1

I am new to opencv and i am trying to track some moving objects(e.g. cars) in an image. I have computed the optical flow and have used it to implement kmeans and try something like background substraction , i mean seperate moving objects from stationary. Then i have also used the intensity of the video as information . The following screenshots are from the result of the flow and the k means segmentation respectively :

enter image description here

The results are not good but also not bad. How could i proceed from now on ? I am thinking of trying SURF feature extraction and SURF detector . Any ideas are welcome .

george_t
  • 188
  • 1
  • 3
  • 19
  • Shadows seem to cause issues, did you try the MOG2 detector that can detect the shadows? Where in the image do you want to detect the vehicles? Did you try cascade classifiers? – Dan Mašek Apr 04 '16 at 00:58
  • No i didn't use neither of these suggestions . And i do not even know how the work to be honest. I want to detect movement in general. Not count cars or something like that. Just detect movement and then track a car for example with specific colour . – george_t Apr 04 '16 at 01:43
  • Regarding background subtraction see [this](http://docs.opencv.org/3.1.0/db/d5c/tutorial_py_bg_subtraction.html#gsc.tab=0). The issue with feature detection is that it's suitable for finding a single match. I'm trying to play with it for [this question](http://stackoverflow.com/questions/36363397/issue-training-sift-or-surf-for-car-detection-in-video-with-opencv-python), and it's proving a little tricky. – Dan Mašek Apr 04 '16 at 01:55

1 Answers1

1

It seems you are using dense optical flow. I would advice trying some feature detection (surf, fast, whatever) followed by sparse optical flow tracking(from my experience it is better than feature matching for this task). Then, once you have the feature correspondences over some frames, you can use fundamental matrix, trifocal tensor, plane+parallax or some other method to detect moving objects. You can later cluster moving objects into different motion groups that represent different objects.

Also it seems that your camera is fixed. In this case you can drop the movement detection step, and consider only tracks with enough displacement, and then do the clustering into motion groups.

alexisrozhkov
  • 1,623
  • 12
  • 18
  • Thank you for your answer ! Later I am going to try with moving camera as well. My first thoughts are to use findHomography to compensate for the camera's movement. Is it going to work ? – george_t Apr 04 '16 at 08:47
  • Depends on how "flat" actual background is. Plane+parallax follows this path, and after homography compensation they obtain so called residual parallax. You can later check, if the movements share one focus of expansion or not and segment according to this criteria – alexisrozhkov Apr 04 '16 at 09:49
  • Can you provide me with some code or tutorials ? I would be grateful . – george_t Apr 04 '16 at 22:19
  • 1
    Do you have problem with some particular step? Then please provide more details. Or maybe you need a simple example to get you started? In this case a quick look on top google search results provides quite valuable sources: http://opencv-python-tutroals.readthedocs.org/en/latest/py_tutorials/py_video/py_lucas_kanade/py_lucas_kanade.html https://www.youtube.com/watch?v=X6rPdRZzgjg http://www.pyimagesearch.com/2015/09/21/opencv-track-object-movement/ – alexisrozhkov Apr 05 '16 at 09:54
  • Well, I have completed the projects with the optical flow. Now am I thinking how i could combine SURF features for example with optical flow. Would that be useful ? And how can you please explain me ? I am missing something in the theoretical approach i guess .. – george_t Apr 05 '16 at 09:59