This template project consists of a single library, an executable that uses the library and tests for the library with the catch
framework. CMake
is used for the build system.
Additinaly, the OpenCV library can be enabled with a WITH_OPENCV_DEBUG
flag.
> git clone https://github.com/cirquit/opencv-template
> cd opencv-template
> rm .git
> cd ..
> mv opencv-template <your-project-name>
> cd <your-project-name>
> vim CMakeLists.txt
(modify the project names)
- Go to the OpenCV hompage, download the latest stable source (I it tested with 3.3).
- Extract the folder
opencv-3.3
anywhere - You probably will have to install multiple dependencies, which are missing. This depends on, e.g Java and Python bindings, use of
gstreamer
etc. Modify theopencv-3.3/CMakeLists.txt
file accordingly and install the tools. Almost any errors you will encounter are easily searchable, which point to a singleapt-get install
command. - Here is one, which covers the basics requirements
sudo apt-get install build-essential cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
- Alternativly, you can try to execute this prepared script, but it would be wise to run it line by line to fix the errors you encounter
> cd opencv-3.3
> mkdir build && cd build
If you want to finalize your OpenCV program and run it on a e.g Jetson TX1, use the following command (this improves the overall performance):
> cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local ..
Otherwise, to be able to find bugs easier with gdb
, compile with
> cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_INSTALL_PREFIX=/usr/local ..
Afterwards, install the library:
> make
> sudo make install
> cd <your-project-name>
> mkdir build && cd build
> cmake .. -DWITH_OPENCV_DEBUG=ON
> make
> cd <your-project-name>
> mkdir build && cd build
> cmake .. -DWITH_OPENCV_DEBUG=ON
> make
> cd src
> ./opencv-exec