OpenCV 3.1 with USB camera support

Hi,

I have created a guide to install OpenCV3.1 on Jetson TX1.

The main motivation of this guide was the inability of OpenCV4Tegra to change capture resolution of USB cameras from Python.

You can access it here: http://dev.t7.ai/jetson/opencv/

Hope it helps,
Keko

This guide was very useful, especially in learning about the different cmake flags. Thanks!

thank you for your guide.
But, do you have tested the performance about it, i just run the facedetect demo at opecnv 2.4.13.2, the video fps for 640x480 is more than 10 times with openCV4Tegra using jetpack 2.3.1.

That’s work for me!
Thank you,Korgakoth!

Hi,

Thanks for this guide.

But I have run into some problems and if you can help me.

So I followed every step in your guide and I used the modified source for OpenCV, but when I make -j4 it, it returns the following errors:

In file included from /home/ubuntu/opencv/release/modules/cudaobjdetect/precomp.hpp:59:0:
/home/ubuntu/opencv/modules/cudalegacy/include/opencv2/cudalegacy/private.hpp:90:2: fatal error: can’t write PCH file: No space left on device
 }}
  ^
compilation terminated.
modules/cudaobjdetect/CMakeFiles/pch_Generate_opencv_cudaobjdetect.dir/build.make:62: recipe for target 'modules/cudaobjdetect/precomp.hpp.gch/opencv_cudaobjdetect_RELEASE.gch' failed
make[2]: *** [modules/cudaobjdetect/precomp.hpp.gch/opencv_cudaobjdetect_RELEASE.gch] Error 1
CMakeFiles/Makefile2:9106: recipe for target 'modules/cudaobjdetect/CMakeFiles/pch_Generate_opencv_cudaobjdetect.dir/all' failed
make[1]: *** [modules/cudaobjdetect/CMakeFiles/pch_Generate_opencv_cudaobjdetect.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
In file included from /home/ubuntu/opencv/modules/objdetect/include/opencv2/objdetect.hpp:474:0,
                 from /home/ubuntu/opencv/release/modules/cudaobjdetect/test_precomp.hpp:60:
/home/ubuntu/opencv/modules/objdetect/include/opencv2/objdetect/detection_based_tracker.hpp:222:1: fatal error: can’t write PCH file: No space left on device
 } //end of cv namespace
 ^
compilation terminated.
In file included from /home/ubuntu/opencv/modules/video/include/opencv2/video.hpp:56:0,
                 from /home/ubuntu/opencv/release/modules/cudalegacy/perf_precomp.hpp:58:
/home/ubuntu/opencv/modules/video/include/opencv2/video/tracking.hpp:624:1: fatal error: can’t write PCH file: No space left on device
 } // cv
 ^
compilation terminated.
modules/cudaobjdetect/CMakeFiles/pch_Generate_opencv_test_cudaobjdetect.dir/build.make:62: recipe for target 'modules/cudaobjdetect/test_precomp.hpp.gch/opencv_test_cudaobjdetect_RELEASE.gch' failed
make[2]: *** [modules/cudaobjdetect/test_precomp.hpp.gch/opencv_test_cudaobjdetect_RELEASE.gch] Error 1
CMakeFiles/Makefile2:9303: recipe for target 'modules/cudaobjdetect/CMakeFiles/pch_Generate_opencv_test_cudaobjdetect.dir/all' failed
make[1]: *** [modules/cudaobjdetect/CMakeFiles/pch_Generate_opencv_test_cudaobjdetect.dir/all] Error 2
modules/cudalegacy/CMakeFiles/pch_Generate_opencv_perf_cudalegacy.dir/build.make:62: recipe for target 'modules/cudalegacy/perf_precomp.hpp.gch/opencv_perf_cudalegacy_RELEASE.gch' failed
make[2]: *** [modules/cudalegacy/perf_precomp.hpp.gch/opencv_perf_cudalegacy_RELEASE.gch] Error 1
CMakeFiles/Makefile2:8987: recipe for target 'modules/cudalegacy/CMakeFiles/pch_Generate_opencv_perf_cudalegacy.dir/all' failed
make[1]: *** [modules/cudalegacy/CMakeFiles/pch_Generate_opencv_perf_cudalegacy.dir/all] Error 2
In file included from /home/ubuntu/opencv/modules/objdetect/include/opencv2/objdetect.hpp:474:0,
                 from /home/ubuntu/opencv/release/modules/cudaobjdetect/perf_precomp.hpp:58:
