3

I am trying to use opencv background subtraction for detecting moving objects. It works good for some videos. But for one particular video (captured by still camera), it do not detect moving pedestrians. Also, there is very light snow showers in the video which are hard to see by naked eye. Could this be the reason it do not detect the moving objects. Or there could be other reasons like similar pixel values for background and foreground objects.

This is program code:

import processing.core.*;
import processing.video.*;
import gab.opencv.*; 
public class BackgroundSubtraction extends PApplet {

Movie video;
OpenCV opencv;

public void setup(){
    size(720,680);
    video = new Movie(this, "/home/gurinderbeer/Downloads/IMG_1570.MOV");
    opencv = new OpenCV(this, width, height);
    opencv.startBackgroundSubtraction(0, 3, .5); // 5,3, .5
    video.play();
    }

public void draw() {
    image(video, 0, 0); 
    opencv.loadImage(video);
    opencv.updateBackground();
    opencv.dilate();
    opencv.erode();
    noFill();
    stroke(255, 0, 0);
    strokeWeight(3);
    for (Contour contour : opencv.findContours()) {
        contour.draw();
        }
    }


public void movieEvent(Movie m) {
      m.read();
    }

public static void main(String _args[]){
    PApplet.main(new String[] { BackgroundSubtraction.class.getName()});
    }
}

These are couple of snapshots from video. We can hardly see any snow showers (although there are actually very light snow showers), and there are two pedestrians walking. but they are not captured in contour detection.

Could this very light snow showers be the reason for not detecting the walking pedestrians.

  • I never used that function but snow will definitely add noise to your image which might cause troubles if this algorithm is based on detecting non-changing things. Check if there is some noise threshold you can set. The contrast ist not very good but you should at least detect some movement when the guys cover the snow area. – Piglet Feb 11 '16 at 10:32
  • I would try applying median filter on each frame.It should remove snowflakes, if it isn't avalanche. :-) – Milos Miletic Apr 04 '16 at 16:42
  • Thanks for your reply @Milos. I will try this as well. Actually, I was using older version of Opencv (2.4) . When I updated the opencv where some different algorithm is used for background subtraction, it worked. – Gurinderbeer Singh Apr 04 '16 at 17:49

1 Answers1

1

It could be due to the background noises from the environment, you could use Smoothing Effect on your video before processing.

The smoothing will definitely blur out the noises which will improve the overall detection rate.

There is an example here.

Meaniegy
  • 62
  • 1
  • 7