1.download opencv-x.x.x
download links
2.将解压到的包mv到/usr/local/下
3.cd opencv-x.x.x
4.mkdir build
5.cd build
6.cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local …
7.make
8.make install
9.测试一波
[root@localhost 文档]# vi DisplayImage.cpp
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace cv;
int main(int argc, char** argv ) {
if ( argc != 2 ) {
printf(“please add the image\n”);
return -1;
}
Mat imag;
imag = imread( argv[1], 1 );
if ( !image.data ) {
printf(“No image\n”);
return -1;
}
namedWindow(“Display Image”, WINDOW_AUTOSIZE );
imshow(“Display Image”, imag);
waitKey(0);
return 0;
}
[root@localhost 文档]# vi 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} )
[root@localhost 文档]# cmake .
[root@localhost 文档]# make
[root@localhost 文档]# ./DisplayImage Lena.jpg