I want to use the Raspberry Pi and the camera board as surveillance camera: As soon as a movement is detected, an event shall be raised, e.g. a mail sent. What I am wondering about: Do the typicall software solutions for such a thing handle night/day change? I guess the image difference of the same place at daylight and at (dark) night is larger than a threshold one defines for movement / change detection?

5 Answers 5


standard raspbian image has motion program installed or you may easily install it with:

$ sudo apt-get install motion

that is surveillance software to capture, analyse images from the camera, detect a lot of different things, and do a log of other things (like sending mail, recording a video or saving pictures) when or even before the motion is detected. please install it and check config files for plethora of options available. it's easier to setup the necessary parameters if you start it as motion -s -- that will make it print a lot of debug information on the screen.

also, keep in mind, basically it's not a very good idea to use SD card as a storage for surveillance data, especially in the long run, so make sure you're going to get a decent HDD later for that purpose.

regarding day/night changes -- these happen too slowly to be detected, and motion has some options to ignore lights on/off as well.

ps. if you don't have RasPi available yet, motion is available in the most linux distributions and works well with most of the web cameras, so you may start testing right away =)


Look at this thread in raspberrypi.org : http://www.raspberrypi.org/phpBB3/viewtopic.php?p=358259#p362915

In thread user 'pageauc' pointed a python script to detect motion. In the script, developer use difference in sensivity of image. Count the changed pixels then if bigger than threshold. Steps for checking;

  • Take a test image to compare
  • Take another image to compare
  • Get image data from both image
  • Compare two images for changing
  • If changed anything in imagedata it is a motion.

I'm not a image processing developer, just tried to understand his code.


Most surveillance cameras use infrared light for motion detection. Normally a rapid change in the infrared view is needed to trigger an alarm, and the change from day to night is not rapid enough for this to happen.

If you're wanting to detect all movement, not just infrared, you could do something similar with a regular image. Just make it such that only significant changes in between images will trigger the event.

  • Yeah, I think I know what you mean, change from day to night doesn't happen in a second. Interesting information how motion detection is usually done, thanks! But what if at night light from another room comes into the picture and changes a large amount of the image? Is there software detection kind of changed corners, objects etc in the image instead of only pixel intensitys? Aug 16, 2013 at 21:37
  • If you use infrared detection I don't think turning on lights in other rooms would cause a problem. If you had a night light plugged into the wall in view of the camera, it might cause a disturbance. If you just plan on using regular images, things could get tricky pretty fast.
    – Gramstrong
    Aug 16, 2013 at 21:47

I think this is what you are looking for. http://www.raspberrypi.org/phpBB3/viewtopic.php?f=2&t=617


here is a complete implementation of a home video surveillance system using multiple Raspberry Pi Cameras : www.magdiblog.fr/domotique/systeme-de-tele-surveillance-abordable-avec-des-raspberry-pi/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.