I am new to matlab and computer vision. I used the code given in the link to detect cars. But the problem is the shadow is also being detected and tracked. Can anyone tell me how to modify the code so that only car are detected. Link:http://in.mathworks.com/help/vision/examples/detecting-cars-using-gaussian-mixture-models.html Thanks in advance
What I would try is to :
- Get the HSL (Hue Saturation Lightness) decomposition of the original picture
- Only keep the L component
- Multiply the image you have from the last steps with the image you get after the morphological operation (the black and white one, after deleting the noise)
- Do some thresholding on that
- Use what you obtained from that instead of the image after the morphological operation for the following part of the algorithm.
I don't know well Matlab so I can't provide function names, but I guess you can find it easily with a bit of googling. And please keep me updated if you try this, I would like to know if it works well or not.
In the example you've cited you feed RGB frames into
vision.ForegroundDetector. To get rid of shadows you can try converting the frame into a color space that separates luma from chroma, using
rgb2hsv. Then you can feed only the chroma components, cb and cr, or H and S respectively into
vision.ForegroundDetector. The downside of this approach is that you will not be able to detect gray objects. So you will probably not detect wheels and windows of the cars, and you may lose the entire car if it is not colorful.