I'm trying to use the imread
function from OpenCV2.2.
My code is very simple.
cv::Mat host= imread("1.bmp", CV_LOAD_IMAGE_GRAYSCALE);
After that, the host matrix became filled by zeros pointers, i.e. an image has not loaded.
If I use cvLoadImage
then it all works properly.
The file exists, and I am not mixing the release and debug libraries. Why imread
doesn't work?
If you are running in Debug, check that you are also using debug libraries, it fixed our problem. : OpenCV imread(filename) fails in debug mode when using release libraries.
imread() Loads an image from a file. The function imread loads an image from the specified file and returns it. If the image cannot be read (because of missing file, improper permissions, unsupported or invalid format), the function returns an empty matrix ( Mat::data==NULL ).
Any transparency present in the image is not read. To read PNG images with transparency (alpha) channel, use cv2. IMREAD_UNCHANGED as second argument in cv2. imread() function as shown in the following.
A = imread( filename ) reads the image from the file specified by filename , inferring the format of the file from its contents. If filename is a multi-image file, then imread reads the first image in the file.
Reproduced with opencv 2.4.8.
If you are running in Debug, check that you are also using debug libraries, it fixed our problem. : OpenCV imread(filename) fails in debug mode when using release libraries.
i was facing the same problem with 2.4.6 . The reason was that while selecting the library , i had selected both the debug version and the release version. When i selected only the debug version for the library everything worked fine
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With