How to find object on video using OpenCV

Thar1988 picture Thar1988 · May 28, 2012 · Viewed 14.8k times · Source

To track object on video frame, first of all I extract image frames from video and save those images to a folder. Then I am supposed to process those images to find an object. Actually I do not know if this is a practical thing, because all the algorithm did this for one step. Is this correct?

Answer

karlphillip picture karlphillip · May 28, 2012

Well, your approach will consume a lot of space on your disk depending on the size of the video and the size of the frames, plus you will spend a considerable amount of time reading frames from the disk.

Have you tried to perform real-time video processing instead? If your algorithm is not too slow, there are some posts that show the things that you need to do:

  • This post demonstrates how to use the C interface of OpenCV to execute a function to convert frames captured by the webcam (on-the-fly) to grayscale and displays them on the screen;
  • This post shows a simple way to detect a square in an image using the C++ interface;
  • This post is a slight variation of the one above, and shows how to detect a paper sheet;
  • This thread shows several different ways to perform advanced square detection.

I trust you are capable of converting code from the C interface to the C++ interface.