-1
이 코드는 이미지를 읽을 수 없습니다. 그것은 올바르게 컴파일되고 실행되지만 이미지를로드 할 수 없습니다.OpenCV imread 함수가 이미지를 읽을 수 없습니다.
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;
}
프로그램에서 이미지의 전체 경로를 지정하는 것은 어떻습니까? image = imread ("/ path/of/lena.jpg", CV_LOAD_IMAGE_COLOR); – maythe4thbewithu
무엇을 제안 할지도 모른다. 또는 lena.jpg와 동일한 디렉토리에서 응용 프로그램을 실행하고 있는지 확인하십시오. –
@Nadim Farhat 및 maythe4thbewithu 팁을 모두 사용했습니다. 하지만 작동하지 않습니다. 내 OS는 Windows 8 및 컴파일러 vc2013입니다. Windows에서 imread를 사용하는 데 문제가 있습니까? 그러나 이것에 의해 작동했습니다 : IplImage * img = cvLoadImage ("lena.jpg"); 매트 이미지 (img); –