Motion Detection Using Raspberry Pi

Intro: Motion Detection Using Raspberry Pi

Here i am explaining a simple motion detection project. Platform used is raspberry pi. Motion is detected using the simplecv libraries which is available in python.

What is SimpleCV ?
SimpleCV is an open source framework for building computer vision applications. With it, you get access to several high-powered computer vision libraries such as OpenCV – without having to first learn about bit depths, file formats, color spaces, buffer management, eigenvalues, or matrix versus bitmap storage.

Step 1:

Parts needed

1.Raspberry pi

2.USB Camera

Now we can see how the motion is detected using the camera. Take multiple images and subtracting each image from the previous one. If their is no motion, the difference between the images will be almost equal to zero or a small value. Otherwise if motion detected, the difference is a big value. This is the basic idea behind the motion detection.

The python code for motion detection is given below

from SimpleCV import Camera,Display
import time
cam=Camera() //Intializing camera
time.sleep(3) //delay for three seconds
a=cam.getImage()//capturing the first image
time.sleep(1)
b=cam.getImage()//capturing the second image after one second
d=b-a //subtracting the image pixels
d.show() // display the subtracted image
mat=d.getNumpy() //converting to numpy array
avg=mat.mean() //take the mean
print avg //print average value on the screen
if avg>6:
print("Motion Detected")
else: print("not detected")

Share

    Recommendations

    • Audio Contest 2018

      Audio Contest 2018
    • Plastics Contest

      Plastics Contest
    • Optics Contest

      Optics Contest

    2 Discussions

    0
    None
    Greywolfg

    2 years ago

    Nice job! The Raspberry Pi is amazing! :D

    Going to try soon.

    #RaspberryPI

    1 reply