开源镜头检测实现?
我正在尝试实现一个视频检索系统,我需要首先从视频中提取关键帧,理想情况下我想要一个用于自动检测这些关键帧的库,每个镜头一个关键帧。如果我可以配置提取哪个关键帧(镜头中连续帧的第一个、中间或最后一个),那就太好了。 有这方面的开源实现吗?
I am trying to implement a video retrieval system and I need to first extract key frames from a video, ideally I want to have a library for automatically detecting those key frames, one key frame from each shot. Bonus if I can configure which key frame to extract(first, middle, or last of the continuous frames in a shot).
Is there an open source implementation for this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您所追求的称为镜头分割。虽然这是一个非常活跃的研究领域,但我认为您不太可能找到任何完整的库可以立即为您解决问题。您最好的选择可能是阅读该主题,选择最适合您要求的方法并自行编码。
一种方法是计算相邻帧的颜色直方图之间的卡方距离。当该距离超过用户指定的阈值时,您就处于镜头边界。 本文对此方法进行了解释:
我已经尝试过它,并取得了一些成功。值得注意的失败是单次拍摄中突然的光线变化(由相机闪光灯等引起)和混合镜头变化。
正如其他人指出的那样,一旦您知道了镜头边界,从每个镜头中选择关键帧将变得微不足道。
What you're after is called shot segmentation. While it's a pretty active research area, I think you're unlikely to find any complete libraries that solve the problem for you out-of-the-box. Your best option may be reading up on the topic, selecting an approach that best fits your requirements and coding it up yourself.
One approach is to calculate the chi-squared distance between the color histograms of adjacent frames. When this distance rises above a user-specified threshold, you are at a shot boundary. The approach is explained in this paper:
I've played around with it, with some success. Notable failures are sudden light changes within a single shot (caused by camera flash, etc) and blending shot changes.
Once you know the shot boundaries, picking a keyframe from each shot will be trivial, as other people have pointed out.
ffmpeg lib(包含在 openCV 中)可以使用 av_seek_frame() 来查找关键帧,
请参阅 FFMPEG 读取关键帧
The ffmpeg lib (included in openCV) can seek to a keyframe with av_seek_frame()
see FFMPEG reading keyframes
如果您有未压缩的视频作为输入,您可以从 [www.ffmpeg.org] 下载 ffmpeg 并使用此可执行文件将视频流解压缩为其帧。
随后,为了检测镜头边界,您必须从视频关键帧中提取一些特征。 MediaMixer 可交付成果,D1.1.2。此外,在 MediaMixer 网络研讨会中,您可以找到讲座“有意义地分割您的媒体资产 – 用于片段检测和提取的媒体分析” 展示了镜头边界检测实现,同时您还可以访问 MediaMixer 演示器[http://www.mediamixer.eu/automatic-fragmentation-and-annotation-for-improved-access-to-lecture-videos/]其中视频镜头分割和概念检测的结果被可视化。
If you have as an input an uncompressed video, you can download the ffmpeg from [www.ffmpeg.org] and use this executable to decompress your video stream into its frames.
Subsequently, in order to detect your shot boundaries you have to extract some features from the video keyframes. An efficient technique for shot boundary detection is proposed in MediaMixer Deliverable, D1.1.2. In addition, in MediaMixer Webinars you can find the lecture “Fragmenting your Media Assets meaningfully – media analysis for fragment detection and extraction” where this shot-boundary detection implementation is presented, while you can also visit the MediaMixer demonstrator [http://www.mediamixer.eu/automatic-fragmentation-and-annotation-for-improved-access-to-lecture-videos/] where the results of video shot segmentation and concept detection are visualized.