Install OpenCV in CentOS

Solution 1:

I just did the same install on CentOS 6. Since the install instructions are more geared toward Ubuntu, here is what I was able to do to install it:

  1. install all the required packages using yum

    yum groupinstall "Development Tools" 
    yum install gcc 
    yum install cmake 
    yum install git
    yum install gtk2-devel
    yum install pkgconfig 
    yum install numpy 
    yum install ffmpeg
    
  2. Create working directory and check out the source code [note: You probably don't want to use the tag below anymore as it is a significantly old version. I had to use that version due to my software requiring it.]

    mkdir /opt/working
    cd /opt/working
    git clone https://github.com/Itseez/opencv.git
    cd opencv
    git checkout tags/2.4.8.2
    
  3. Create the Makefile

    mkdir release
    cd release
    cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..
    
  4. If using cmake version 2.6-patch 4 (check with cmake --version), then you'll need to comment out a line in the build. Comment out string(MD5 hash "${lines}") on line 50 in /opt/working/opencv/cmake/cl2cpp.cmake. Other options (including updating cmake) can be found at here.

  5. Build and install

    cd /opt/working/opencv/release
    make
    make install
    

Solution 2:

sudo yum search all --enablerepo=epel libtiff4-dev libjpeg-dev libjasper-dev

Gives-

libjpeg-devel.x86_64 : Development tools for programs which will use the libjpeg library
Warning: No matches found for: libtiff4-dev
Warning: No matches found for: libjasper-dev

Which makes me think that you have wrong package names. Are you sure that these aren't debian package names?

Anyways in the meanwhile you can install libjpeg-devel.x86_64 via-

sudo yum install --enablerepo=epel libjpeg-dev

Solution 3:

@Roopendra I met this error too and I tried: cp /usr/local/lib/python2.7/site-packages/cv2.so /usr/lib/python2.7/site-packages and solved it. Source: http://techieroop.com/install-opencv-in-centos/