mdegans / nano_build_opencv

Build OpenCV on Nvidia Jetson Nano
MIT License
504 stars 199 forks source link

Build OpenCV with CUDA on Jetson AGX Xavier #65

Open habjoel opened 2 years ago

habjoel commented 2 years ago

Hi @mdegans

I would like to use your script to build OpenCV with CUDA support on the Jetson AGX Xavier. There is already a OpenCV installed on the device through Jetpack (but without cuda). Do I need uninstall it before running the script (sudo apt-get purge -y '*opencv*') or does it work without that?

Furthermore, is there any reason why this script should not work for OpenCV version > 4.4.0?

habjoel commented 2 years ago

@mdegans The script worked flawlessly for OpenCV 4.5.0. :) The only thing I am confused about is that there is no /usr/include/opencv4 or /usr/lib/python3.6/dist-packages/cv2 directory, which exist for the native OpenCV installation. Why is that and should I be worried about it?

Furthermore, I am planning to use OpenCV together with ROS Melodic and I am hoping that ROS will use my newly installed OpenCV with CUDA... do you have any experience with that?

mdegans commented 2 years ago

Hi @mdegans

I would like to use your script to build OpenCV with CUDA support on the Jetson AGX Xavier. There is already a OpenCV installed on the device through Jetpack (but without cuda). Do I need uninstall it before running the script (sudo apt-get purge -y 'opencv') or does it work without that?

Furthermore, is there any reason why this script should not work for OpenCV version > 4.4.0?

It's not mandatory to remove a preexisting version of OpenCV so long as you know your build system and/or python paths. Some Nvidia software requires 4.1.1 anyway, I think, and as such apt might remove more than you'd expect (because it would break that software anyway).

mdegans commented 2 years ago

@mdegans The script worked flawlessly for OpenCV 4.5.0. :) The only thing I am confused about is that there is no /usr/include/opencv4 or /usr/lib/python3.6/dist-packages/cv2 directory, which exist for the native OpenCV installation. Why is that and should I be worried about it?

Furthermore, I am planning to use OpenCV together with ROS Melodic and I am hoping that ROS will use my newly installed OpenCV with CUDA... do you have any experience with that?

You'll have to look into OpenCV's cmake to see how it figures out the python path (and the way that worked it changed recently). If you run the script from within a venv, it'll probably pick the venv's location to install the python module. In any case you should be able to copy and paste the cv2 directory wherever you want it without breaking anything.

HXB-1997 commented 11 months ago

what's your jetpack version? @habjoel my jetpack is 5.1.2,and I specified OpenCV version 4.5.0. when I run the bash, terminal says multipul dependency unmet,and the dependency is not to be installed