Skip to content
PimenovAlexander edited this page Feb 15, 2020 · 24 revisions

Building OpenCV for compatibly with CoreCVS

  • Please don't use OpenCV if you don't need it.
  • Please use OpenCV if you feel you need it.

OpenCV 3.4.6+ is supported. OpenCV 2.X support is discontinued. Build is checked for:

  • OpenCV 3.4.6
  • OpenCV 3.4.9

Info about nonfree support could be found here - https://elbauldelprogramador.com/en/how-to-compile-opencv3-nonfree-part-from-source/#2-download-and-unpack-nonfree-part

Instructions

Before we begin choose preferred install path. I recommend /opt/opencv-3.4.6. You would need ~4.6G of space during build and ~130Mb for binaries.

Without Contrib (rarely needed)

mkdir -p ~/3rd_party/opencv
cd ~/3rd_party/opencv
wget https://codeload.github.com/opencv/opencv/zip/3.4.6 -O opencv-3.4.6.zip
unzip opencv-3.4.6.zip 
cd opencv-3.4.6/
mkdir build
cd build
# You probably want to switch off some modules to save space
# OpenCV PNG could probably interfere with Qt PNG support. Depends on the versions
cmake -DWITH_PNG=false -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/opt/opencv-3.4.6 ..

# Use all your cores
make -j 12 

# You can use checkinstall. Or we can just install it
sudo make install

With Contrib (prefered by OpenCV-dependent fan-students)

Some usages require opencv_contrib. Here is an action that checks it: Build status for opencv_build_instructions branch

mkdir -p ~/3rd_party/opencv
cd ~/3rd_party/opencv
wget https://codeload.github.com/opencv/opencv/zip/3.4.6 -O opencv-3.4.6.zip
unzip opencv-3.4.6.zip 
wget https://github.com/opencv/opencv_contrib/archive/3.4.6.zip -O opencv_contrib-3.4.6.zip
unzip opencv_contrib-3.4.6.zip 
cd opencv-3.4.6/
mkdir build
cd build
# You probably want to switch off some modules to save space
# OpenCV PNG could probably interfere with Qt PNG support. Depends on the versions
cmake -DWITH_PNG=false -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/opt/opencv-3.4.6   -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.6/modules ..

sudo make install

Done. Your data is set. You need to refer it during both build and run stages.

Building CoreCVS with Opencv

Return to CVS build repository (setup instructions - https://github.com/PimenovAlexander/corecvs/wiki/Build) Before build make sure with_opencv in switched on in CMake or cvs-config.pri

QMake Build

export OPENCV_PATH=/opt/opencv-3.4.6
qmake -r
make -j 12

You should see the following during qmake phase

Project MESSAGE: Compiling with OpenCV from /opt/opencv-3.4.6
Project MESSAGE: Using OpenCV 3.x

CMake build

export OpenCV_DIR=/opt/opencv-3.4.6
cmake ..
make -j 12

You should see the following during cmake phase

-- Including OpenCV on CORECVS build
-- Found OpenCV: /opt/opencv-3.4.6 (found version "3.4.6") 

Well you are done now. Don't forget to do

export LD_LIBRARY_PATH=/opt/opencv-3.4/lib/:$LD_LIBRARY_PATH

before calling OpenCV dependent applications.

Alternatively you could either put it in you ~/.bashrc or make your install system-wide by modifying /etc/ld.so.conf.d/*

Clone this wiki locally