Skip to content

Scripts for build OpenCV on the NVIDIA Jetson Nano Developer Kit

License

Notifications You must be signed in to change notification settings

JetsonHacksNano/buildOpenCV

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

buildOpenCV

Script for building OpenCV 4 on the NVIDIA Jetson Nano Developer Kit

Building for:

  • Jetson Nano
  • L4T 32.2.1/JetPack 4.2.2
  • OpenCV 4.1.1
  • Packaging Option ( Builds package by default; --no_package does not build package)

Note: The script does not check to see which version of L4T is running before building, understand the script may only work with the stated versions.

Building

This is a long build, you may want to write to a log file, for example:

$ ./buildOpenCV.sh |& tee openCV_build.log

While the build will still be written to the console, the build log will be written to openCV_build.log for later review.

On the Jetson Nano, this is a challenging build. There is not enough memory on the Nano to make with multiple jobs (i.e)

$ make -j4

without using a significant amount of swap file space. With L4T 32.2.1, there is a default swap space. However, if you are using a SD card, this can result in long compile times as both physcial memory and the swap file memory exhaust. Recommend using a USB drive for building. If you use a SD card, consider setting the environment variable NUM_JOBS in the buildOpenCV.sh script to 1. The build time may be longer, but you will not have the same amount of memory/SD card thrashing. If you are using a USB drive, you may want to add a swapfile: https://github.com/JetsonHacksNano/installSwapfile.

Note that if you are building for Python, you most definitely will benefit from building with a swap file and running on a USB drive. See: https://github.com/JetsonHacksNano/installSwapfile

Usage

usage: ./buildOpenCV.sh [[-s sourcedir ] | [-h]]
     -s | --sourcedir Directory in which to place the opencv sources (default $HOME ; this is usually ~/)
     -i | --installdir Directory in which to install opencv libraries (default /usr/local)
     --no_package Do not package OpenCV as .deb file (default is true)
     -h | --help Print help

Build Parameters

OpenCV is a very rich environment, with many different options available. Check the script to make sure that the options you need are included/excluded. By default, the buildOpenCV.sh script selects these major options:

  • CUDA on
  • GStreamer
  • V4L - (Video for Linux)
  • QT - (No gtk support built in)
  • Python 2 bindings
  • Python 3 bindings

Packaging

By default, the build will create a OpenCV package. The package file will be found in:

opencv/build/_CPACK_Packages/Linux/STGZ/OpenCV-4.1.1-<commit>-aarch64.sh

The advantage of packaging is that you can use the resulting package file to install this OpenCV build on other machines without having to rebuild. Whether the OpenCV package is built or not is controlled by the CMake directive CPACK_BINARY_DEB in the script.

Notes

November 2019, Initial Release

  • Jetson Nano
  • L4T 32.2.1/JetPack 4.2.2
  • OpenCV 4.1.1
  • Packaging Option ( Builds package by default; --no_package does not build package)