Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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.

like image 282
Miloš Ljumović Avatar asked Mar 25 '13 15:03

Miloš Ljumović


People also ask

How do I pull a frame from a video?

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.

How can I tell how many frames a video has?

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).


1 Answers

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:

  • Reading a video with openCV
  • Read/write avi video using openCV

and then how to process those frames, individually:

  • OpenCV every frame processing (C interface)
  • How to find object on video using OpenCV
  • Object traking within a video file
  • Very Slow Processing of my Opencv Application

Finally, you will investigate how template matching works:

  • How can I perform Template Matching process in SUB-IMAGE extracted from ORIGINAL-IMAGE and Display the results in Original Image
  • How to handle template matching with multiple occurences

There are other ways to track objects besides template matching, check these references:

  • Comparison of OpenCV's feature detection algorithms
  • Object Tracking using OpenCV (C++/Python)
like image 124
karlphillip Avatar answered Sep 24 '22 15:09

karlphillip