簡體   English   中英

OpenCV imread 函數無法讀取圖像

[英]OpenCV imread function can not read image

此代碼無法讀取圖像。 它編譯正確,運行但無法加載圖像。

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;
}

這些圖像有可能被某些屬性鎖定。 只需使用任何工具(如剪切工具)復制原始圖像並嘗試使用 imread 閱讀。 它肯定會起作用。

當您從互聯網下載圖像時,通常會出現此類問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM