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

Re: Motion - MMAL camera

Sat Apr 05, 2014 2:34 pm

justinzane wrote: I've been googling for a while but I cannot find the sources for the motion-mmal patch/plugin. Could you kindly post the git/mercurial/svn/bzr repo url for it. Thanks.
The URL is present several times already in this very thread... but just to help - https://github.com/dozencrows/motion/tree/mmal-test

eccentricdyslexic
Posts: 157
Joined: Thu Jul 18, 2013 6:13 am
Location: Uttoxeter, Staffordshire, UK

Re: Motion - MMAL camera

Mon Apr 07, 2014 3:01 pm

Hi peeps,

I am also getting the error-

http_bindsock: motion-stream bind() failed, retrying:

I have run

netstat -anp

and this is the result-

[email protected] ~ $ netstat -anp
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:3389 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:8099 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:8081 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:3350 0.0.0.0:* LISTEN -
tcp 0 0 192.168.1.99:58735 64.94.18.122:443 TIME_WAIT -
tcp 0 816 192.168.1.99:8099 81.219.175.201:63574 ESTABLISHED -
udp 0 0 192.168.1.99:123 0.0.0.0:* -
udp 0 0 127.0.0.1:123 0.0.0.0:* -
udp 0 0 0.0.0.0:123 0.0.0.0:* -

I am confused as to how to resolve this issue.

Cheers

Steve

User avatar
DougieLawson
Posts: 37604
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Motion - MMAL camera

Mon Apr 07, 2014 3:07 pm

tcp 0 0 0.0.0.0:3389 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:8099 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:8080 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:8081 0.0.0.0:* LISTEN -
tcp 0 0 127.0.0.1:3350 0.0.0.0:* LISTEN -
tcp 0 0 192.168.1.99:58735 64.94.18.122:443 TIME_WAIT -
tcp 0 816 192.168.1.99:8099 81.219.175.201:63574 ESTABLISHED -
udp 0 0 192.168.1.99:123 0.0.0.0:* -
udp 0 0 127.0.0.1:123 0.0.0.0:* -
udp 0 0 0.0.0.0:123 0.0.0.0:* -
Why do you have so many servers binding on the localhost (127.0.0.1) rather than inaddr_any (0.0.0.0)?

You can't connect outside your localhost if you do that, not even from your local LAN.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

eccentricdyslexic
Posts: 157
Joined: Thu Jul 18, 2013 6:13 am
Location: Uttoxeter, Staffordshire, UK

Re: Motion - MMAL camera

Mon Apr 07, 2014 3:11 pm

Thanks Doughie.

But errrr... your guess is as good as mine! How do I resolve this? It was working fine until the other day.

Cheers

Steve

User avatar
DougieLawson
Posts: 37604
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Motion - MMAL camera

Mon Apr 07, 2014 3:13 pm

eccentricdyslexic wrote:Thanks Dougie.

But errrr... your guess is as good as mine! How do I resolve this? It was working fine until the other day.

Cheers

Steve
You'll have to look at the config where it defines what interface & port to bind to.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

eccentricdyslexic
Posts: 157
Joined: Thu Jul 18, 2013 6:13 am
Location: Uttoxeter, Staffordshire, UK

Re: Motion - MMAL camera

Mon Apr 07, 2014 3:28 pm

I found this-

# URL to use if you are using a network camera, size will be autodetected (incl http:// ftp:// mjpg:// or file:///)
# Must be a URL that returns single jpeg pictures or a raw mjpeg stream. Default: Not defined
;netcam_url http://127.0.0.1/cgi-bin/raspicam.sh

Is that any help? I am using a raspberry pi camera though.

Steve

justinzane
Posts: 2
Joined: Thu Mar 20, 2014 8:53 pm

Re: Motion - MMAL camera

Tue Apr 08, 2014 10:58 pm

dozencrows wrote:
justinzane wrote: I've been googling for a while but I cannot find the sources for the motion-mmal patch/plugin. Could you kindly post the git/mercurial/svn/bzr repo url for it. Thanks.
The URL is present several times already in this very thread... but just to help - https://github.com/dozencrows/motion/tree/mmal-test
Thanks.

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

Re: Motion - MMAL camera

Mon Apr 21, 2014 4:13 pm

If you've been using my modified version of motion, you might be interested in this new thread about some optimisations: http://www.raspberrypi.org/forums/viewt ... 98#p538398.

andies
Posts: 141
Joined: Mon Nov 11, 2013 8:12 pm
Location: Berlin

