从特定文件开始的int64名称的序列的视频关注

发布于 2025-02-03 06:16:55 字数 789 浏览 2 评论 0原文

我有一系列用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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

凹づ凸ル 2025-02-10 06:16:55

总体解决方法: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 be while. 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 with CAP_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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文