I have loop in my C++ code to open and process a set of images. One of those is http://i.stack.imgur.com/rUJnp.gif
imread
has trouble opening this specific one.imread().data
is NULL
.
FWIW, I'm on CentOS
and using the latest opencv 2.4.8. Is there anyway to fix this? If not what is the easiest way to maybe open it with another C++ image library and convert it to cv::Mat
?
From OpenCV documentation regarding imread
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
). Currently, the following file formats are supported:
Windows bitmaps - *.bmp, *.dib (always supported)
JPEG files - *.jpeg, *.jpg, *.jpe (see the Notes section)
JPEG 2000 files - *.jp2 (see the Notes section)
Portable Network Graphics - *.png (see the Notes section)
Portable image format - *.pbm, *.pgm, *.ppm (always supported)
Sun rasters - *.sr, *.ras (always supported)
TIFF files - *.tiff, *.tif (see the Notes section)
So .gif
format is not supported by OpenCV hence imread
is returning NULL
.
As I known, OpenCV does not support the gif format that, to read directly in your program, some external libraries are required. Such as http://freeimage.sourceforge.net/.
Good Luck
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