9

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?

Jav_Rock
  • 21,011
  • 18
  • 115
  • 164
Thar1988
  • 471
  • 3
  • 9
  • 21

2 Answers2

9

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.

Community
  • 1
  • 1
karlphillip
  • 87,606
  • 33
  • 227
  • 395
  • Sir Thank you very much for your reply. Yeah,Now i could understand that using two steps will take more time. so i thought that using one step is good for a real time project. Sir, according to the your answer of http://stackoverflow.com/questions/3907028/opencv-every-frame-processing/3919216#3919216 i studied about video processing and but i could not understand that how to track object from the processed video frame. could you please explain that how to identify object of that processed video frame. and Sir i would glad if you provide some coding on c++ interface. – Thar1988 May 29 '12 at 17:11
  • sir,could you please explain that does that require separate two threads for writing both video frame processing part and object tracking part in one program. i would be glad if you give some example for that. – Thar1988 May 29 '12 at 17:36
  • Let's keep one question per thread, you are starting to hijack your own thread. If you have other questions, feel free to ask them in separate threads. Stackoverflow is not aimed at 1x1 support. I summarized what needs to be done and provided a few references with code. There's very little left for you to do. There are other posts here that talk about implementing multithreading system for capturing and processing frames from the camera using OpenCV. keyword: [circular buffer](http://stackoverflow.com/questions/10535182/advice-for-real-time-image-processing/10536166#10536166). – karlphillip May 29 '12 at 17:41
  • Sir I'm sorry for if there was an inconvenience, actually i am new to stackoverflow and did not feel that asking more than one question is not good in one thread.i give my best to avoiding those difficulties. so again i would like to say sorry if there was an inconvenience. – Thar1988 May 29 '12 at 18:10
  • No problem, don't worry. Enjoy Stackoverflow, I'll see you around. – karlphillip May 29 '12 at 20:18
5

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.

Community
  • 1
  • 1
Jav_Rock
  • 21,011
  • 18
  • 115
  • 164
  • Sir Thank you for your reply.Yeah. Now i can understand that there is no point to doing two steps(first storing frames and then track object for those frame). is SIFT algorithm is should do using matlab and java? – Thar1988 May 29 '12 at 17:23
  • Yes, as long as you have SIFT implemented, it will work. I think matlab should be slower, but it is great to play with data and learn the process. Debuging OpenCV is a bit annoying. – Jav_Rock May 29 '12 at 20:01
  • but the thing is the project is implementing using opencv and c++ . are there any good algorithms that can be using for opencv – Thar1988 May 30 '12 at 16:30
  • 2
    OpenCV has got all the good algorithms. SIFT, FAST, SURF,RANSAC,... For detecting an object you need first "features" that describe it (which you can obtain with SIFT) and a matching algorithm (matchTemplate, e.j.). Google a bit, search posts here in stackoverflow and you will practicaly get the codes, but first try something by yourself. At the beggining is tricky, but you can ask for help here. – Jav_Rock May 30 '12 at 16:50
  • in SURF that detect key points of the video. how i can change that to detect only an rectangular objects? – Thar1988 Jun 02 '12 at 18:52
  • i would be glad if you help me for following question about SURF [link](http://stackoverflow.com/questions/10867412/how-to-detect-object-in-a-video-using-surf-and-c) – Thar1988 Jun 03 '12 at 02:28
  • That is a whole different question, to go from SURF to a rectangle of the object, there is a sample: http://docs.opencv.org/doc/tutorials/features2d/feature_homography/feature_homography.html#feature-homography – Rui Marques Jun 21 '12 at 15:11