Hi, just wanted to echo the other posters and say thanks to dozencrows for this! It's awesome and works great, I had no problems setting it up. The quality is great from the pi cam, so much better than usb webcams. Motion works great with it and for my purposes the motion detection is spot on, with no modifications it doesn't get activated by trees swaying etc, but people are captured straight away.
Cheers!
-
- Posts: 6
- Joined: Sat Jun 16, 2012 8:32 am
- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Re: Motion - MMAL camera
FYI I've moved the temporary binary build to Dropbox from Google Drive. This should hopefully be even easier for everyone!
It is now at this location: https://www.dropbox.com/s/xdfcxm5hu71s9 ... mal.tar.gz
You shouldn't need to sign up for or install Dropbox to access it - use the link in a browser, or use wget on a Pi command line to load it directly onto a Pi.
It is now at this location: https://www.dropbox.com/s/xdfcxm5hu71s9 ... mal.tar.gz
You shouldn't need to sign up for or install Dropbox to access it - use the link in a browser, or use wget on a Pi command line to load it directly onto a Pi.
Re: Motion - MMAL camera
Thanks!dozencrows wrote:FYI I've moved the temporary binary build to Dropbox from Google Drive. This should hopefully be even easier for everyone!
It is now at this location: https://www.dropbox.com/s/xdfcxm5hu71s9 ... mal.tar.gz
You shouldn't need to sign up for or install Dropbox to access it - use the link in a browser, or use wget on a Pi command line to load it directly onto a Pi.

- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Re: Motion - MMAL camera
Tentative promising news on the performance front...
I've been able to double the speed of the basic image differencing algorithm using some hand-coded ARM assembly. This is good evidence that progress can be made! Because of all the other processing going on, this translates to only about a 10% to 12% speedup - but it's encouraging that I can make a difference, and am keen to try more over the coming weeks.
I can't make this public quite yet, as it needs more testing and I haven't got time left this weekend to tidy up enough loose ends to push the source to GitHub.
I've been able to double the speed of the basic image differencing algorithm using some hand-coded ARM assembly. This is good evidence that progress can be made! Because of all the other processing going on, this translates to only about a 10% to 12% speedup - but it's encouraging that I can make a difference, and am keen to try more over the coming weeks.
I can't make this public quite yet, as it needs more testing and I haven't got time left this weekend to tidy up enough loose ends to push the source to GitHub.
-
- Posts: 39
- Joined: Mon Feb 11, 2013 12:00 am
- Location: USA Alabama
Re: Motion - MMAL camera
So what is the trick to viewing the video stream? My laptop is running Windows 7 with IE 9. When I browse to the Raspberry PI address and port 8081, Internet Explorer wants to know if I want to open or save the output. Neither choice will show me the video. Is it my browser or do I not have something configured correctly?
Re: Motion - MMAL camera
Just tried with IE 10 on 7 and it does the same for me. I've always used VLC to open a network stream or Firefox/Chrome and they both just display the feed. I believes it a motion-jpg.whowantspi wrote:So what is the trick to viewing the video stream? My laptop is running Windows 7 with IE 9. When I browse to the Raspberry PI address and port 8081, Internet Explorer wants to know if I want to open or save the output. Neither choice will show me the video. Is it my browser or do I not have something configured correctly?
Craig.
Re: Motion - MMAL camera
Internet Explorer does not support motion jpeg.
Leo
Leo
-
- Posts: 39
- Joined: Mon Feb 11, 2013 12:00 am
- Location: USA Alabama
Re: Motion - MMAL camera
So what are my choices for viewing the video on a Windows 7 machine?
Re: Motion - MMAL camera
This looks to work quite well. It worked quite well while testing it with the RPi in a room but then I moved it so it was showing an outside picture. After this due to the high brightness the picture seems to cycle in brightness i.e. start at black, brigher..brighter, very bright and then back to black.
Any ideas how to solve this?
I've tried turning on autobrightness but this made no difference.
Any ideas how to solve this?
I've tried turning on autobrightness but this made no difference.
- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Re: Motion - MMAL camera
Please try using the raspivid program to capture video in the same environment (with the same mmalcam parameters) and see if that is stable or not - this will help determine if it is a camera-side issue or an issue with motion.
It might also be worth trying out the different metering and exposure settings detailed in the Pi camera documentation.
Some have also experienced exposure stability problems with the timelapse mode of raspistill - if you haven't read it, there might be some useful info in this thread: http://www.raspberrypi.org/phpBB3/viewt ... 18#p361518
It might also be worth trying out the different metering and exposure settings detailed in the Pi camera documentation.
Some have also experienced exposure stability problems with the timelapse mode of raspistill - if you haven't read it, there might be some useful info in this thread: http://www.raspberrypi.org/phpBB3/viewt ... 18#p361518
-
- Posts: 2
- Joined: Wed Jun 05, 2013 2:31 pm
Re: Motion - MMAL camera
Hi dozencows.
I haven't really got a question - I probably will have in the future.. I just wanted to say how amazed I am by this forum and this post. I intend to use my pi and camera and motion to catch fly-tippers in a local lane. I don't get much time to play so it might take some time. Next big step is getting motion to work - and to understand how to use it, then I will to work out how to run the pi on batteries or solar.... Good job everyone posting here though - not like other forums where novices like me get totally torched.
I haven't really got a question - I probably will have in the future.. I just wanted to say how amazed I am by this forum and this post. I intend to use my pi and camera and motion to catch fly-tippers in a local lane. I don't get much time to play so it might take some time. Next big step is getting motion to work - and to understand how to use it, then I will to work out how to run the pi on batteries or solar.... Good job everyone posting here though - not like other forums where novices like me get totally torched.
Re: Motion - MMAL camera
The following 4 steps are collated from the excellent posts so far. They cover installing the depedencies (some my be overkill but it worked for me), downloading the prebuilt binary, unziping the archive and running with the MMAL config provided.Globalidentity wrote:Hi dozencows.
Next big step is getting motion to work
Code: Select all
$ 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
$ wget https://www.dropbox.com/s/xdfcxm5hu71s97d/motion-mmal.tar.gz
$ tar -zxvf motion-mmal.tar.gz
$ ./motion -n -c motion-mmalcam.conf
- Slowly spreading the joy the RaspberryPi way!
http://raspberrytorte.com/ http://wiki.raspberrytorte.com https://github.com/raspberrytorte
Re: Motion - MMAL camera
great work, without knowing anything about 'motion' I followed the above instructions and it worked the first time. Great!
WIth one exception, this command fails on my install
I had to remove the dash, like so:
and I made a small change to the .conf file like so:
WIth one exception, this command fails on my install
Code: Select all
tar -zxvf motion-mmal.tar.gz
Code: Select all
tar zxvf motion-mmal.tar.gz
Code: Select all
############################################################
# OpenMax/MMAL camera support for Raspberry Pi
############################################################
mmalcam_name vc.ril.camera
mmalcam_control_params -mm matrix -rot 180
Re: Motion - MMAL camera
Ok, I have to correct my glowing review above. What I see in my home directory, after running './motion -n -c motion-mmalcam.conf' are a set of .jpg files, with long number-names that indicate year-month-day-hour-minute-second-frame, and also a set of .avi files. The JPEG files are exactly as I expect, I see about one frame per second (sometimes 2 in the same second) where something new appeared in the frame. Now I assume the avi files are supposed to be a combined set of the stills, grouped together by when a continuous motion was detected, but when I try to play them, they are all frozen at the first frame. However they are of various, fairly large sizes and they do last a variable number of seconds, proportional to how long the motion event was, so I think they are not simply 1-frame videos.
I wonder if there is some problem with ffmpeg, I presume that is what motion is calling to generate the avi.
I wonder if there is some problem with ffmpeg, I presume that is what motion is calling to generate the avi.
Re: Motion - MMAL camera
Hi, I had something similar when I try and play the videos via VLC, first frame and no more, playing them via windows media player showed the full video. I didn't dig much further as I just blamed by setup, if I get a chance tonight I'll try and dig deeper unless someone else knows sooner.jbeale wrote:Ok, I have to correct my glowing review above. What I see in my home directory, after running './motion -n -c motion-mmalcam.conf' are a set of .jpg files, with long number-names that indicate year-month-day-hour-minute-second-frame, and also a set of .avi files. The JPEG files are exactly as I expect, I see about one frame per second (sometimes 2 in the same second) where something new appeared in the frame. Now I assume the avi files are supposed to be a combined set of the stills, grouped together by when a continuous motion was detected, but when I try to play them, they are all frozen at the first frame. However they are of various, fairly large sizes and they do last a variable number of seconds, proportional to how long the motion event was, so I think they are not simply 1-frame videos.
I wonder if there is some problem with ffmpeg, I presume that is what motion is calling to generate the avi.
Craig.
-
- Posts: 22
- Joined: Mon Jan 07, 2013 5:45 pm
Re: Motion - MMAL camera
I'm seeing the same frozen avi's in VLC but not if I open them in Winamp or Irfanview. Not sure why VLC has a problem but I've also seeing the same problem with vanilla Motion avi's
Re: Motion - MMAL camera
Same as the others have reported, VLC locks up on the first frame (and runs 100% CPU) but Windows Media Player, and also Nero ShowTime can play it. The metadata reported by "codec information appliance" GSpot v2.70a says the frame rate is 5 fps. But the actual playback is more like 1 fps, but jerky and inconsistent; sometimes faster. I wonder if that is problem- maybe VLC is expecting to find five frames per second, but the 'motion' process wasn't fast enough to actually record all the frames for the requested rate.
Re: Motion - MMAL camera
generation of avi's is part of the motion config.
admittedly I switched this off in the default file before I started
poor quality video will probably be because you're overtaxing the RPI asking for both.
disable in the conf and retest.
I recommend running 'top' in another terminal to monitor performance.
also enable by default (I think) is the web stream. watch this at <your.RPI.IP>:8081 in a webbrower.. on another machine of course.
admittedly I switched this off in the default file before I started
poor quality video will probably be because you're overtaxing the RPI asking for both.
disable in the conf and retest.
I recommend running 'top' in another terminal to monitor performance.
also enable by default (I think) is the web stream. watch this at <your.RPI.IP>:8081 in a webbrower.. on another machine of course.
- Slowly spreading the joy the RaspberryPi way!
http://raspberrytorte.com/ http://wiki.raspberrytorte.com https://github.com/raspberrytorte
Re: Motion - MMAL camera
I expected the movie to be jerky due to the slow, and inconsistent frame rate. I did not expect VLC (running on a Debian install on Dell laptop, not R-Pi) to freeze on the first frame and actually lock up, and require a kill -9 to stop. Maybe there's a problem with the .avi but it also seems to trigger a bug in VLC.
Yes, the live view in the web browser at port 8081 is a nice feature, I can even see it on my Android phone.
Yes, the live view in the web browser at port 8081 is a nice feature, I can even see it on my Android phone.
- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Re: Motion - MMAL camera
The frame rate specified in the "mmal" configuration file is 5 fps at 1024 x 576, which is optimistic...
It might be worth dialling this down to a realistic figure and see if that makes for more stable AVI generation.
It might be worth dialling this down to a realistic figure and see if that makes for more stable AVI generation.
- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Re: Motion - MMAL camera
Having looked further into the motion code, my suggestion above probably won't make a difference - the actual frame rate used for ffmpeg is calculated based on the real capture frame rate just prior to generating a new AVI file. So there will be differences in frame rate between video files, but the base frame rate for a file should be constant.
I've noticed variability in frame timing not just in the ffmpeg movie generation - the image shown for a given timestamp is often actually a few seconds behind real time, and sometimes there can appear to be big visual jumps that don't tie up with the timestamps. I suspect that much better performance needs to be achieved in order to tackle these by improving the capture frame rate.
The image subjects also play a part here - with the relatively narrow FOV of the video, only relatively low speed objects are going to get captured. My test environment (front bedroom window) means that any vehicle going over about 15mph would at best appear in one frame. And with a rate of 1 fps, it's very easy for a subject to accelerate or decelerate significantly between frames.
I've noticed variability in frame timing not just in the ffmpeg movie generation - the image shown for a given timestamp is often actually a few seconds behind real time, and sometimes there can appear to be big visual jumps that don't tie up with the timestamps. I suspect that much better performance needs to be achieved in order to tackle these by improving the capture frame rate.
The image subjects also play a part here - with the relatively narrow FOV of the video, only relatively low speed objects are going to get captured. My test environment (front bedroom window) means that any vehicle going over about 15mph would at best appear in one frame. And with a rate of 1 fps, it's very easy for a subject to accelerate or decelerate significantly between frames.
- dozencrows
- Posts: 176
- Joined: Sat Aug 04, 2012 6:02 pm
Re: Motion - MMAL camera
Time for a code update!
I've pushed some changes to GitHub and updated the binary build in Dropbox (https://www.dropbox.com/s/xdfcxm5hu71s9 ... mal.tar.gz).
What's changed?
I've pushed some changes to GitHub and updated the binary build in Dropbox (https://www.dropbox.com/s/xdfcxm5hu71s9 ... mal.tar.gz).
What's changed?
- First pass assembler optimisations to the image processing "hotspots". Currently only a very small gain in speed, and only if you're not using a mask image or the smart mask option.
- Option to use the Pi camera's stills mode rather than video. This can give you a wider field of view, but currently exposure control can go a bit wild if you have a frame rate faster than around 0.2 fps. So right now it's not very useful, but I'd be interested to hear others' experiences with it. See the example config file for more info.
- Some internal changes to make it easier to test changes for correctness and measure performance.
Re: Motion - MMAL camera
Hi all,
Running as a normal user this solution works perfect.
But if I want to run it as a service (so it will lauch automatically when rebooted), I cannot make it work.
The issue seem, that the service do not start the application with "./motion" in the home-folder, but as "motion" which gives the errors "/dev/video0".
Anybody who have had success turning this application into a service ??
Best regards,
dktak
Running as a normal user this solution works perfect.
But if I want to run it as a service (so it will lauch automatically when rebooted), I cannot make it work.
The issue seem, that the service do not start the application with "./motion" in the home-folder, but as "motion" which gives the errors "/dev/video0".
Anybody who have had success turning this application into a service ??
Best regards,
dktak
Re: Motion - MMAL camera
copy the motion-mmalcam.conf file to /etc/motion.conf,
copy the motion file to /usr/bin
and then you can start motion from /etc/rc.local
Pete
copy the motion file to /usr/bin
and then you can start motion from /etc/rc.local
Pete