从特定文件开始的int64名称的序列的视频关注
我有一系列用INT64时间戳命名的图像。我也有一个特定的时间戳,我想启动视频仪。
问题1
cv2.VideoCapture('./%19d.png', cv2.CAP_IMAGES)
不起作用。
我已经完成了以下测试(对序列名称进行了相应的调整),
cv2.VideoCapture('./%019d.png', cv2.CAP_IMAGES) # doesn't work
cv2.VideoCapture('./%10d.png', cv2.CAP_IMAGES) # doesn't work
cv2.VideoCapture('./%010d.png', cv2.CAP_IMAGES) # doesn't work
cv2.VideoCapture('./%09d.png', cv2.CAP_IMAGES) # works
cv2.VideoCapture('./%9d.png', cv2.CAP_IMAGES) # works
问题似乎CV2格式指定符不需要2位数字长度。我尚未尝试过一些语法还是这是OpenCV的限制?
问题2
我还想从特定的框架开始视频仪。我可以从我想开始的特定时间戳或n:th框架。但是,我没有自由对文件系统进行任何更改。
即使是给出cv2.VIDEOCAPTURE
一系列文件名,我可以在Python中进行准备,但是如果可能的话,我找不到任何指示。
I have a sequence of images that are named with int64 timestamps. I also have a specific timestamp where I would like to start the VideoCapture.
Problem 1
cv2.VideoCapture('./%19d.png', cv2.CAP_IMAGES)
doesn't work.
I've done the following tests (with sequence names adjusted accordingly)
cv2.VideoCapture('./%019d.png', cv2.CAP_IMAGES) # doesn't work
cv2.VideoCapture('./%10d.png', cv2.CAP_IMAGES) # doesn't work
cv2.VideoCapture('./%010d.png', cv2.CAP_IMAGES) # doesn't work
cv2.VideoCapture('./%09d.png', cv2.CAP_IMAGES) # works
cv2.VideoCapture('./%9d.png', cv2.CAP_IMAGES) # works
The problem seems that the cv2 format specifier doesn't take 2 digit lengths. Is there some syntax I haven't tried yet or is this a limitation of opencv?
Problem 2
I would also like to start the VideoCapture at a specific frame. I can get the specific timestamp, or the N:th frame that I would like to start from. However I'm not at liberty to make any changes to the filesystem.
Even something like giving cv2.VideoCapture
a sequence of filenames, which I can prepare in python would work, but I cant find any indications if that is possible.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
总体解决方法:Just
Imread
单独的图片列表。videocapture
所做的不止于此。问题1:需要对 https://github.com/opencv/opencv/blob/4.x/modules/videoio/videoio/src/cap/cpp_images.cpp#l221 <代码> 。这使得验证比需要的宽容更为宽容(接受任意数字格式的宽度,而不仅仅是1位数字),但是ehhhhh会很好。
问题2:您可以使用
cap.set(cv.cap_prop_pos_frames)
,尽管我从来没有使用cap_images
进行此操作。如果那不起作用,它应该这样做,值得在OpenCV的GitHub上打开一个问题。NB:在同一问题中要小心多个问题。这个网站更喜欢每个问题。
Overall workaround: just
imread
your list of pictures individually.VideoCapture
does little more than that.Problem 1: requires a tiny change to the input validation in https://github.com/opencv/opencv/blob/4.x/modules/videoio/src/cap_images.cpp#L221, namely replacing
if
to bewhile
. This is makes the validation more forgiving than it needs to be (accepts arbitrary-digit format widths, instead of just 1-digit) but ehhhh it'll be fine.Problem 2: you might be able to use
cap.set(cv.CAP_PROP_POS_FRAMES)
though I've never done that withCAP_IMAGES
. If that doesn't work, it is supposed to, and would be worth opening an issue on OpenCV's github.NB: be careful with multiple problems in the same question. This site prefers one problem per question.