4

I am trying to extract several moving objects in a video frame, and extract them as foreground. The data is from video frames.

The current problem is: the light is changing, so there are some shadows, or more brighter parts than the actual background. This leads to false background/foreground extraction by OpenCV MoG background segmentation method.

For this, I haven't get any straightforward method, but have an idea like this: if I can extract the edges of those moving objects in the previous frame, then maybe I could track them using algorithms like SIFT in the next frame, see where they are, and regard them as foreground.

I think in this case, the light change won't affect the result. If I am right on this point, then my question is:

How can I do the edge detection of those moving objects efficiently with OpenCV? If I need to use SIFT algorithm in OpenCV, is it freely available? From the web, I saw it was nonfree, am I right?

And my second question is: does anyone have a better idea for this?

Thank you.

Rui Marques
  • 8,567
  • 3
  • 60
  • 91
E_learner
  • 3,512
  • 14
  • 57
  • 88
  • You could consider a simpler edge detector (Sobel, Laplace, etc). – CookieOfFortune Oct 10 '12 at 17:18
  • @CookieOfFortune: thank you for your answer. The problem is, how to decide the moving object edges among other edges from background, and then tracking them in SIFT, etc, especially under changing light condition. Do you have any idea? – E_learner Oct 10 '12 at 17:23
  • 2
    Do you know something about the object you try to recognize (color, shape etc)? – ArtemStorozhuk Oct 10 '12 at 17:25
  • I want to do human detection, but the color of their clothes could be different. – E_learner Oct 10 '12 at 17:29

3 Answers3

4

If you want to do human detection/tracking you should look for research papers or projects regarding exactly that. There is a lot of it, you will even find some questions regarding that topic here on SOF:

How can I detect and track people using OpenCV? (maybe outdated)

single person tracking from video sequence

How to do motion tracking of an object using video?

Also, there are several questions addressing feature detectors/descriptors like SIFT and its more recent alternatives (SURF, ORB, FREAK - just to name some implemented in OpenCV):

Are there any fast alternatives to SURF and SIFT for scale-invariant feature extraction?

OpenCV for ANDROID image compare

To put it simple, SIFT is not an algorithm to track moving objects, it is to detect image regions which are somehow unique and robust to several distortions (translation, rotation, scale...). Meaning, the same feature can be later detected in different image conditions. You can indeed use SIFT-like algorithms to identify objects, but maybe for person tracking there are better alternatives. To those image regions you can then apply some tracking algorithm, optical flow, for example - but there are more specific ones for human tracking.

SIFT and SURF are "freely" available with OpenCV but parts of them are patented so people are avoiding to use them so they have no issues in the future because of those patents - this is the reason they where moved to the "nonfree" OpenCV module.

Other problems you will have, besides the light issues you mentioned, are object occlusion and people entering-exiting the scene.

Community
  • 1
  • 1
Rui Marques
  • 8,567
  • 3
  • 60
  • 91
  • thank you for your answer. I will read carefully those links you give and about object occlusion under light changing conditions. – E_learner Oct 10 '12 at 19:24
3

May I suggest that you normalize the images for illumination. One practical way of doing this is to use "Histogram Matching".

Please have a look at Histogram matching of two colored images in matlab to know about using histogram matching.

Hope this helps

Community
  • 1
  • 1
mkuse
  • 2,250
  • 4
  • 32
  • 61
2

I know that you have already accepted Rui's answer, but after some googling I found another solution to your problem - it's HOG Descriptor.

Unfortunately, I'm not familiar with this descriptor, so I can't help you with implementing, but, again, after some googling I found that this descriptor is used for pedestrian detection.

Take a look at this human detection code.

ArtemStorozhuk
  • 8,715
  • 4
  • 35
  • 53
  • Dear Astor, thank you so much for your answer. I will aslo look at them. With regards. – E_learner Oct 11 '12 at 06:20
  • 1
    I was about to mention HOG, but was unsure :) Here is a link talking about HOG: http://answers.opencv.org/question/711/human-detector-using-haar-cascades-has-too-many/ – Rui Marques Oct 11 '12 at 08:33