4

I am developing a application for detecting vehicles using opencv.

I am using background subtraction method, BackgroundSubtractorMOG, and findContours method for detecting vehicles. I facing a couple of problems in this one.

1) When a vehicle stops,like in a signal, it becomes a part of the background. But I don't want this to happen.

2) When there are more vehicles stopping in signal closely, the foreground of all the vehicles are joined when using findcontors function.

Is there any way I could solve this problem.

Som
  • 185
  • 15
  • 1
    see https://stackoverflow.com/a/36274515/5294258 – sturkmen Jul 28 '17 at 11:58
  • @sturkmen thanks for pointing to that answer. – Som Jul 28 '17 at 14:33
  • 1
    @Som IIRC I at least partially address #1 in my answer there -- slower learning rate on the background subtractor, and ideally don't update the background when vehicles are in view (and definitely not when you detect that they are stationary. #2 will need some more elaborate segmentation. It would be useful if you could make a MCVE containing the relevant part of your algorithm and provide some sample inputs that reproduce the problem. – Dan Mašek Jul 28 '17 at 14:41
  • @DanMašek one more thing, you said not to update the background when vehicles are in view. Is there any function in BackgroundSubtractorMOG class to do it. Only method I could see is apply(...). – Som Jul 29 '17 at 08:31
  • @Som If you `apply` with learning rate set to 0, no updating of the model is done. – Dan Mašek Jul 30 '17 at 22:49
  • @DanMašek I got that one working thanks, but the current problem which I am facing is with "pMOG->apply(image,image,1.0);" which doesn't seem to initialize the background model, rather the first frame of the video is updated. Any ideas what I am doing wrong. – Som Jul 31 '17 at 03:05
  • @DanMašek Got it working at last,I had a mistake in my code, thanks.Can you suggest any methods which will be helpful for reducing the effect of vehicle headlight. Currently I tried CLAHE algorithm and equalizeHist methods, but not much help. Any advice will great, i am struck in this for a long time. – Som Jul 31 '17 at 14:48

0 Answers0