Re: Motion - MMAL camera

Mon Apr 21, 2014 7:14 pm

If one uses a mask file (pgm) for detection - does this decrease CPU usage? Does anybody have some experience on that?
raspberry B, Noir camera, Mac Book Air, iPhone, Bezzera

caporeira
Posts: 73
Joined: Sun Aug 25, 2013 5:58 pm

Re: Motion - MMAL camera

Sun Apr 27, 2014 6:22 am

How can I disable automatically start Motiom MMAL ?

User avatar
DougieLawson
Posts: 37604
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Motion - MMAL camera

Sun Apr 27, 2014 7:33 am

If it's done in /etc/init.d then
sudo update-rc.d motion disable
or
sudo update-rc.d motion remove

should stop it from being automatically started.
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

caporeira
Posts: 73
Joined: Sun Aug 25, 2013 5:58 pm

Re: Motion - MMAL camera

Sun Apr 27, 2014 8:34 am

[email protected] ~ $ sudo update-rc.d motion disable
update-rc.d: using dependency based boot sequencing
update-rc.d: error: cannot find a LSB script for motion
[email protected] ~ $ sudo update-rc.d motion remove
update-rc.d: using dependency based boot sequencing
[email protected] ~ $
After reboot Motion still running :(

User avatar
DougieLawson
Posts: 37604
Joined: Sun Jun 16, 2013 11:19 pm
Location: Basingstoke, UK
Contact: Website Twitter

Re: Motion - MMAL camera

Sun Apr 27, 2014 10:28 am

caporeira wrote:
[email protected] ~ $ sudo update-rc.d motion disable
update-rc.d: using dependency based boot sequencing
update-rc.d: error: cannot find a LSB script for motion
[email protected] ~ $ sudo update-rc.d motion remove
update-rc.d: using dependency based boot sequencing
[email protected] ~ $
After reboot Motion still running :(
Then you need to look at how it's being started at boot time.

Is there something in /etc/rc.local?
Is there an entry in a crontab?
Note: Having anything humorous in your signature is completely banned on this forum. Wear a tin-foil hat and you'll get a ban.

Any DMs sent on Twitter will be answered next month.

This is a doctor free zone.

RPi85
Posts: 26
Joined: Fri Dec 27, 2013 10:42 pm

Re: Motion - MMAL camera

Sun Apr 27, 2014 11:19 am

/etc/default/motion

That's where it autostarts on my Pi.

ianj
Posts: 21
Joined: Mon May 12, 2014 2:24 am

Re: Motion - MMAL camera

Mon May 12, 2014 2:37 am

While this has likely been answered before, I keep digging up conflicting information from posts made in 2013.

Can this version of motion (or any version) capture 720p video at 30fps upon detection? It seems to be possible from every spec I've read, and it works through raspivid, but motion always results in low res and extremely low fps video, and stills with no actual changes.

Any thoughts or tips would be greatly appreciated. Running the latest Wheezy, firmware is up to date, mmal motion (not the test version), gpu at 128.

Thanks!

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

Re: Motion - MMAL camera

Mon May 12, 2014 1:12 pm

You might want to try my Pi-specific optimisations described in this thread - http://www.raspberrypi.org/forums/viewt ... 98#p538398.

motion originally does all its image processing and encoding on the CPU side, which is very expensive on the Pi even with overclocking - hence why in reality you see low framerates and low resolutions, even though the camera can capture at much higher rates and quality

The thread linked above concerns an alternative method where the camera is set to capture at high resolution, then the GPU downsizes the image for the motion detection part while the high resolution image is passed through and is encoded and saved to a file if motion is found in the low resolution image. This reduces the CPU load and enables higher resolutions and frame rates, but as the CPU is still used to encode images for output to JPEG or AVI, it still isn't amazing.

There's a further optimisation also done where the GPU also encodes the high resolution image in JPEG format, for saving as individual files or streaming in MJPEG format. This reduces the CPU load still further - currently 15fps is achievable for images close to the 720p resolution size.

ianj
Posts: 21
Joined: Mon May 12, 2014 2:24 am

Re: Motion - MMAL camera

Mon May 12, 2014 3:46 pm

dozencrows wrote:You might want to try my Pi-specific optimisations described in this thread - http://www.raspberrypi.org/forums/viewt ... 98#p538398.

motion originally does all its image processing and encoding on the CPU side, which is very expensive on the Pi even with overclocking - hence why in reality you see low framerates and low resolutions, even though the camera can capture at much higher rates and quality

The thread linked above concerns an alternative method where the camera is set to capture at high resolution, then the GPU downsizes the image for the motion detection part while the high resolution image is passed through and is encoded and saved to a file if motion is found in the low resolution image. This reduces the CPU load and enables higher resolutions and frame rates, but as the CPU is still used to encode images for output to JPEG or AVI, it still isn't amazing.

There's a further optimisation also done where the GPU also encodes the high resolution image in JPEG format, for saving as individual files or streaming in MJPEG format. This reduces the CPU load still further - currently 15fps is achievable for images close to the 720p resolution size.
Gotcha. Thanks for the reply! Your updated test build is what I was referring to before :)

I'll check it out and see what changes. Do you think GPU strain would be dramatically reduced if only video were captured as opposed to both?

Would disabling the browser based streaming, or creating an setting for lower resolution broadcast be possible? At the moment all I can find is one resolution setting, which leads me to believe I've missed something. So for example, browser MJPEG stream is at 360p, motion capture saved as video at 720p30, all based on your test version using those low-res previews for motion detection.

tgwaste
Posts: 46
Joined: Thu Jan 31, 2013 7:15 pm

Re: Motion - MMAL camera

Sun May 18, 2014 10:58 pm

My camera is zoomed all the way in with motion. Is there any way to zoom it out?
I know some kind of zoom is possible because when I use raspistill the preview shows the images zoomed in and then for a second shows it zoomed out.

any ideas?

recurry
Posts: 6
Joined: Wed May 07, 2014 11:34 pm

Re: Motion - MMAL camera

Wed May 28, 2014 5:23 am

dozencrows wrote:The URL is present several times already in this very thread... but just to help - https://github.com/dozencrows/motion/tree/mmal-test
Yes, it has been posted a few times but it's pretty well hidden. It also says in the readme that files are missing and that it's not possible to compile what you have up there. Also, in looking through the code it appears it may be just test code rather than the full functional code. Perhaps you could clarify that. Anyhow, thank so much for your effort on this. It looks like a lot of effort judging from the changes. It would be great though (and consistent with the license) if you would provide the complete compilable sources or at least some instructions so we can use what's up there to generate the binary. That way we can add to your effort. It would also be great to merge your changes into the mainline motion codebase perhaps in the form of a patch or conditionals so the RPI could leverage the continuing improvements the motion team is making!

Thanks again!

Best,
Ron

Update: My apologies for not doing enough homework on this. Dozencrows has all the instructions for doing compiles and generating a binary in the repository. It takes some git gyrations but it all works fine and I've been able to make some tweaks and compile without issue. Eventually, it would be nice to have the RPi stuff integrated in the standard motion package but that takes a lot more work and I'm very appreciative for what Dozencrows has given us here!
Last edited by recurry on Fri May 30, 2014 4:59 pm, edited 1 time in total.

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

Re: Motion - MMAL camera

Thu May 29, 2014 8:30 am

@ianj: GPU strain isn't the issue here - the bottleneck is the work being done on the CPU. motion-mmal only captures either video or stills, not both at the same time.

Browser based streaming can be disabled if you set the port for the streaming to zero in the config file, I think. It also doesn't take up any CPU if there's no browser connected.

There is only one resolution setting, but effectively there are two because of the secondary buffer option (though that is a multiplier). The streaming output can select either the primary or secondary buffer as output; if you select primary then the resolution will match the original settings, if you select secondary then the resolution will be the higher-res secondary image. That's how you can have a lower-res streaming image.

If you have the primary buffer for streaming, this will be encoded on the CPU, which can be a performance hit. If you set the secondary buffer to the GPU encoded JPEG mode, then this gets passed straight through reducing the CPU load - but as the resolution is higher, it uses more network bandwidth.

It would be possible to add a tertiary buffer via the MMAL API that could also be encoded to JPEG on the GPU and used for the streaming; this could be a different multiple of the original image resolution and thus could be both smaller and save CPU load. Probably worth a try - however right now I can't make any promises about working on it due to lack of time. Could be an interesting exercise "for the reader" ... :)

@recurry: apologies for any confusion... I think the README is out of date. I've been focussed on improving the code ;) The complete code is in the mmal-test branch of Github and has been for quite a while; it is buildable, and there are instructions in the BUILD-HOWTO file.

The code is also fully functional - it is reasonably well structured, and in keeping with the style of the rest of motion so could be the subject of a pull request on the original repo. However I think that is a mirror of the main code in SVN, so I don't know if the original developers will pay attention to it. But at least the code is out in the public domain anyway, which is the most important thing!

eccentricdyslexic
Posts: 157
Joined: Thu Jul 18, 2013 6:13 am
Location: Uttoxeter, Staffordshire, UK

Re: Motion - MMAL camera

Sun Jun 01, 2014 7:34 am

Clouds/brightness changes over gravel driveway triggering motion. Hi peeps, is there anyway I can reduce the unintended triggering when clouds overhead cast shadows and trigger my motion rpi camera?

Cheers

Steve

sjmsoftware
Posts: 4
Joined: Wed Oct 02, 2013 6:21 pm

Re: Motion - MMAL camera

Tue Jun 03, 2014 10:20 pm

@dozencrows - my pi runs an rpi-update nightly cron and it looks like motion-mmal is now using a larger field of view for detection and preview and this is resulting in false positives. I'm guessing its now using latest firmware updates that include the new camera modes. Is there anything I can feed into the options to tell it to use the smaller FOV?

Thanks in advance.

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

Re: Motion - MMAL camera

Sun Jun 08, 2014 10:46 am

You could try experimenting with different resolutions to see if that affects the cropping - the latest code should allow a greater range of working resolutions than listed in the out-of-date readme. As long as width and height are both a multiple of 16.

You could also create a mask image to prevent detection in the expanded field of view area - see http://www.lavrsen.dk/foswiki/bin/view/ ... onMaskFile. The size of this mask image should be the same as the width and height you specify in the motion config file.

sjmsoftware
Posts: 4
Joined: Wed Oct 02, 2013 6:21 pm

Re: Motion - MMAL camera

Sun Jun 08, 2014 5:56 pm

dozencrows wrote:You could try experimenting with different resolutions to see if that affects the cropping - the latest code should allow a greater range of working resolutions than listed in the out-of-date readme. As long as width and height are both a multiple of 16.

You could also create a mask image to prevent detection in the expanded field of view area - see http://www.lavrsen.dk/foswiki/bin/view/ ... onMaskFile. The size of this mask image should be the same as the width and height you specify in the motion config file.
Thanks @dozencrows. Alas, I tried a number of different options setting the resolution in your motion.conf file but I can't get preview or video captures that resemble the partial field of view. If I run raspivid manually from the command line with -w and -h then the resolution is used. However, from MMAL I couldn't get it to work. Here is what I have configured:

Code: Select all

# Rotate image this number of degrees. The rotation affects all saved images as
# well as movies. Valid values: 0 (default = no rotation), 90, 180 and 270.
rotate 90

# Image width (pixels). Valid range: Camera dependent, default: 352
width 640

# Image height (pixels). Valid range: Camera dependent, default: 288
height 480

# Maximum number of frames to be captured per second.
# Valid range: 2-100. Default: 100 (almost no limit).
framerate 2

# Minimum time in seconds between capturing picture frames from the camera.
# Default: 0 = disabled - the capture rate is given by the camera framerate.
# This option is used when you want to capture images at a rate lower than 2 per second.
minimum_frame_time 1

############################################################
# File "camera" support - read raw YUV data from a file
############################################################
#filecam_path /home/pi/test-cap/motion-mmal.capture

############################################################
# OpenMax/MMAL camera support for Raspberry Pi
############################################################
mmalcam_name vc.ril.camera
mmalcam_control_params -w 640 -h 480
#mmalcam_raw_capture_file /home/pi/motion-mmal.capture

# Switch this setting to "on" to use the still image mode of the Pi's camera
# instead of video. This gives a wider field of view, but requires
# a much slower frame-rate to achieve exposure stability
# (e.g. 0.25 fps or slower). You can use the minimum_frame_time
# parameter above to achieve this

mmalcam_use_still off
I'd like to avoid using the mask file if at all possible. Any pointers or assistance would be appreciated.

grats
Posts: 30
Joined: Fri Apr 25, 2014 6:51 am
Location: Colorado, USA

Re: Motion - MMAL camera

Sun Jun 08, 2014 8:03 pm

Any idea why I can't write to a mounted drive?

this includes all of my commands for the drive & motion errors:

Image

So I've obviously gone to the point where it wasn't working so I allowed everything fully access and made motion the actual owner of the mounted drive, still getting errors..?

I don't care where the usb drive is mounted or what has access to it... I just want to write to it instead of my SD card.

Any ideas on this?

Return to “Camera board”