I'm trying to load a .pbm image with opencv.
I'm using the imread function; the documentation says that it should open pbm files but I can't make it work.
It does work with other format like png/jpeg/...
#define CV_LOAD_IMAGE_ANYDEPTH 2
#define CV_LOAD_IMAGE_ANYCOLOR 4
[...]
//argv[1] is the file's name
cv::Mat img = cv::imread(argv[1], CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR);
if (img.rows*img.cols==0){
printf("\nImage not loaded");
return 0;
}
..of course, with pbm files, it returns 0.
If you are using OpenCV 3, you can use:
If you want to rule out the possibility that your starting images are corrupt/incorrect, you can create test images easily at the command line with ImageMagick, which is installed on most Linux distros, and is available for OSX and Windows.