Ask Your Question

Revision history [back]

How to build OpenCV 4.1.0 on Ubuntu 18.10

Any chance someone has a tutorial newer than the nine year old instructions on Ubuntu 10.0 here: https://docs.opencv.org/4.1.0/d7/d9f/tutorial_linux_install.html

I've been attempting to build from source, and while I'm close, there are still some problems I don't know how to solve. For example, once built and installed, I end up with the include files installed in the directory /usr/include/opencv4/opencv2/... which obviously is not correct.

This is how I've been attempting to build on Ubuntu 18.10:

unzip opencv-4.1.0.zip
unzip opencv_contrib-4.1.0.zip
cd opencv-4.1.0
mkdir build
cd build
cmake \
  -DCPACK_BINARY_DEB=ON \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=/usr/local \
  -DOPENCV_GENERATE_PKGCONFIG=ON \
  -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.0/modules \
  -DEXTRA_MODULES_VCSVERSION=4.1.0 \
  -DOPENCV_VCSVERSION=4.1.0 \
  -DWITH_TBB=ON \
  -DWITH_IPP=ON \
  -DWITH_CUDA=OFF \
  -DWITH_OPENCL=ON \
  -DWITH_LIBV4L=ON \
  -DWITH_OPENMP=ON \
  -DWITH_NVCUVID=OFF \
  -DWITH_CSTRIPES=ON \
  -DWITH_GSTREAMER=ON \
  -DBUILD_opencv_python2=ON \
  -DBUILD_opencv_python3=ON \
  -DBUILD_PERF_TESTS=OFF \
  -DBUILD_EXAMPLES=OFF \
  -DBUILD_TESTS=OFF \
  -DBUILD_DOCS=ON \
  ..
make -j16
sudo make install
cpack -G DEB
sudo make uninstall
sudo dpkg -i OpenCV-4.1.0-x86_64-*.deb