列出OpenCV支持的文件扩展名 [英] list file extensions supported by 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;
}
推荐答案
对于 对于 For AVI文件-* .avi AVI files - *.avi 似乎AVI是唯一具有不错的跨平台支持的格式.有关更多信息,请参见此处.
这篇关于列出OpenCV支持的文件扩展名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!imread()
(更多信息
VideoCapture()
: VideoCapture()
: