OpenCV 2.0 C++ API using imshow: returns unhandled exception and “bad-flag”

后端 未结 6 1036
生来不讨喜
生来不讨喜 2020-12-07 02:08

I\'m trying to use the new OpenCV 2.0 API in MS Visual C++ 2008 and wrote this simple program:

cv::Mat img1 = cv::imread(\"image.jpg\",1);
cv::namedWindow(\"         


        
6条回答
  •  长情又很酷
    2020-12-07 03:09

    Are you sure you added the whole path starting from /home/.... I had the same problem as you but when I added the whole path, things work out pretty well. The whole path had to be added despite the fact the path exists in the include files.

    imread in openCV unlike Matlab does not return an error when file/folder is not found - instead it returns a null matrix, which in turn is reflected as an error during imshow. Also, imread does not look for image files in the included folders or the workspace. So, specify the entire path whenever possible.

    Please take a note of this for future references.

提交回复
热议问题