【问题标题】:OpenCV VideoCapture read the picture sequences cost too much time, about 40ms per frameOpenCV VideoCapture读取图片序列耗时太长,每帧40ms左右
【发布时间】:2018-06-03 14:23:10
【问题描述】:

我使用opencv3.3开发一些算法。一个功能是读取视频或图片序列。

读取视频文件时,VidoeCapture 类运行良好。每帧读取只需几毫秒(小于 3 毫秒 @frame 1280*720)。

但是,从目录中读取图片序列时,读取过程太慢,大约每帧 40 ~ 42 ms。我确信代码正确且成功(它可以正确显示图片)。似乎 OpenCV 已将 fps 锁定在 25(40 毫秒/帧),但我不知道如何更改。

string filePath = "<my picture sequences dir>\\001_01_%06d.png"; // the file path, the name of pictures is consecutive
VideoCapture sq(filePath);
Mat _sq_tmpImage;
while(1){
    sq >> _sq_tmpImage; // I had insert the breakpoint to check the cost time, it is about 40-42 ms pre frame. I also use the function "sq.read(_sq_tmpImage)" instead, but seems the same.
}

【问题讨论】:

    标签: image opencv video-capture sequences


    【解决方案1】:

    不,代码在读取/加载图像之间没有任何延迟,可以找到code here

    如果您尚未将图像存储在 SSD 上,请尝试这样做。或者使用具有更快解码器的格式,也许 jpeg 比 png 更快。

    【讨论】:

    • 我遇到了问题。它是图像格式。 .png 格式的图像需要更多时间来解码。转换为 .jpg 格式后,图像在 7 毫秒内被读取/加载。非常感谢!
    猜你喜欢
    • 2014-05-07
    • 1970-01-01
    • 2016-11-06
    • 2019-11-22
    • 1970-01-01
    • 1970-01-01
    • 2016-02-12
    • 2017-04-14
    相关资源
    最近更新 更多