OpenCV imread不工作 [英] OpenCV imread doesn't work

查看:733
本文介绍了OpenCV imread不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的C ++代码中循环打开和处理一组图像。其中之一是
http://i.stack.imgur.com/rUJnp.gif



imread 无法打开这个特定的。 imread()。data NULL



FWIW,我在 CentOS 并使用最新的opencv 2.4.8。有没有反正解决这个?如果不是什么是最简单的方法,可能打开它与另一个C ++图像库,并将其转换为 cv :: Mat

解决方案

OpenCV 关于 imread的文档



函数 imread 图像从指定的文件并返回。如果图像无法读取(因为缺少文件,不正确的权限,不受支持或格式无效),函数将返回一个空矩阵( Mat :: data == NULL )。目前支持以下文件格式:

  Windows位图 -  * .bmp,* .dib(始终支持)
JPEG文件 - * .jpeg,* .jpg,* .jpe(参见注释部分)
JPEG 2000文件 - * .jp2(参见注释部分)
便携式网络图形 - * .png
便携式图像格式 - * .pbm,* .pgm,* .ppm(总是支持)
太阳栅格 - * .sr,* .ras(总是支持)
TIFF文件 - * .tiff,* .tif(参见注释部分)

c> .gif 格式不被OpenCV支持,因此 imread 正在返回 NULL 。 / p>

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.

这篇关于OpenCV imread不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