/home/ubuntu/opencv/modules/objdetect/include/opencv2/objdetect/detection_based_tracker.hpp:222:1: fatal error: can’t write PCH file: No space left on device
 } //end of cv namespace
 ^
compilation terminated.
modules/cudaobjdetect/CMakeFiles/pch_Generate_opencv_perf_cudaobjdetect.dir/build.make:62: recipe for target 'modules/cudaobjdetect/perf_precomp.hpp.gch/opencv_perf_cudaobjdetect_RELEASE.gch' failed
make[2]: *** [modules/cudaobjdetect/perf_precomp.hpp.gch/opencv_perf_cudaobjdetect_RELEASE.gch] Error 1
CMakeFiles/Makefile2:9391: recipe for target 'modules/cudaobjdetect/CMakeFiles/pch_Generate_opencv_perf_cudaobjdetect.dir/all' failed
make[1]: *** [modules/cudaobjdetect/CMakeFiles/pch_Generate_opencv_perf_cudaobjdetect.dir/all] Error 2
Makefile:160: recipe for target 'all' failed
make: *** [all] Error 2

I didn’t install anything else except for Jetpack 3.0 so I’m not sure why it’s taking up so much space. Can you help?

Thanks!

Building opencv takes a lot of disk space.
You could try to build it on a USB disk or SD card.
For disk usage, you can check its free space with

df -H

and you can try to see where it gets used from fs root with

du -sh /*

and then recursively checking biggest folders.
A typical place where a lot of space can be consumed is in /var/log when you encounter many errors.

Hi nothingworkswithme,

-j4 requires more space than -j1 (default) but the compilation time will be much longer using less parallel jobs. In fact you have only two options: compile using precompiler headers on J1 (less disk usage) or without the precompiled but at 4 parallel jobs. I suggest you to try the second, add this param to the command line: -D ENABLE_PRECOMPILED_HEADERS=OFF and run with -j4

Let me know if it works

Hi Korgakoth,

Thanks for the reply! I tried adding -D ENABLE_PRECOMPILED_HEADERS=OFF to CMakeLists.txt but when I run make -j4 it’s still showing no more space.

I’ve used this guide with success. OpenCV: Building OpenCV for Tegra with CUDA Has builds for several of the nvidia boards. Also if you are running ROS it has its own internal opencv lib and its 3.2. If you want to run stuff in ROS and have opencv be cuda enabled you can’t just build opencv put it in /usr/lib and be done with it. ROS will never see it. It puts its version in a directory in /tmp that disappears as soon as you stop the app or it crashes. Hard to find that puppy to see what is going on with it.The build instructions for cuda enhanced opencv in ROS are here. Hover over the text to get rid of the extra text after translation. ROS KineticでOpenCV3 x CUDA 8.0RCのロボット用GPGPU環境を構築する - Qiita To get ORB_SLAM2 working with the ZED camera you need the nvidia version 3.1.1 and 3.2 in ROS to make it all work. Works much better after enhancing everything with cuda ORB_SLAM2_GPU - YouTube You will find other ways to get cuda enhanced stuff working in ROS but they are klugey and can give you fits. This way works much better. Once you have the deb built its easy to reinstall it should you need to reflash the jetson.

I have Jetson Tx1 development kit opened the box but not used. I had bought for a Project but the Project got cancelled. So I was not able to use this Kit. I am now selling this development kit of Rs 48000/-. (negotiable). Please contact me on email id as.k231216@gmail.com. You guys can call me or mail me for the recent pictures of the kit. It will be helpful if anyone needs it.