# inspired by http://superuser.com/questions/678568/install-opencv-in-centos
sudo yum groupinstall "Development Tools"
sudo yum install gcc cmake git gtk2-devel pkgconfig numpy ffmpeg
sudo mkdir /opt/working
cd /opt/working
sudo git clone https://github.com/Itseez/opencv.git
cd opencv
sudo mkdir release
cd release
sudo cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
sudo make
sudo make install
- Add OpenCV package config:
$ touch /usr/local/lib/pkgconfig/opencv.pc
- Add the following lines to
.bashrc
andsource
it:
PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig
export PKG_CONFIG_PATH
- Add the following flags to the package config:
$ pkg-config --cflags opencv
$ pkg-config --libs opencv
Next, add OpenCV library location to make linking work.
- Create a
opencv.conf
file at/etc/ld.so.conf.d/
. - Add the location of your OpenCV library to the
opencv.conf
file (probably/usr/local/lib
) - Run
sudo ldconfig -v
You should now be able to run any OpenCV executable.
To compile any .cpp
OpenCV program, use the Makefile
like:
$ make <program_name_without_extension>