Installation - zlacey1234/LearningOpenCV GitHub Wiki
Installing OpenCV on Linux (Computer)
Note: This tutorial assumes using Ubuntu 16.04 with OpenCV
Required Packages
- GCC 4.4.x or later
- CMake 2.8.7 or higher
- Git
- GTK+2.x or higher, including headers (libgtk2.0-dev)
- pkg-config
- Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy)
- ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev
- [optional] libtbb2 libtbb-dev
- [optional] libdc1394 2.x
- [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev, libdc1394-22-dev
- [optional] CUDA Toolkit 6.5 or higher
[compiler] sudo apt-get install build-essential
[required] sudo apt-get install cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev
[optional] sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev
Getting OpenCV Source Code
- Make a OpenCV Build Directory
cd ~
mkdir opencv_build
cd opencv_build
- Clone the OpenCV Repository from Github
git clone https://github.com/opencv/opencv.git
git clone https://github.com/opencv/opencv_contrib.git
- create a temporary build directory within OpenCV Repository, where the generated Makefiles will be placed.
cd ~/opencv_build/opencv
mkdir build
cd build
- Configuring. Run cmake
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local .. -DOPENCV_GENERATE_PKGCONFIG=ON
- Build. From build directory execute make, it is recommended to do this in several threads
make -j7
- To install libraries, execute the following command
sudo make install
Setup the shared location of the OpenCV Library
- Check to see if OpenCV was properly built. Navigate to the path:
/usr/local/include
. There should be anopencv4
folder which contains theopencv2
folder - Navigate to the path:
/usr/local/lib
. This should contain the shared libraries (files beginning inlib
and usually ending in.so
). An example of this should belibopencv_core.so
. If these files were properly placed here, then proceed to Step 3. Otherwise, find the location of these files. - Create a file called
/etc/ld.so.conf.d/opencv.conf
. To do this, navigate to the path:/etc/ld.so.conf.d
\
sudo gedit opencv.conf
- In the
opencv.conf
file write:
/usr/local/lib/
- Run
sudo ldconfig -v
Installing OpenCV on Linux (Raspberry Pi 4B)
TODO