Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find object on video using OpenCV

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?

like image 566
Thar1988 Avatar asked May 28 '12 17:05

Thar1988


People also ask

How do I identify a specific object in an image in python?

To actually detect objects, you need to call the detectObjectsFromImage() method. Pass the file path of your input image to the “input_image” parameter and the path to the output image (this image will contain the detected object, but it doesn't exist yet), to the “output_image_path” parameter.


2 Answers

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.

like image 190
karlphillip Avatar answered Oct 08 '22 07:10

karlphillip


There is no point in storing frames of a video if you're using OpenCV, as it has really handy methods for capturing frames from a camera/stored video real-time.

In this post you have an example code for capturing frames from a video.

Then, if you want to detect objects on those frames, you need to process each frame using a detection algorithm. OpenCV brings some sample code related to the topic. You can try to use SIFT algorithm, to detect a picture, for example.

like image 28
Jav_Rock Avatar answered Oct 08 '22 08:10

Jav_Rock