# How to install Opencv 4.0 on Jetson TX2 with jetpack 4.2

**URL:** <https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289>\
**Category:** Jetson TX2\
**Tags:** opencv\
**Created:** [April 17, 2019, 10:37pm UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289 "2019-04-17T22:37:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![sandeepkumarjangir07](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sandeepkumarjangir07](https://forums.developer.nvidia.com/u/sandeepkumarjangir07)\
**Post date:** [April 17, 2019, 10:37pm UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/1 "2019-04-17T22:37:34Z")

</div>

Hello,  
I have successfully installed Jetpack 4.2 using the sdk on my jetson tx2. I was building the opecv 3.4 but it always stops at 47% giving the error as :

No rule to make target ‘/usr/lib/aarch64-linux-gnu/libGL.so’, needed by ‘lib/libopencv\_cudev.so.3.4.1’. Stop. tx2

Can some one please help me solve this problem or help me build opecv 4.0

Thanks

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [April 18, 2019, 4:24am UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/2 "2019-04-18T04:24:47Z")

</div>

sandeepkumarjangir0,

Did you see this libGL.so under that path?

---

<div class="post-metadata">

**Author:** ![sandeepkumarjangir07](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sandeepkumarjangir07](https://forums.developer.nvidia.com/u/sandeepkumarjangir07)\
**Post date:** [April 18, 2019, 9:14pm UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/3 "2019-04-18T21:14:20Z")

</div>

Yes,the file exist under that path .!!

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [April 19, 2019, 1:50am UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/4 "2019-04-19T01:50:23Z")

</div>

Please try to use these script.

> **[JEP/script at master · AastaNV/JEP](https://github.com/AastaNV/JEP/tree/master/script)**
>
> Contribute to AastaNV/JEP development by creating an account on GitHub.

---

<div class="post-metadata">

**Author:** ![pierre.giraud](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@pierre.giraud](https://forums.developer.nvidia.com/u/pierre.giraud)\
**Post date:** [April 19, 2019, 9:39am UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/5 "2019-04-19T09:39:35Z")

</div>

Hi sandeepkumarjangir07,

As WayneWWW proposed, I followed the link to the openCV installation files and have been able to install OpenCV 4.0.0 with the “install\_opencv4.0.0\_Nano.sh” on my Jetson TX2 by changing the architecture to 6.2. I had some issues with packages that were not too hard to fix so you should be able to do the same and have OpenCV 4.0.0 running on your TX2.

Bye :)

---

<div class="post-metadata">

**Author:** ![sandeepkumarjangir07](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sandeepkumarjangir07](https://forums.developer.nvidia.com/u/sandeepkumarjangir07)\
**Post date:** [April 20, 2019, 8:10pm UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/6 "2019-04-20T20:10:19Z")

</div>

Thank you all for the reply. I re-flashed my TX2 with jetpack 4.2 and built the opencv 4 using the nano script. But my python 2 and 3 version of opencv has been downgraded from 3.3.0 to 3.2.0 instead upgrading it to 4.0. The binding for python in the script are ON but still couldn’t figure out how to update my opencv version of python 2 and 3 to 4.0. There were no errors during the build(some warning of course but nothing serious ). can you guys suggest something that might be wrong or something that could be done to make my python-opencv version to 4.0 ?

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [April 22, 2019, 4:30am UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/7 "2019-04-22T04:30:13Z")

</div>

Hi Sandeep,

If I remember correctly, to install latest opencv-python, you should not use apt-get or any tools that can directly download the prebuilt library.

You will need to build it from opencv source by yourself. I think opencv forum or some external links should have such tutorial.

---

<div class="post-metadata">

**Author:** ![sandeepkumarjangir07](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sandeepkumarjangir07](https://forums.developer.nvidia.com/u/sandeepkumarjangir07)\
**Post date:** [April 22, 2019, 10:24am UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/8 "2019-04-22T10:24:12Z")

</div>

you are right WayneWWW but I am building the opencv from the source.  
When I build opencv 3.4.0, I get the error No rule to make target ‘/usr/lib/aarch64-linux-gnu/libGL.so’, needed by ‘lib/libopencv\_cudev.so.3.4.1’. Stop. tx2 and when i checked the libGL.so, the link is broken and there should be another libGL.so present in /usr/lib/aarch64-linux-gnu/tegra directory but its not there.

Then I started building the opencv 4.0, which does build properly without any errors but my python version shows the opencv version as 3.2.0.

I am trying to solve errors from either of the build but nothing is proving to be working. I have flashed my jetson once and do not want to do it again because flashing takes a lot of time and also building tensorflow and protobuf from source takes even more (not even including the opencv build :-p)

if you can help me with libGL.so file or give me a reason why build of opencv4.0 still shows version 3.2.0 that would be helpful.

regards

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [April 23, 2019, 2:34am UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/9 "2019-04-23T02:34:24Z")

</div>

> > > When I build opencv 3.4.0, I get the error No rule to make target ‘/usr/lib/aarch64-linux-gnu/libGL.so’, needed by ‘lib/libopencv\_cudev.so.3.4.1’. Stop. tx2 and when i checked the libGL.so, the link is broken and there should be another libGL.so present in /usr/lib/aarch64-linux-gnu/tegra directory but its not there.

Do you mean the default jetpack has a empty symlink for libGL.so? I will help check.

I don’t think opencv4.0 gives the 3.2 opencv-python. Are you sure you didn’t install it by using apt-get or something else?

---

<div class="post-metadata">

**Author:** ![sandeepkumarjangir07](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sandeepkumarjangir07](https://forums.developer.nvidia.com/u/sandeepkumarjangir07)\
**Post date:** [May 2, 2019, 9:39am UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/10 "2019-05-02T09:39:14Z")

</div>

Yes, there was no libGL.so so i re-flashed tx2 with 4.2 again and its present now. But instead of building Opencv 3.4.0 , i tried again to install opecv 4.0 and below is the log after the build and opencv version that it shows.

Setting up libdapclient6v5:arm64 (3.19.1-2build1) …  
Setting up gdal-data (2.2.3+dfsg-2) …  
Setting up libgeos-c1v5:arm64 (3.6.2-1build2) …  
Setting up libpq5:arm64 (10.7-0ubuntu0.18.04.1) …  
Processing triggers for libc-bin (2.27-3ubuntu1) …  
Setting up libgdcm2.8:arm64 (2.8.4-1build2) …  
Setting up libopencv-ml3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libarpack2:arm64 (3.5.0+real-2) …  
Processing triggers for man-db (2.8.3-2ubuntu0.1) …  
Setting up libopencv-imgproc3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libopencv-flann3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libtcl8.6:arm64 (8.6.8+dfsg-3) …  
Setting up libhdf4-0-alt (4.2.13-2) …  
Setting up libopencv-video3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libxerces-c3.2:arm64 (3.2.0+debian-2) …  
Setting up liburiparser1:arm64 (0.8.4-1) …  
Setting up libsz2:arm64 (0.3.2-2) …  
Setting up proj-data (4.9.3-2) …  
Setting up libgl2ps1.4 (1.4.0+dfsg1-1) …  
Setting up libopencv-photo3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libproj12:arm64 (4.9.3-2) …  
Setting up libhdf5-openmpi-100:arm64 (1.10.0-patch1+docs-4) …  
Setting up libhdf5-100:arm64 (1.10.0-patch1+docs-4) …  
Setting up libtk8.6:arm64 (8.6.8-4) …  
Setting up libtesseract4 (4.00~git2288-10f4998a-2) …  
Setting up libkmlbase1:arm64 (1.3.0-5) …  
Setting up libarmadillo8 (1:8.400.0+dfsg-2) …  
Setting up libogdi3.2 (3.2.0+ds-2) …  
Setting up proj-bin (4.9.3-2) …  
Setting up libgeotiff2:arm64 (1.4.2-2build1) …  
Setting up libnetcdf13:arm64 (1:4.6.0-2build1) …  
Setting up libopencv-shape3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libspatialite7:arm64 (4.3.0a-5build1) …  
Setting up libkmldom1:arm64 (1.3.0-5) …  
Setting up libnetcdf-c++4 (4.2-8) …  
Setting up libkmlengine1:arm64 (1.3.0-5) …  
Setting up odbcinst1debian2:arm64 (2.3.4-1.1ubuntu3) …  
Setting up odbcinst (2.3.4-1.1ubuntu3) …  
Setting up libgdal20 (2.2.3+dfsg-2) …  
Setting up libopencv-imgcodecs3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libvtk6.3 (6.3.0+dfsg1-11build1) …  
Setting up libopencv-videoio3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libopencv-viz3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libopencv-superres3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libopencv-highgui3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libopencv-objdetect3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libopencv-features2d3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libopencv-calib3d3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libopencv-stitching3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libopencv-videostab3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up libopencv-contrib3.2:arm64 (3.2.0+dfsg-4ubuntu0.1) …  
Setting up python3-opencv (3.2.0+dfsg-4ubuntu0.1) …  
Setting up python-opencv (3.2.0+dfsg-4ubuntu0.1) …  
Processing triggers for libc-bin (2.27-3ubuntu1) …  
\*\* Install opencv-4.0.0 successfully  
\*\* Bye :)  
nvidia@nvidia:~/JEP/script$ clear

nvidia@nvidia:~/JEP/script$ python3  
Python 3.6.7 (default, Oct 22 2018, 11:32:17)  
[GCC 8.2.0] on linux  
Type “help”, “copyright”, “credits” or “license” for more information.

> > > import cv2  
> > > cv2. **version**  
> > > ‘3.2.0’

I think its not installing properly due memory limitations but i have approx 16 gb free on my tx2, so it might be ram issue but still not sure whats causing this !!

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [May 2, 2019, 10:03am UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/11 "2019-05-02T10:03:54Z")

</div>

```auto
Setting up python3-opencv (3.2.0+dfsg-4ubuntu0.1) ...
Setting up python-opencv (3.2.0+dfsg-4ubuntu0.1) ..

```

Looks like it is installing 3.2.0

---

<div class="post-metadata">

**Author:** ![sandeepkumarjangir07](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sandeepkumarjangir07](https://forums.developer.nvidia.com/u/sandeepkumarjangir07)\
**Post date:** [May 2, 2019, 10:16am UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/12 "2019-05-02T10:16:26Z")

</div>

#!/bin/bash

# 

# Copyright (c) 2018, NVIDIA CORPORATION. All rights reserved.

# 

# NVIDIA Corporation and its licensors retain all intellectual property

# and proprietary rights in and to this software, related documentation

# and any modifications thereto. Any use, reproduction, disclosure or

# distribution of this software and related documentation without an express

# license agreement from NVIDIA Corporation is strictly prohibited.

# 

if [“$#” -ne 1]; then  
echo “Usage: $0 ”  
exit  
fi  
folder=“$1”  
user=“nvidia”  
passwd=“nvidia”

echo “\*\* Install requirement”  
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  
sudo apt-get install -y python2.7-dev python3.6-dev python-dev python-numpy python3-numpy  
sudo apt-get install -y libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev  
sudo apt-get install -y libv4l-dev v4l-utils qv4l2 v4l2ucp  
sudo apt-get install -y curl  
sudo apt-get update

echo “\*\* Download opencv-4.0.0”  
cd $folder  
curl -L [https://github.com/opencv/opencv/archive/4.0.0.zip](https://github.com/opencv/opencv/archive/4.0.0.zip) -o opencv-4.0.0.zip  
curl -L [https://github.com/opencv/opencv\_contrib/archive/4.0.0.zip](https://github.com/opencv/opencv_contrib/archive/4.0.0.zip) -o opencv\_contrib-4.0.0.zip  
unzip opencv-4.0.0.zip  
unzip opencv\_contrib-4.0.0.zip  
cd opencv-4.0.0/

echo “\*\* Building…”  
mkdir release  
cd release/  
cmake -D WITH\_CUDA=ON -D CUDA\_ARCH\_BIN=“6.2” -D CUDA\_ARCH\_PTX=“” -D OPENCV\_EXTRA\_MODULES\_PATH=../../opencv\_contrib-4.0.0/modules -D WITH\_GSTREAMER=ON -D WITH\_LIBV4L=ON -D BUILD\_opencv\_python2=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 -j3  
sudo make install  
sudo apt-get install -y python-opencv python3-opencv

echo “\*\* Install opencv-4.0.0 successfully”

This is the script from above used to build.

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [May 2, 2019, 10:20am UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/13 "2019-05-02T10:20:27Z")

</div>

```auto
sudo apt-get install -y python-opencv python3-opencv

```

Please do not add these.

---

<div class="post-metadata">

**Author:** ![silasv38em](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@silasv38em](https://forums.developer.nvidia.com/u/silasv38em)\
**Post date:** [May 16, 2019, 3:58am UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/14 "2019-05-16T03:58:28Z")

</div>

I’m working on multi-class object detection with tracking on Jetson Nano.

I’d like to use the tracking libraries in opencv.

I successfully installed opencv using WayneWWW’s script:  
[url][https://github.com/AastaNV/JEP/tree/master/script[/url]](https://github.com/AastaNV/JEP/tree/master/script%5B/url%5D)

However no trackers (ex: cv2.TrackerMOSSE\_create) were installed.

Could someone kindly help me install opencv’s object trackers or suggest a replacement object tracker for the Jetson Nano?

---

<div class="post-metadata">

**Author:** ![kayccc](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/kayccc/32/14043_2.png) [@kayccc](https://forums.developer.nvidia.com/u/kayccc)\
**Post date:** [May 23, 2019, 2:48am UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/15 "2019-05-23T02:48:37Z")

</div>

> [@](#):
>
> I’m working on multi-class object detection with tracking on Jetson Nano.
> 
> I’d like to use the tracking libraries in opencv.
> 
> I successfully installed opencv using WayneWWW’s script:  
> [https://github.com/AastaNV/JEP/tree/master/script](https://github.com/AastaNV/JEP/tree/master/script)
> 
> However no trackers (ex: cv2.TrackerMOSSE\_create) were installed.
> 
> **Could someone kindly help me install opencv’s object trackers or suggest a replacement object tracker for the Jetson Nano?**

Hi silasv38em,

Please file your issue into Jetson Nano forum: [https://devtalk.nvidia.com/default/board/371/jetson-nano/](https://devtalk.nvidia.com/default/board/371/jetson-nano/)

---

<div class="post-metadata">

**Author:** ![animbekar25](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@animbekar25](https://forums.developer.nvidia.com/u/animbekar25)\
**Post date:** [May 26, 2019, 10:40am UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/16 "2019-05-26T10:40:53Z")

</div>

hello , i am trying to install opencv and opencv-contrib as i wanted to use the “xfeatures2d” from the contrib/modules but when i try to compile the opencv by using the command “make -j4” after 34% it stops and the jetson runs out of memory. I have 5 GB of free space in the jetson tx2 .  
can anyone help me out ?

Thank you.

---

<div class="post-metadata">

**Author:** ![WayneWWW](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/waynewww/32/14043_2.png) [@WayneWWW](https://forums.developer.nvidia.com/u/WayneWWW)\
**Post date:** [May 27, 2019, 4:29am UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/17 "2019-05-27T04:29:58Z")

</div>

I cannot tell you what is the necessary disk size for installing opencv, but sometimes the makefile will create too much file simultaneously when you compile with -j option. You could try to use -j2 with slower build time or just some external storage(usb/sdcard).

---

<div class="post-metadata">

**Author:** ![yohanmarvel012](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@yohanmarvel012](https://forums.developer.nvidia.com/u/yohanmarvel012)\
**Post date:** [June 13, 2019, 2:35pm UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/18 "2019-06-13T14:35:25Z")

</div>

Do i have to flash jetpack 4.2 if i want to install opencv 4.0?

---

<div class="post-metadata">

**Author:** ![yohanmarvel012](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@yohanmarvel012](https://forums.developer.nvidia.com/u/yohanmarvel012)\
**Post date:** [June 13, 2019, 2:41pm UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/19 "2019-06-13T14:41:37Z")

</div>

.

---

<div class="post-metadata">

**Author:** ![yohanmarvel012](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@yohanmarvel012](https://forums.developer.nvidia.com/u/yohanmarvel012)\
**Post date:** [June 13, 2019, 2:43pm UTC](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289/20 "2019-06-13T14:43:18Z")

</div>

.

[Next page](https://forums.developer.nvidia.com/t/how-to-install-opencv-4-0-on-jetson-tx2-with-jetpack-4-2/73289.md?page=2)
