Compile and Install OpenCV for Nvidia Nano

Spread the love
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  

Update your Operating System

Follow the link below to update your operating system.

https://brisbaneroboticsclub.id.au/update-and-upgrade-operating-system-linux/

Download the Packages

Make sure you have pip3 installled.

sudo apt-get install python3-pip

Reboot the Nano.

Check current version of OpenCV

The jetpack image comes pre-installed with OpenCV. To check which version you have installed, enter the following command.

dpkg -l | grep libopencv

For more information on your OpenCV installation to check if Cuda is installed, follow these instructions and install jtop. http://brisbaneroboticsclub.id.au/measure-nvidia-nano-gpu-performance/

Once ‘jtop’ is installed, see if OpenCV is compiled for Cuda. The standard Jetpack image is NOT compiled for CUDA.

OpenCV operates much faster when it is compiled for Cuda.

Remove existing OpenCV (Optional)

sudo pip3 uninstall opencv-python

Increase swap file

Reduce crashes while compiling and compile faster.

Follow the instructions in the link below, however use this command in ‘For example’.

git clone https://github.com/JetsonHacksNano/resizeSwapMemory

cd resizeSwapMemory

./setSwapMemorySize.sh -g 4

sudo reboot

https://www.jetsonhacks.com/2019/11/28/jetson-nano-even-more-swap/

Compile OpenCV using bash script.

Follow the link and follow the instructions OR go to the next section for our quick install guide.

For website instructions, please click the following link…

https://www.jetsonhacks.com/2019/11/22/opencv-4-cuda-on-jetson-nano/

Enter these commands to Auto compile and install the latest version of OpenCV

Open the ‘System monitor’ to monitor CPU and swap file performance. The enter the following command lines to install and compile the most recent version of OpenCV.

git clone https://github.com/JetsonHacksNano/buildOpenCV

cd buildOpenCV

./buildOpenCV.sh |& tee openCV_build.log

sudo ldconfig -v
Compiling OpenCV

Check OpenCV installed.

python3 -c 'import cv2; print(cv2.__version__)'
Success!!! OpenCV installed.

Check OpenCV is installed for Cuda.

Follow the instruction in the link below to install ‘jtop” and see Cuda performance and statistics.

http://brisbaneroboticsclub.id.au/measure-nvidia-nano-gpu-performance/

Success!! OpenCV is installed and compiled for Cuda!!!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.