Difference between revisions of "Opencv with cuda support"
Jump to navigation
Jump to search
(3 intermediate revisions by the same user not shown) | |||
Line 14: | Line 14: | ||
<pre> | <pre> | ||
cd jetson-containers/packages/opencv | cd jetson-containers/packages/opencv | ||
nano opencv_install | nano opencv_install.sh | ||
</pre> | </pre> | ||
Then paste the following into the sh file: | Then paste the following into the sh file: | ||
Line 86: | Line 86: | ||
</pre> | </pre> | ||
Now | Now either run the bash file above which will install OpenCV.4.10.0 ... | ||
<pre> | <pre> | ||
bash | bash opencv_install.sh | ||
</pre> | </pre> | ||
Or if you want a specific version of OpenCV then compile opencv as below | |||
Change into the home directory | |||
<pre> | <pre> | ||
sudo ./jetson-containers/packages/opencv/opencv_install.sh https://nvidia.box.com/shared/static/ngp26xb9hb7dqbu6pbs7cs9flztmqwg0.deb OpenCV-4.8.1-aarch64.tar.gz</pre> | sudo ./jetson-containers/packages/opencv/opencv_install.sh https://nvidia.box.com/shared/static/ngp26xb9hb7dqbu6pbs7cs9flztmqwg0.deb OpenCV-4.8.1-aarch64.tar.gz</pre> |
Latest revision as of 13:34, 8 January 2025
Install JTOP
sudo apt install python3-pip
After pip installs:
sudo pip3 install -U jetson-stats
Install jetson containers
# install the container tools git clone https://github.com/dusty-nv/jetson-containers
The opencv_install.sh has gone so you must recreate it using:
cd jetson-containers/packages/opencv nano opencv_install.sh
Then paste the following into the sh file:
#!/bin/bash # version="4.10.0" folder="workspace" set -e for (( ; ; )) do echo "Do you want to remove the default OpenCV (yes/no)?" read rm_old if [ "$rm_old" = "yes" ]; then echo "** Remove other OpenCV first" sudo apt -y purge *libopencv* break elif [ "$rm_old" = "no" ]; then break fi done echo "------------------------------------" echo "** Install requirement (1/4)" echo "------------------------------------" sudo apt-get update sudo apt-get install -y build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev sudo apt-get install -y libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev python3.10-dev python3-numpy sudo apt-get install -y libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libv4l-dev v4l-utils qv4l2 sudo apt-get install -y curl echo "------------------------------------" echo "** Download opencv "${version}" (2/4)" echo "------------------------------------" mkdir $folder cd ${folder} curl -L https://github.com/opencv/opencv/archive/${version}.zip -o opencv-${version}.zip curl -L https://github.com/opencv/opencv_contrib/archive/${version}.zip -o opencv_contrib-${version}.zip unzip opencv-${version}.zip unzip opencv_contrib-${version}.zip rm opencv-${version}.zip opencv_contrib-${version}.zip cd opencv-${version}/ echo "------------------------------------" echo "** Build opencv "${version}" (3/4)" echo "------------------------------------" mkdir release cd release/ cmake -D WITH_CUDA=ON -D WITH_CUDNN=ON -D CUDA_ARCH_BIN="8.7" -D CUDA_ARCH_PTX="" -D OPENCV_GENERATE_PKGCONFIG=ON -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${version}/modules -D WITH_GSTREAMER=ON -D WITH_LIBV4L=ON -D BUILD_opencv_python3=ON -D BUILD_TESTS=OFF -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. make -j$(nproc) echo "------------------------------------" echo "** Install opencv "${version}" (4/4)" echo "------------------------------------" sudo make install echo 'export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH' >> ~/.bashrc echo 'export PYTHONPATH=/usr/local/lib/python3.10/site-packages/:$PYTHONPATH' >> ~/.bashrc source ~/.bashrc echo "** Install opencv "${version}" successfully" echo "** Bye :)"
Now either run the bash file above which will install OpenCV.4.10.0 ...
bash opencv_install.sh
Or if you want a specific version of OpenCV then compile opencv as below Change into the home directory
sudo ./jetson-containers/packages/opencv/opencv_install.sh https://nvidia.box.com/shared/static/ngp26xb9hb7dqbu6pbs7cs9flztmqwg0.deb OpenCV-4.8.1-aarch64.tar.gz
Run JTOP and you should see