Posts: 12
Joined: Wed Aug 06, 2014 7:39 am

Motion detection software for the Pi

Thu Sep 11, 2014 8:52 pm

Hi folks!

First of all thanks for the wonderful community! I have become a fan of the Pi a month ago, using it predominantly for sports footage. However, I have two interesting issues to solve:

A) motion detection
- the Pi B/B+ should record all day long a football pitch (unattended, left on batteries)
- the Pi B/B+ will store the videos locally on the SD Card
- since the Pi is unattended, is it possible to make it record and store a video only after it recognizes some motion on the pitch so that we avoid deleting the moments when there is no play?
- I have made a research myself and have found the open-source motion detection software Motion (Motion is a program that monitors the video signal from cameras. It is able to detect if a significant part of the picture has changed; in other words, it can detect motion.): ... 43&t=75240
- Are there any other similar possibilities out there that you recommend for this case? :)

B) motion recognition - trajectory, movement trails
- the Pi is now with a standard camera module, without IR
- what are the advantages of using an IR camera module - in our use case the videos will be taken only when there is daylight outdoors, never in low light or when it is dark
- does anyone know a way of tracking movements/trajectory of an object via IR assuming that the object has been specifically painted/sprayed for the purpose?

Thank you very much for the attention.

Best regards!

User avatar
Posts: 15574
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Motion detection software for the Pi

Fri Sep 12, 2014 6:04 am

A) You're going to need a bigish battery to run a Pi all day.

Yes, motion is probably the package you need. It will work with the Pi camera using the v4l driver for it.
sudo apt-get install motion
Although the Pi is possibly not powerful enough to use the full features of motion. I have only used it with a USB video capture device and a camera with composite output and it wasn't able to handle more than about 1 frame a second. The Pi Camera should be a lot faster as much of the work is done with hardware acceleration.

User avatar
Posts: 3514
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Motion detection software for the Pi

Sat Sep 13, 2014 8:54 am

Motion on the pi is running all on the ARM (no HW acceleration). You can get 2 or 3 FPS at 1024 pixels across using the Pi camera board with Motion. There is a program that runs low res for Motion, then switches modes and records full HD video when motion is detected. The program is called "RPi Cam Web Interface" by silvanmelchior. ... 43&t=63276

No harm in trying, but for tracking balls or players on a sports field you may want a more powerful machine than
the Pi. Not sure the IR module would be of much use during the day in your case.

User avatar
Posts: 172
Joined: Sat Aug 04, 2012 6:02 pm

Re: Motion detection software for the Pi

Sat Sep 13, 2014 12:08 pm

You could try my customised version of motion for the Pi camera, which with careful configuration can achieve 15fps at a reasonable resolution. See this thread for more information: ... 43&t=75240

User avatar
Posts: 3514
Joined: Tue Nov 22, 2011 11:51 pm
Contact: Website

Re: Motion detection software for the Pi

Mon Oct 13, 2014 5:51 pm

I made a rather simple-minded Python program to detect motion while also recording video continually. This allows automatic extraction of the interesting parts as still frames (or also video, if you wanted). Motion detection happens only 4 times a second, but that is independent of the video recording rate. I'm only recording 8 fps video, but faster frame rates should be possible as that is mostly GPU, not the slower CPU.

Below, you can see it's good enough to capture a car driving at 36 km/h. ... 51#p626051

However if the whole system must run off batteries, this isn't the best approach. I'm using a second computer to store all the video files and extract stills wherever motion is flagged. My design goal was to get the highest resolution stills that had little or no lag between motion and still capture. I can get zero lag by looking a few frames backwards in time in the saved video from the moment of motion-detect.

Return to “Camera board”