OpenCV imread函数无法读取图像

时间:2014-04-04 16:36:36

标签: c++ opencv

此代码无法读取图像。它正确编译,运行但无法加载图像。

int main(int /*argc*/, char** /*argv*/)
{
  Mat image;
  image = imread("lena.jpg", CV_LOAD_IMAGE_COLOR);   // Read the file

  if (!image.data)                              // Check for invalid input
  {
    cout << "Could not open or find the image" << std::endl;
    return -1;
  }

  namedWindow("Display window", CV_WINDOW_AUTOSIZE);// Create a window for display.
  imshow("Display window", image);                   // Show our image inside it.

  waitKey(0);
  cv::waitKey(50000);
  getchar();
  return 0;
}

1 个答案:

答案 0 :(得分:-1)

这些图像可能会被某些属性锁定。只需使用剪切工具等任何工具制作原始图像的副本,然后尝试使用imread进行阅读。它肯定会起作用。

从互联网下载图像时,通常会出现这类问题。

相关问题