从视频/图像中提取元数据

问题描述:

我从 IP 摄像机获取 MJPEG 流,我正在查看并保存在我的计算机上.可以在here一>.答案解释了如何从流中提取图像并保存.

I am getting an MJPEG stream from an IP Camera which I am viewing and saving on my computer. The code of how I am doing it can be found here. The answer explains how to extract the images from the stream and save them.

为了提取图像,我使用答案中列出的方法并保存它,我只是使用 OpenCV 将图像放入 avi 容器中.代码如下.

For extracting the images I am using the method listed in the answer and for saving it I am simply putting the images in an avi container using OpenCV. The code is given below.

writer=cv.CreateVideoWriter("video1.avi", cv.CV_FOURCC('X', '2', '6', '4'), fps, (320,240))
cv_image = cv2.imdecode(np.fromstring(jpg, dtype=np.uint8),cv2.CV_LOAD_IMAGE_COLOR)bitmap=cv.CreateImageHeader((cv_image.shape[1], cv_image.shape[0]), cv.IPL_DEPTH_8U, 3)
cv.SetData(bitmap, cv_image.tostring(), cv_image.dtype.itemsize * 3 * cv_image.shape[1])
cv.WriteFrame(writer, bitmap)

这里的位图是我正在显示并放入 avi 容器中的图像.

Here bitmap is the image that I am displaying and putting in the avi container.

由于图像来自 IP 摄像机,因此它必须具有一些元数据,例如摄像机插入的时间戳.

Since the image is from an IP Camera it must have some metyadata like a time stamp which the camera inserts.

问题:如何提取元数据?

我想到了两种方法来做到这一点:

I have thought of 2 ways to do this:

  1. 从视频中提取帧,然后访问它们以访问时间戳.
  2. 从视频本身提取时间戳.

我该如何继续?我使用哪种方法?我正在使用 Python 和 Opencv,并且正在使用 Windows 7.

How do I proceed? Which method do I use? I am using Python and Opencv and am working on Windows 7.

我还阅读了this 喜欢与我正在尝试做的事情有关.它没有解决我的问题.

I also read this like related to what I am trying to do. It did not solve my problem.

如果有任何附加到(单个图像)文件的元数据,不幸的是,opencv 将丢弃它.

if there is any metadata attached to the (single image) file, opencv will discard it, unfortunately.

此外,mjpeg 协议本身没有任何时间戳(它只是一个与图像交错的 http-multi-part-form [非常类似于电子邮件附件],所以内容类型和内容长度就是你的全部)到达那里 [并且仅当您使用 http1.1 时]).

also, the mjpeg protocol does not have any timestamps on its own (it's just a http-multi-part-form interleaved with images [pretty similar to email-attachments], so content-type and content-length is all you get there [and that only if you're using http1.1]).

对于否定的答案很抱歉,但为此您必须研究除 opencv 之外的图像处理工具.

sorry for the negative answer, but you'll have to look into image-processing tools apart from opencv for this.