Compiling OpenCV on Jetpack 5

I am struggling to compile OpenCV with CUDA support on Jetpack 5 (Jetson Xavier). The install is working for Python2.7, but doesn’t seem to be recognised by Python3.8. I noticed that the installation placed a cv2 folder under the Python2.7 dist-packages, but under the Python3.8 site-packages.

These are the build flags I used:

local CMAKEFLAGS="
        -D BUILD_EXAMPLES=OFF
        -D INSTALL_PYTHON_EXAMPLES=OFF
        -D BUILD_opencv_python2=ON
        -D BUILD_opencv_python3=ON
        -D CMAKE_BUILD_TYPE=RELEASE
        -D CMAKE_INSTALL_PREFIX=${PREFIX}
        -D CUDA_ARCH_BIN=7.2
        -D CUDA_ARCH_PTX=
        -D CUDA_FAST_MATH=ON
        -D EIGEN_INCLUDE_PATH=/usr/include/eigen3 
        -D ENABLE_NEON=ON
        -D OPENCV_DNN_CUDA=ON
        -D OPENCV_ENABLE_NONFREE=ON
        -D OPENCV_EXTRA_MODULES_PATH=/tmp/build_opencv/opencv_contrib/modules
        -D OPENCV_GENERATE_PKGCONFIG=ON
        -D WITH_CUBLAS=ON
        -D WITH_CUDA=ON
        -D WITH_CUDNN=ON
        -D WITH_GSTREAMER=ON
        -D WITH_LIBV4L=ON
        -D WITH_OPENGL=ON"

Based on this script: nano_build_opencv/build_opencv.sh at master · mdegans/nano_build_opencv · GitHub

2 Likes

Hi,
We have not tried the user’s script on 5.0.1 DP. Will give it a try. Also other users may have tried it and can provide suggestion.

1 Like

Hi,

Could you give this script a try: install_opencv4.6.0_Jetson.sh (2.8 KB)
We have confirmed that it can work on a JetPack 5 environment.

$ sudo chmod +x install_opencv4.6.0_Jetson.sh
$ ./install_opencv4.6.0_Jetson.sh

Thanks.

2 Likes

Thank you, the script worked perfectly!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.