# OpenCV

Open Source Computer Vision Library - Home / Github / r/opencv

Introduction

  • Fixed Pixel Types. Limited Use of Templates
  • uses exceptions to signal critical errors ( cv::Exception is a derivative of std::exception)
  • special error code for algorithm (or example, the optimization algorithm did not converge)
  • current OpenCV implementation is fully re-enterable. That is, the same function or the same methods of different class instances can be called from different threads.

  • learn opencv (Murtaza’s Workshop - Robotics and AI)

Installation

Build from source

Pick the right version

$ VERSION=4.5.4 git clone https://github.com/opencv/opencv.git -b $VERSION --depth 1

Compiling OpenCV from Source

sudo apt install libgtk-3-dev	# make sure you have prerequesite installed before launching cmake

Configure the project

cd opencv
mkdir build
cd build

cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_GENERATE_PKGCONFIG=ON \
-D WITH_QT=OFF \
-D WITH_GTK=ON \
-D WITH_OPENCL=ON \
-D WITH_OPENGL=ON \
-D BUILD_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D BUILD_opencv_python2=OFF \
-D PYTHON3_EXECUTABLE=$(which python3) \
-D PYTHON3_INCLUDE_DIR=$(python3 -c "from distutils.sysconfig import get_python_inc; print(get_python_inc())") \
-D PYTHON3_PACKAGES_PATH=$(python3 -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())") \
 ..

This will donwload dependencies as well as build a Makefile. Then build & install

Check that everything you want is enabled before launching a long compilation

make -j6 # adapt to your taste

sudo make install
sudo ldconfig

Test Installation

cd ~/src/opencv/samples
cmake .
make -j6

./cpp/cpp-example-edge	# If the sample runs, then the C++ libraries are properly installed.

pkg-config --cflags opencv4		# to reference opencv in meson/ninja/cmake

Docker Build from source

learn opencv

Running sample (expose X11 first):

xhost +local:docker

docker run --device=/dev/video0:/dev/video0 -v /tmp/.X11-unix:/tmp/.X11-unix -e DISPLAY=$DISPLAY -p 5000:5000 -p 8888:8888 -it spmallick/opencv-docker:opencv /bin/bash
cd ~/demo/python
workon OpenCV-3.4.3-py3

python facialLandmarkDetector.py

deactivate

elehcimd/jupyter-opencv

git clone --branch 4.1.0 --single-branch https://github.com/opencv/opencv.git
git clone --branch 4.1.0 --single-branch https://github.com/opencv/opencv_contrib.git
Written on April 27, 2019, Last update on June 8, 2024
opencv computer-vision