Sunday 24 November 2013

Using Motion mmal cam on raspberry pi

Installing, configuring the Motion software on a Raspberry pi. I will keep this post short and sweet and will only touch the basics. There is a tonne of stiff out there already, but I reckon the more it gets shared the more standard it will become.


I started mucking around with motion, when trying to make a wireless surveillance camera. The standard raspistill and raspivid command, simply won't cut the mustard and are only good for testing to see if the camera is pulgged in properly and in general if it captures at all. So forget about those commands.
At this stage I am assuming you have your OS installed (and updated  sudo apt-get update and sudo apt-get upgrade) and you have your Rpi networked up. And 


So what does the Motion software do?

well first of all the motion software is software that detects motion on  a video camera (it will also run on a USB connected webcam). It is created by a Danish guy called Kenneth Lavrsen and the software is open source and free for usage and download. You might want to read up on it in more details on: http://www.lavrsen.dk/foswiki/bin/view/Motion

The problem with the motion software is that it does NOT support the CSI RPi Camera, it is pretty much usable for webcams only, and it works well with it.


mmalcam is an adaptation to the original motion software that allows you to run motion features, using the CSI camera.  Really what is does is start capturing video as soon as "motion" is detected. Motion is a flexible term, because really what motion does is calculate changes in the stills. When a certain threshold has been exceeded, it assumes this is motion (but it could well be the wind moving the trees, which is motion we are not interested in). 



How to install motion-mmalcam?

Of course you will still need to install the motion software.

Type "sudo apt-get install motion".

Note: do not go any further configuring motion. Do not run it as a deamon, (which is where I went wrong the first time), just install the motion software

Type "sudo apt-get install -y libjpeg62 libjpeg62-dev libavformat53 libavformat-dev libavcodec53 libavcodec-dev libavutil51 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev".

Type "wget https://www.dropbox.com/s/xdfcxm5hu71s97d/motion-mmal.tar.gz".

Type "tar zxvf motion-mmal.tar.gz".




Configuration

Most all configuration exists in the /etc/motion/motion.conf file.


to run mmal:

./motion -n -c motion-mmalcam.conf

You will find there is some tweaking of the mmalcam.conf file involved to get the motion running the way you want it. Because there is a thousand ways do tweak it, I will not get into it. but inbox me if you want a working conf file. I would be more than happy to share it.

An alternative source can be found at:

http://simpledev.webs.com/apps/blog/show/31519067-tutorial-for-motion-detecting-raspberry-pi-security-camera-that-notifies-you-through-an-email-alert-with-a-snapshot-attached-

No comments:

Post a Comment