Installing OpenCV Contrib for Jetson Nano

Hello I have been having issues trying to add the OpenCV Contrib.

I run these code.

$ wget https://github.com/opencv/opencv/archive/4.1.1.zip -O opencv-4.1.1.zip
$ wget https://github.com/opencv/opencv_contrib/archive/4.1.1.zip -O opencv_contrib-4.1.1.zip
$ unzip opencv-4.1.1.zip
$ unzip opencv_contrib-4.1.1.zip
$ cp -r ./opencv_contrib-4.1.1/modules ./opencv-4.1.1/modules/
$ cd opencv-4.1.1/
$ mkdir build
$ cd build
$cmake
-D CUDA_HOST_COMPILER=/usr/bin/gcc-7
-D CUDA_NVCC_FLAGS="–expt-relaxed-constexpr"
-D CUDA_VERSION=“10000”
-DWITH_NVCUVID=OFF
-DENABLE_CCACHE=OFF
-DEIGEN_INCLUDE_PATH=/usr/include/eigen3
-D HAVE_CUDA=1
-D WITH_CUDA=ON
-D CUDA_ARCH_BIN=“5.3”
-D CUDA_ARCH_PTX=""
-DWITH_FAST_MATH=OFF
-D WITH_GSTREAMER=ON
-D WITH_LIBV4L=ON
-D BUILD_opencv_python2=OFF
-D BUILD_opencv_python3=ON
-DPYTHON3_EXECUTABLE=/usr/bin/python3
-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 WITH_CUBLAS=ON
-D LAPACK_CBLAS_H=/usr/include/aarch64-linux-gnu/cblas.h …

$ make -j4
$ sudo make install

cmake shows many modules during program execution
OpenCV modules:
To be built: aruco bgsegm bioinspired calib3d ccalib core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev datasets dnn dnn_objdetect dpm face features2d etc…

But I run the python3 after finishing this code I cant use contrib.

import cv2
print(cv2.getBuildInformation())
To be built: calib3d core dnn features2d flann gapi highgui imgcodecs imgproc ml objdetect photo python2 python3 stitching ts video videoio

print(cv2)
<module ‘cv2’ from ‘/usr/lib/python3.6/dist-packages/cv2/python-3.6/cv2.cpython-36m-aarch64-linux-gnu.so’>

Maybe Opencv is not with contrib but default.

So Please tell me the solution.

Hi,
Do you use Jetson Nano with emmc or SD card? If you use emmc module, the freespace is not anough for building Open CV from source code. Please use SD card module and has SD card at least 32GB.

For building/installing OpenCV, please try this script:
JEP/install_opencv4.5.0_Jetson.sh at master · AastaNV/JEP · GitHub

1 Like

Thank you for your advice.
I use SD card at all times.

After runnning this code, my OpenCV ver has changed.
And I can use contrib.