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. 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. If it finds it (with probability more than SOME_PARAMETER) than app can conclude that that commercials starts there. 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. This is just an idea. I am expert in C++ but totally newbie with 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.
Take a screenshot when the video is playing simply by pressing the Snapshot icon or pressing CTRL+ALT+S. You can use the Left or Right arrow button on the keyboard to playback the video frame by frame and save the frame in image format.
cv. CV_CAP_PROP_FRAME_COUNT . Ideally, passing the respective property name into the . get method of the video pointer will allow us to obtain the total number of frames in the video (Lines 25-30).
What you are looking for is known as template matching in OpenCV.
To get acquainted with OpenCV you should start reading some tutorials, besides the books there are some good ones on the web. 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. If you see the IplImage
data type being used, know it's from the C interface.
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:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With