Linux 下面打开一张图片并且进行显示,以及CMakeLists.txt 的使用 。
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include <stdio.h>
using namespace cv;
int main( int argc, char** argv ){
Mat image;
image = imread( argv[1]);
if( argc != 2 || !image.data ){
printf("没有图片\n");
return -1;
}
namedWindow( "显示图片", CV_WINDOW_AUTOSIZE );
imshow( "显示图片", image );
waitKey(0);
return 0;
}
CMakeList.txt 的编写
cmake_minimum_required(VERSION 2.8)
project( test )
find_package( OpenCV REQUIRED )
include_directories( ${OpenCV_INCLUDE_DIRS} )
add_executable( test test.cpp )
target_link_libraries( test ${OpenCV_LIBS} )
测试
./test panda.jpg
写到这里为以后将 灰度图转换为伪彩色来进行显示先做一个铺垫