Question

I have still images captured over the course of one night by a webcam. The majority are identical, since the lighting in the images is uniform. However, some are significantly different from the rest - they have visible human movement through the frame.

How can I detect which of the images are significantly distinct, so that the movement will be included in them? Better yet, is there a way of specifically detecting motion?

I'm guessing that a library like OpenCV or SimpleCV can accomplish this easily, but I'm not limited to using those ones.

Was it helpful?

Solution

In SimpleCV,

cam = Camera()
prev = cam.getImage()
while True:
    current = cam.getImage()
    fs = current.findMotion(prev, method="LK")
    if fs: #if there's motion
        print "motion found"
    prev = current

Image.findMotion() uses Optical Flow to detect motion. You can use this very easily. Add some condition regarding how much motion do you expect.

fs.dx and fs.dy will give you all the points where motion has been detected.

I have made an example in which I take input from camera and by detecting horizontal and vertical motion, I control Banshee Media Player. you can find it here on my GitHub.

OTHER TIPS

What you're looking for is called background subtraction:

image is taken from the web

(image is taken from this article)

Take a look at this SO discussion.

Also there are many articles/examples in OpenCV so just Google it.

If the first image that you have is of the similar kind , you could find the absolute difference of all the images from the first and have a threshold to find the images that are significantly different. Also in openCV , for detecting motion in a video , something like this can be done : http://sundararajana.blogspot.in/2007/05/motion-detection-using-opencv.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top