To check current version of opencv on desktop
$ pkg-config --modversion opencv
# example above sentence
3.2.0
Remove current version of opencv on desktop
$ sudo apt purge libopencv* python-opencv
# To remove it more neatly, look for the following as:
$ cd /
$ sudo find -name "*opencv*"
**# It directly searches for the files corresponding to the results of the above sentence and deletes them**
# One example of aformentioned sentence
$ cd /usr/local/lib
$ sudo rm -r libopencv_*
# Then checking there is no package on own desktop
$ pkg-config --modversion opencv
# example above sentence
No package 'opencv' found
Reference Site: https://www.pytorials.com/how-to-install-opencv340-on-ubuntu1604/
Following as:
# To install Opencv Only
$ pip install opencv-python
# Install Dependencies
$ sudo apt-get install build-essential
$ sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
# To Download OpenCV 3.4.0 & OpenCV Contrib 3.4.0
# (Contrib has very useful algorithms which is a must for anyone working on Computer Vision)
$ wget [<https://github.com/opencv/opencv/archive/3.4.0.zip>](<https://github.com/opencv/opencv/archive/3.4.0.zip>) -O opencv-3.4.0.zip
$ wget <https://github.com/opencv/opencv_contrib/archive/3.4.0.zip> -O opencv_contrib-3.4.0.zip
# Extrack OpenCV
$ unzip opencv-3.4.0.zip
$ unzip opencv_contrib-3.4.0.zip
# Make a directory named build inside OpenCV-3.4.0
$ cd opencv-3.4.0
$ mkdir build
$ cd build
# Configuration cmake
# First method **install only opencv**
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \\
-D CMAKE_INSTALL_PREFIX=/usr/local \\
-D OPENCV_GENERATE_PKGCONFIG=YES \\
-D WITH_CUDA=OFF \\
-D WITH_CUDNN=OFF \\
-D OPENCV_DNN_CUDA=OFF \\
-D WITH_FFMPEG=OFF \\
-D WITH_CUFFT=ON \\
-D ENABLE_FAST_MATH=ON \\
-D CUDA_FAST_MATH=ON \\
-D WITH_CUBLAS=ON \\
-D WITH_LIBV4L=ON \\
-D WITH_GSTREAMER=ON \\
-D WITH_GSTREAMER_0_10=OFF \\
-D WITH_QT=OFF \\
-D WITH_OPENGL=ON \\
-D BUILD_opencv_cudacodec=OFF \\
-D CUDA_NVCC_FLAGS="--expt-relaxed-constexpr" \\
-D WITH_TBB=ON \\
-D ENABLE_PRECOMPILED_HEADERS=OFF \\
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-3.4.0/modules \\
../
# If you want to **connect with CUDA** then following this github:
# ***** **<https://github.com/engcang/vins-application#-cv_bridge-with-opencv-3x-version**> *****
$ cmake -D CMAKE_BUILD_TYPE=RELEASE \\
-D CMAKE_C_COMPILER=gcc-6 \\ # IF there has some error then install gcc-6 g++-6 !!
-D CMAKE_CXX_COMPILER=g++-6 \\
-D CMAKE_INSTALL_PREFIX=/usr/local \\
-D OPENCV_GENERATE_PKGCONFIG=YES \\
-D WITH_CUDA=ON \\
-D WITH_CUDNN=ON \\
-D OPENCV_DNN_CUDA=ON \\
-D WITH_CUFFT=ON \\
-D WITH_FFMPEG=ON \\
-D CUDA_ARCH_BIN=8.6 \\ # Please check Compute capability
-D CUDA_ARCH_PTX="" \\
-D ENABLE_FAST_MATH=ON \\
-D CUDA_FAST_MATH=ON \\
-D WITH_CUBLAS=ON \\
-D WITH_LIBV4L=ON \\
-D WITH_GSTREAMER=ON \\
-D WITH_GSTREAMER_0_10=OFF \\
-D WITH_QT=ON \\
-D WITH_OPENGL=ON \\
-D BUILD_opencv_cudacodec=OFF \\
-D CUDA_NVCC_FLAGS="--expt-relaxed-constexpr" \\
-D WITH_TBB=ON \\
../
# Build
$ make -j4
# Install in the location /usr/local using command
$ sudo make install
Now, check changed opencv version
$ pkg-config --modversion opencv
# example above sentence
3.4.0
********* **[Error List] *******
Reference Site: https://stackoverflow.com/questions/63448467/installing-opencv-fails-because-it-cannot-find-skbuild
Reference Site (Kor): https://remoted.tistory.com/418
Following As:
# To upgrade pip
$ python -m pip install --upgrade pip
# To install downgrade opencv-python version
$ python -m pip install opencv-python==4.2.0.32
Reference Site: https://stackoverflow.com/questions/40262928/error-compiling-opencv-fatal-error-stdlib-h-no-such-file-or-directory
Error compiling OpenCV, fatal error: stdlib.h: No such file or directory
Following as:
# Add following line:
-D ENABLE_PRECOMPILED_HEADERS=OFF
# Or modified CMakeList.txt file
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers"
**OFF** IF (NOT IOS AND NOT CMAKE_CROSSCOMPILING) )
Reference Site: https://github.com/BVLC/caffe/issues/4436
Error in installing Caffe with OpenCV 3.1.0 on Ubuntu 16.04 · Issue #4436 · BVLC/caffe
Following as:
# Modified CMakeList.txt in opencv folder
OCV_OPTION(WITH_TIFF "Include TIFF support"
**OFF** IF (NOT IOS) )
[Recommend] Reference Site: https://github.com/colmap/colmap/issues/188
Undefined reference to libtiff4.0 on compile (Ubuntu 16.04) · Issue #188 · colmap/colmap
Following as:
# First Check libtiff existed in /usr/lib/x86_64-linux-gnu
$ sudo ldconfig -p | grep libtiff
# In terminal with anaconda environment
(base) $ conda uninstall libtiff
uuid_generate@UUID_1.0',
uuid_unparse_lower@UUID_1.0'
Reference Site: https://stackoverflow.com/questions/45584275/getting-error-usr-lib-lib64-libsm-so-undefined-reference-to-uuid-unparse-l
Following as:
# First Check libuuif existed in /usr/lib/x86_64-linux-gnu
$ sudo ldconfig -p | grep libuuif
# Go to Anaconda library and remove uuid library
$ cd anaconda3/lib
$ sudo rm -r libuuid.*
Then re-build opencv
Reference Site: https://github.com/kakao/khaiii/issues/23#issuecomment-445687382
Makefile:162: recipe for target 'all' failed · Issue #23 · kakao/khaiii
Following as:
# Not "make -j4" but only "make"
$ make
Reference Site: https://gist.github.com/LorenzoLamberti94/2f35d844121a63558c425618ea12ceef#file-opencv3-2withcontrib-sh-L76
Following as:
$ cd opencv-3.2.0/cmake
$ sed -i '21,22 s/^/#/' ./OpenCVCompilerOptions.cmake
Reference Site: https://github.com/YuvalNirkin/face_swap/issues/51
OpenCV installation error · Issue #51 · YuvalNirkin/face_swap
Following as:
# Install lapacke library
$ sudo apt-get install liblapacke-dev checkinstall
# Go to build folder
$ cd opencv-3.2.0/build
# Change line 2
# [Before] #include "LAPACKE_H_PATH-NOTFOUND/lapacke.h"
# [After] #include "/usr/include/lapacke.h"
$ make