简体   繁体   English

OpenCV在视频中查找图片(帧)

[英]OpenCV finding picture (frame) in video

I am trying to create small application in C++ that will return probability value (real number from 0 to 1) for recognizing two pictures in video.我正在尝试用 C++ 创建一个小应用程序,它将返回概率值(从 0 到 1 的实数)以识别视频中的两张图片。 My idea is to find commercials in certain video material.我的想法是在某些视频材料中找到广告。 I was thinking to cut first frame from commercial as well as the last one.我想从商业广告和最后一帧中剪下第一帧。 In that way I could create app, using OpenCV, that will load a video (TV content) and then it will search for the first frame catted from commercials.通过这种方式,我可以使用 OpenCV 创建应用程序,该应用程序将加载视频(电视内容),然后搜索从广告中提取的第一帧。 If it finds it (with probability more than SOME_PARAMETER) than app can conclude that that commercials starts there.如果它找到它(概率超过 SOME_PARAMETER),那么应用程序可以得出结论,广告从那里开始。 Then I would like to search for the last frame and if it's found (again with probability more than SOME_PARAMETER) than the app can conclude that wanted commercial really exists in given video.然后我想搜索最后一帧,如果找到了(再次概率超过 SOME_PARAMETER),那么应用程序可以得出结论,在给定的视频中确实存在想要的商业广告。 This is just an idea.这只是一个想法。 I am expert in C++ but totally newbie with OpenCV.我是 C++ 专家,但完全是 OpenCV 的新手。 If someone can point me out, or give an example it would be much appreciated.如果有人能指出我,或举个例子,将不胜感激。 Of course I am open to any suggestions regarding idea.当然,我对任何关于想法的建议持开放态度。 Thanks,谢谢,

M. M。

What you are looking for is known as template matching in OpenCV.您正在寻找的是 OpenCV 中的模板匹配

To get acquainted with OpenCV you should start reading some tutorials , besides the books there are some good ones on the web.要熟悉 OpenCV,您应该开始阅读一些教程,除了书籍之外,网络上还有一些不错的教程 As a C++ guy, you will probably use the C++ interface of OpenCV which uses cv::Mat as the main data structure to represent images.作为一个 C++ 人,你可能会使用OpenCV的 C++ 接口,它使用cv::Mat作为主要数据结构来表示图像。 If you see the IplImage data type being used, know it's from the C interface.如果您看到正在使用的IplImage数据类型,请知道它来自 C 接口。

After the preliminaries, you will eventually need to learn how to read frames from a video:在预赛之后,您最终将需要学习如何从视频中读取帧:

and then how to process those frames, individually:然后如何单独处理这些帧:

Finally, you will investigate how template matching works:最后,您将研究模板匹配的工作原理:

There are other ways to track objects besides template matching, check these references:除了模板匹配之外,还有其他跟踪对象的方法,请检查这些参考:

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

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