OpenCV4 comes out in October, but you can compile and install the prerelease now. OpenCV4 will have further optimizations, C+11 support, and improvements to the DNN module. In order to compile and install you will need around 14GB of free space. Therefore having a NVMe M.2 SSD installed is imperative. Yesterday I purchased a Samsung 970 EVO 250GB for $87.99
I highly recommend using python virtual environments. Then you don’t have to worry about messing up your local python install and dependencies. I like virtualenv. Create one based on the latest Python3.
Install OpenCV4 dependencies:
sudo apt-get install build-essential cmake unzip pkg-config
sudo apt-get install libjpeg-dev libpng-dev libtiff-dev
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev
sudo apt-get install libxvidcore-dev libx264-dev
sudo apt-get install libgtk-3-dev
sudo apt-get install libatlas-base-dev gfortran
sudo apt-get install python3-dev
Configure your python virtual environment and make it active. I am using Python v3.6.5.
pip install numpy
Within the opencv folder create a build folder. Work out of that folder when issuing the cmake command
Issue the cmake command.
cmake -D CMAKE_BUILD_TYPE=RELEASE
-D OPENCV_EXTRA_MODULES_PATH= ‘path to your opencv_contrib/modules folder’
-D PYTHON_EXECUTABLE=~/.virtualenvs/xxxx/bin/python \ xxxx = virtual environment folder name
-D BUILD_EXAMPLES=ON …
You should see "Build files have been written to: ‘location of your build folder’
The important thing to verify:
Python 3 Interpreter: points to you virtual environment python instal
Example: /home/nvidia/.virtualenvs/xxxx/bin/python3 (ver 3.6.5)
Python 3 numpy: points to your virtual environment numpy install
Example: /home/nvidia/.virtualenvs/xxxx/lib/python3.6/site-packages/numpy/core/include (ver 1.14.5)
xxxx = name of your virtual environment
(4) is the number of CPU cores you want to devote to this task. I suppose you could use 8, but then maybe your Jetson will
The compile will take awhile (1 to 2 hours). Walk away from your Jetson and hope.
Hopefully you come back and see:
[100%] Built target opencv_python3
From the same Build directory issue the follow two commands
sudo make install
Create a symbolic link from the OpenCV install directory to your virtual environment
cd ~/.virtualenvs/xxxx/lib/python3.6/site-packages/ xxxx = virtual environment folder name
ln -s /usr/local/lib/python3.6/site-packages/cv2.cpython-36m-aarch64-linux-gnu.so cv2.so
Your output should be: ‘4.0.0-pre’
Congratulations, all is well in your Jetson world.