列出OpenCV支持的文件扩展名 [英] list file extensions supported by OpenCV

查看:305
本文介绍了列出OpenCV支持的文件扩展名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在OpenCV中,我看到imread()和VideoCapture()都将字符串带到具有多个扩展名的文件路径中.有没有办法获得它们支持的扩展列表?例如,获取"jpg","png","mov","mpg"等的列表?我认为这是系统相关的,其他人则需要在运行时进行查询.

In OpenCV, I see imread() and VideoCapture() both take a string to a file path of multiple extensions. Is there a way to get a list of extensions that are supported by them? For example, getting a list of "jpg", "png", "mov", "mpg", etc.? I assume this is system dependent and others have needed to query this at runtime.

此外,如何确定支持?如果有类似以下代码的内容,并且返回的Mat总是看起来部分损坏(我可以看到一些图像).无论我要求的帧号如何,它似乎都没有改变.我可以在视频播放器图腾"中播放此视频,但是我什至不确定图腾和OpenCV是否为此文件使用相同的编解码器.

Furthermore, how is support determined? If have something like the below code and the Mat I get back always seems partially corrupted (I can see a bit of the image). It doesn't seem to change regardless of the frame number I ask for. I can play this video in my video player "totem", but I'm not even sure if totem and OpenCV are even using the same codec for this file.

Mat fromVideo(std::string _videoPath, int frame) {
    VideoCapture capture(_videoPath);

    Mat f;
    for (int i = 0; i < frame; i++) {
        capture >> f;
    }
    return f;
}

推荐答案

对于imread() (更多信息

  • Windows位图-* .bmp,*.dib(始终受支持)
  • JPEG文件-* .jpeg,*.jpg,*.jpe(请参阅注释"部分)
  • JPEG 2000文件-* .jp2(请参阅注释"部分)
  • 便携式网络图形-* .png(请参阅注释"部分)
  • 便携式图像格式-* .pbm,*.pgm,*.ppm(始终受支持)
  • Sun栅格-* .sr,*.ras(始终受支持)
  • TIFF文件-* .tiff,*.tif(请参阅注释"部分)
  • 对于VideoCapture():

    For VideoCapture():

    • AVI文件-* .avi

    • AVI files - *.avi

    似乎AVI是唯一具有不错的跨平台支持的格式.有关更多信息,请参见此处.

    这篇关于列出OpenCV支持的文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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