Install opencv in centos 6

Source: Internet
Author: User

I installed it yesterday. I can't remember some details today. I 'd like to give it a rough description.

First, download the Linux opencv-2.4.9 installation package from the opencv Official Website: http://jaist.dl.sourceforge.net/project/opencvlibrary/opencv-unix/2.4.9/opencv-2.4.9.zip

Then, because the download of eleven zip compressed package, so to install a RAR decompression software,: http://www.rarsoft.com/rar/rarlinux-x64-5.1.1.tar.gz

RAR installation command:

# Tar-xzvf rarlinux-x64-5.1.1.tar.gz # cd RAR // The Name Of The extracted folder is rar, available ls view # Make # make install

Then, directly

# RAR x opencv-2.4.9.zip
# Cd opencv-2.4.9
# Cmake cmakelists.txt // note that cmake must use a new version. Otherwise, it cannot be compiled.
# Make
# Make install

Note: here, the cmake version of my system is 2.3. If the compilation fails, an error is reported:

Cc1plus: warning the command line option "-wmissing-prototypes" is valid for Ada, C, and objc, but not for C ++.
Cc1plus: warning the command line option "-wstrict-prototypes" is valid for Ada, C, and objc, but not for C ++.

After some look finally found that the cmake version is too low, and then download the installation of cmake3.0.2: http://www.cmake.org/files/v3.0/cmake-3.0.2.tar.gz

To install cmake3.0.2, you must use cmake2.6 or a later version to compile it. I still cannot install the current version. When I was depressed, I found a lifeline:

The cmake folder contains a bootstrap file.

#./bootstrap
#make
#make install

To complete the installation.

Test procedure:

Source program displayimage. cpp

#include <stdio.h>#include <opencv2/opencv.hpp>using namespace cv;int main(int argc, char** argv ){    if ( argc != 2 )    {        printf("usage: DisplayImage.out <Image_Path>\n");        return -1;    }    Mat image;    image = imread( argv[1], 1 );    if ( !image.data )    {        printf("No image data \n");        return -1;    }    namedWindow("Display Image", CV_WINDOW_AUTOSIZE );    imshow("Display Image", image);    waitKey(0);    return 0;}

Cmake file cmakelists.txt

cmake_minimum_required(VERSION 2.8)project( DisplayImage )find_package( OpenCV REQUIRED )add_executable( DisplayImage DisplayImage.cpp )target_link_libraries( DisplayImage ${OpenCV_LIBS} )

Then compile the file:

#cd <DisplayImage_directory>#cmake .#make

Execution result:

#./DisplayImage lena.jpg

Install opencv in centos 6

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.