With the deprecation of OpenCV4Tegra in L4T 28.1, developers may want to build OpenCV from source for their applications. There is a script on the JetsonHacks Github account to help in the process. Looky here:
Background
For some applications it makes sense to build OpenCV from source. OpenCV is a rich environment with many options. For example, the OpenCV libraries in the Ubuntu repositories currently do not include GPU acceleration for aarch64 machines. For the Jetson, with its built in GPU, it makes sense to build GPU support into the OpenCV library.
An earlier NVIDIA supplied version of OpenCV4Tegra provided a variety of optimizations for the OpenCV library. Over the course of the last couple of years these optimizations have migrated upstream. That means that the optimizations are now available in the public OpenCV library.
Installation
The community has gathered the recipe(s) for building OpenCV for version later than OpenCV 3.0. There is a repository on the JetsonHacks Github account which contains a build script to help in the process.
To download the source and build OpenCV:
$ git clone https://github.com/jetsonhacks/buildOpenCVTX1.git
$ cd buildOpenCVTX1
$ ./buildOpenCV.sh
Once finished building, you are ready to install.
Navigate to the build directory to install the newly built libraries:
$ cd ~/opencv/build
Note: As discussed in the video, due to the nature of the multi-processor make process, some files may not be compiled. It’s a good idea to run make again after switching to the build directory:
$ make
This takes an extra few minutes, but will round up any stragglers and save headaches down the road.
Now install:
$ sudo make install
Once you have generated the build files, you can use the ccmake tool to examine the different options and modules available.
Remember to setup your OpenCV library paths correctly after installation.
Notes
- This is meant to be a template for building your own custom version of OpenCV, pick and choose your own modules and options
- The Jetson TX1 in the video is running L4T 28.1, OpenCV 3.3 is the version being built.
- In the script, GStreamer support has been enabled. However there are issues using the Jetson TX1 onboard camera with it. The issue is discussed here: NVIDIA Jetson TX1 Forum – L4T 28.1 Onboard Camera Error. As of this writing (9/5/2017), I have been unable to get this working.
- Most people do NOT have both OpenCV4Tegra and the source built OpenCV on their system. Some people have noted success using both however, check the forums.
- Sometimes the make tool does not build everything. Experience dictates to go back to the build directory and run make again, just to be sure
- Different modules and setting may require different dependencies, make sure to look for error messages when building.
- After building, you should run the tests. The build script includes the testing options. All tests may not pass.
- The build script adds support for Python 2.7
- The compiler assumes that the Jetson TX1 aarch64 (ARMv8) architecture is NEON enabled, therefore you do not have to enable the NEON flag for the build
The information for this script was gathered from several places:
The post Build OpenCV on the NVIDIA Jetson TX1 appeared first on JetsonHacks.