简体   繁体   English

如何在 python 中使用 opencv 打开优胜美地序列

[英]how to open the yosemite sequence with opencv in python

I have been playing around with optical flow algorithms in python, and would like to apply them on the famous Yosemite sequence (a sequence of 15 frames).我一直在玩 python 中的光流算法,并想将它们应用于著名的优胜美地序列(15 帧序列)。 Some instructions are provided, but solely in C.提供了一些说明,但仅在 C 中提供。 I would like to be able to open these frames as images in opencv so I can export them to a video file and apply optical flow algorithms.我希望能够在 opencv 中将这些帧作为图像打开,这样我就可以将它们导出到视频文件并应用光流算法。 Any ideas?有任何想法吗?

Instructions in C here . C 中的说明在这里 Image sequences here by clicking on the Yosemite image.通过单击 Yosemite 图像在此处进行图像序列。

if you have problems understanding the C code they provided, just say so.如果您在理解他们提供的 C 代码时遇到问题,请直说。

as you can probably tell, the pictures have a resolution of 316 x 252.正如您可能知道的那样,这些图片的分辨率为 316 x 252。

further, they're grayscale.此外,它们是灰度的。

the files just so happen to be 316 * 252 = 79632 bytes in size.这些文件恰好是 316 * 252 = 79632 字节大小。

I would suggest reading the files and interpreting them as np.uint8 element type of the given shape.我建议阅读这些文件并将它们解释为给定形状的np.uint8元素类型。

numpy has frombuffer . numpy 有frombuffer read read everything from a file, use frombuffer to convert it into a numpy array. read 从文件中读取所有内容,使用frombuffer将其转换为 numpy 数组。

from that, you can apply the scale and pedestal (meaning an a*x+b calculation), or just look at the values as they are.从中,您可以应用比例和基座(意思是a*x+b计算),或者直接查看值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM