当编写好了一个使用到opencv库的程序(程序如下所示,名字为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", WINDOW_AUTOSIZE );
imshow("Display Image", image);
waitKey(0);
return 0;
}
执行“g++ -Wall DisplayImage.cpp -o DisplayImage `pkg-config opencv --cflags --libs`”后生成可执行文件DisplayImage,然后运行./DisplayImage 1.jpg时出现错误。
具体见下图: