opencv - OPEN CV程序执行错误?

我在Eclipse中运行下面的代码,成功包含了路径和库,但是运行代码时显示错误。

 #include <cv.h>
 #include<stdio.h>
 #include <highgui.h>
  //using namespace cv;
 int main()
{     
 Mat image;
 image = imread( argv[1], 1 );

 if( argc != 2 || !image.data )
  {
    printf( "No image data \n" );
    return -1;
  }

 namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
 imshow( "Display Image", image );

 waitKey(0);
   printf("this is open cv programming");

  return 0;
}

最佳答案

您的main()签名不完整

尝试

int main(int argc, char* argv[])

这些参数表示:
argc  // an int indicating the number of arguments passed in to the function

argv[]  // an array of character strings, the actual arguments.

第一个参数argv [0]是程序名称...因此argc始终至少为1。

第二个参数argv [1]将是用户传入的第一个参数,使argc达到2。这就是程序所期望的,用户的单个参数argc == 2。

https://stackoverflow.com/questions/14273139/

相关文章:

image-processing - 通过 find_contour 获取每个标志的 1 个轮廓并在

opencv - 在OpenCV中编译

matlab - 不裁剪的图像重映射

opencv - Eclipse安装opencv 2.4.3库时出错

python - opencv-python:不是一个numpy数组

opencv - 使用Filestrage在OpenCV中保存和读取Mat向量的向量

opencv - OpenCV Codebook方法-背景模型

c# - 使用 SURF 匹配 OpenCV\EmguCV 中的图像

image-processing - 使用 openCV 检测图案区域

c++ - 负 RGB 值