How to Build OpenCV on Jetson Modules?
Hardware: Jetson AGX Xavier
OS: Jetpack 4.6
In this blog post, you will learn how to build OpenCV on Jetson modules. If you have not installed OpenCV yet, you can by following the steps in this blog post.
First, download OpenCV repository with extra modules from GitHub using the following command and extract them.
curl -L https://github.com/opencv/opencv/archive/4.4.0.zip -o opencv-4.4.0.zipcurl -L https://github.com/opencv/opencv_contrib/archive/4.4.0.zip -o opencv_contrib-4.4.0.zipunzip opencv-4.4.0.zipunzip opencv_contrib-4.4.0.zip
Go to the downloaded directory and create a build folder.
cd opencv-4.4.0/mkdir build && cd build
Run the cmake and make commands to compile the OpenCV scripts. This could take a while.
cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="5.3,6.2,7.2" -D CUDA_ARCH_PTX="" -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.4.0/modules -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_opencv_sfm=OFF ..make -j6
Then, run the following command to build OpenCV.
sudo checkinstall -D make install
Change the first four values as the following:
#0 - Maintainer: [ firstname.lastname@example.org ]
#1 - Summary: [ Open Computer Vision Library (with Cuda 10.2) ]
#2 - Name: [ libopencv-4.4.0 ]
#3 - Version: [ 4.4.0 ]
After entering the values, installation will start. You can press Enter to all the questions while installing.
At the end, give permissions to the Debian package and change its name if you wish. Here, 4.4.0-1 is the Name of the Debian package that is changed at the previous step. You should use what you have written before.
sudo chmod 666 libopencv-4.4.0_4.4.0-1_arm64.debmv libopencv-4.4.0_4.4.0-1_arm64.deb libopencv-4.4.0_arm64_jetpack_4.6_xavier.deb
You can also see the packages installed using the following command.
dpkg --contents libopencv-4.4.0_arm64_jetpack_4.6_xavier.deb