2019년 11월 5일 화요일

Jetson TX2 - OpenCV 4.1.1 upgrade

New Jetpack 4.3(2019 Dec) comes with built in OpenCV 4.1.1. So If you make a new image, you don't have to do this job.

I used Jetson TX2, Ubuntu 18.04 Official image with root account. Installing Ubuntu 18.04 on the Jetson TX2, please visit my another article at https://spyjetson.blogspot.com/2019/11/jetsontx2-installation-osubuntu-1804.html .

And I've explained installing OpenCV 4.1.1 on the Jetson Nano at https://spyjetson.blogspot.com/2019/09/jetsonnano-opencv-411-build.html.

Installing OpenCV on the Jetson TX2 is not much different than installing it on the Jetson Nano.
You can downlaod this script at my repo(https://github.com/raspberry-pi-maker/NVIDIA-Jetson/tree/master/useful_script 
This script file automatically removes old OpenCV(3.3) installed on the Jetson TX2.


Check the current OpenCV version



root@spytx-desktop:/usr/local/src# python3
Python 3.6.8 (default, Oct  7 2019, 12:59:55) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'3.3.1'
>>> exit();

Current OpenCV version is 3.3. Now remove this version and install 4.1.1 version.


Install OpenCV4.1.1


The script name is "install_opencv4.1.1_TX2.sh".  It's very similar to "install_opencv4.1.1_Nano.sh". But there's one big difference. That is CUDA Architecture. The cmake define options in the script file, CUDA_ARCH_BIN="5.3" has changed to CUDA_ARCH_BIN="6.2". And I found that the GUI GTK version 2, 3 conflict may occur when I testing "Human Pose estimation using tensorflow". So I changed GUI option in the sh file from GTK to QT.

These are some of my changes in the "install_opencv4.1.1_TX2.sh".


apt-get install qt5-default
-D WITH_GTK=OFF
-D WITH_QT=ON


Follow these steps to install  OpenCV 4.1.1 .


cd /usr/local/src
git clone https://github.com/raspberry-pi-maker/NVIDIA-Jetson.git
cd NVIDIA-Jetson/useful_scripts
chmod 755 install_opencv4.1.1_TX2.sh
./install_opencv4.1.1_TX2.sh /usr/local/src

Install_opencv4.1.1_TX2.sh files parameter "/usr/local/src" is the directory to store the opencv source codes.
OpenCV source compiling has little to do with the GPU. Source code compilation speed depends on CPU performance. While the Jetson TX2's CPU outperforms the Jetson Nano, it doesn't make much difference, so the compilation speed doesn't noticeably improve.
So the OpenCV installation can take a while, have a coffee break.

Be careful : If you see the "Download failed: 1;"unsupported protocol"" message during the build and fail to build, rebuild cmake. See my other article here.  

Check the installation

If you have installed successfully, you can check the result like this.


root@spypiggy-desktop:/usr/local/src# python3
Python 3.6.8 (default, Oct  7 2019, 12:59:55) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> cv2.__version__
'4.1.1'



And check the cuda support of OpenCV. In the build information, you can see this line:
"NVIDIA CUDA:                   YES (ver 10.0, CUFFT CUBLAS)"


root@spypiggy-desktop:/usr/local/src# python3
Python 3.6.8 (default, Oct  7 2019, 12:59:55) 
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import cv2
>>> print(cv2.getBuildInformation())


댓글 없음:

댓글 쓰기