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.