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

Re: Motion - MMAL camera

Sun May 26, 2013 11:10 am

@mahtiaivo - no, you didn't miss the option as that patch isn't in the original motion's trunk or 3.2 release code. My goal is to focus on core functionality relating to the Pi camera, so I won't be considering bringing over patches at this time.

However I do plan to expose the Pi camera controls via an config file option as they are in raspivid/raspistill, so mirroring should be achievable through those options.

skooby
Posts: 23
Joined: Sun Feb 12, 2012 1:50 pm

Re: Motion - MMAL camera

Sun May 26, 2013 1:51 pm

Hi all,

Looking for a little help with this please. I am very new to linux so its probably something I am doing wrong. Anyway, my camera works fine with raspistill so I know its working.

I followed the instructions above and installed motion and then copied the 2 files across to the home directory. I have also updated the libjpeg file. When I run motion with : sudo motion -n -c motion-mmalcam.conf I get the error:
Failed to open device /dev/video0: no such file or directory.

It tries a few times then gives up. The camera led is off.

Ayone able to tell me what I have done wrong?

Thanks

Skooby

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

Re: Motion - MMAL camera

Sun May 26, 2013 2:05 pm

Hi skooby - try running using this command line in the same directory:

Code: Select all

./motion -n -c motion-mmalcam.conf
Note the ./ at the start - this is important as it ensures the MMAL version of motion is run, and not the installed version. Also, you shouldn't need to use sudo.

The command line you've given will run the installed version of motion as the root user (which is what sudo does) - it then won't understand the MMAL specific camera option in the config file, so will try to use the default camera option (dev/video0 in this case) and will fail.

skooby
Posts: 23
Joined: Sun Feb 12, 2012 1:50 pm

Re: Motion - MMAL camera

Sun May 26, 2013 2:10 pm

Thanks for the quick response. I had tried that before but got a no premissions error. I now did a chmod 755 on the 2 files and it appears to run,or at least I get no errors and the red led is on. Now to check the stream.

Thanks

skooby

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

Re: Motion - MMAL camera

Sun May 26, 2013 2:32 pm

dozencrows wrote:Ok, the source is now up on Github at this URL: https://github.com/dozencrows/motion

The master branch is an untouched fork of the original; all the MMAL changes are in the branch mmal-test. Note that this is currently just a drop of the configured source - there's no means provided yet for building the code.
I've now updated the mmal-test branch on GitHub with a few small fixes, a cmake build script and a short "how-to" file on building - both directly on a Pi, and also using cross-compilation on a Linux PC. I've tested the cmake build in a clean directory on a Pi, and it worked ok.

If you try it, please let me know how you get on, and whether there are any corrections needed to the how-to or cmake script.

dpguest
Posts: 28
Joined: Wed Feb 06, 2013 4:17 pm

Re: Motion - MMAL camera

Sun May 26, 2013 2:53 pm

Followed your instructions and I now see the stream on a web browser at 8081.... neat, thank you.

Now I have to read the motion documentation to find out how to use it....

thanks again and have a nice day...

David Guest

mahtiaivo
Posts: 8
Joined: Sat May 25, 2013 9:05 pm

Re: Motion - MMAL camera

Sun May 26, 2013 6:55 pm

compiled it on the rpi, works fine!
thanks :mrgreen:

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

Re: Motion - MMAL camera

Sun May 26, 2013 8:02 pm

Thanks mahtiaivo!

I've committed a change to GitHub to add a new parameter to the .conf file: mmalcam_control_params. This takes a list of camera control options in the same way as raspivid/raspistill, so you can adjust exposure, white balance, apply effects, etc. I have disabled the automatic horizontal flip in the code, but included it in the updated motion-mmalcam.conf file.

Note that the options supported are just those listed as "camera control options" in the RaspiCam documentation - the preview and application specific settings are not supported.

I've also uploaded a new binary and conf file to Dropbox: https://www.dropbox.com/s/xdfcxm5hu71s9 ... mal.tar.gz
Last edited by dozencrows on Mon Jun 24, 2013 1:11 pm, edited 1 time in total.

drmaples
Posts: 1
Joined: Sun May 26, 2013 9:02 pm

Re: Motion - MMAL camera

Sun May 26, 2013 9:07 pm

dozencrows - i got this setup and it works great, thanks for all the hard work! let me know if there is any way i can help make this even more awesome.

peewee2
Posts: 57
Joined: Sun Apr 14, 2013 7:04 pm

Re: Motion - MMAL camera

Sun May 26, 2013 11:39 pm

Magic, well done

It took me less than 5 minutes to implement your fix.

Thanks again

Pete

heliobteixeira
Posts: 3
Joined: Thu May 09, 2013 10:08 am

Re: Motion - MMAL camera

Sun May 26, 2013 11:55 pm

Thanks a lot for the post! Amazing the things ppl like can do...
I'm having this small issue, when detecting movement, cam led goes on and off constantly...any ideia whats wrong?
How can I debug whats happening?
Best Regards

dpguest
Posts: 28
Joined: Wed Feb 06, 2013 4:17 pm

Re: Motion - MMAL camera

Mon May 27, 2013 10:10 am

check your power supply ... I was using a .7amp power supply and had the same problem. Once I switched to a 1.5amp power supply the problem went away...

mahtiaivo
Posts: 8
Joined: Sat May 25, 2013 9:05 pm

Re: Motion - MMAL camera

Mon May 27, 2013 9:51 pm

@dozencrows

excellent!
works also very fine with:
mmalcam_control_params -ex night

thanks! :mrgreen:

skooby
Posts: 23
Joined: Sun Feb 12, 2012 1:50 pm

Re: Motion - MMAL camera

Tue May 28, 2013 2:22 pm

Just wanted to say a big THANKS to dozencrows for his work on getting this ported to the pi. I now have a cctv system up and running. Just need to find a waterproof box to fit the camera in and I will be all the road.

skooby

M_P
Posts: 43
Joined: Sun Jan 06, 2013 5:40 pm

Re: Motion - MMAL camera

Tue May 28, 2013 11:44 pm

Hey Dozencrows - this works like a charm for me. Uptime of three days and counting.

Thank you very much for all your work on this, very much appreciated!!!

hitman80
Posts: 18
Joined: Sun Nov 04, 2012 5:55 pm

Re: Motion - MMAL camera

Wed May 29, 2013 5:43 am

thanks @Dozencrows

It works. I used two files that you have linked . I modified file .CONF removing lines for motion detect that I don't use at this moment...

I have a question.... Is possibile use this versione of motion as a daemon/service or with a script at the boot of PI... I tried to insert the command with & in /etc/rc.local but it doesn't work ... Not installing I think there is an option to install as a service ?

Can you suggest me how to do ?

thanks

howarthc
Posts: 5
Joined: Sun Mar 31, 2013 3:43 pm

Re: Motion - MMAL camera

Wed May 29, 2013 11:36 am

Hi there, long time user of motion on raspi, always found it easy to work with. Been following the instructions here. I have...
  • Installed and tested the camera module
    Replaced the motion binary
    Installed libjpeg62
    replaced the motion.conf with the one included with the binary
Starting it up I can't connect to 8081

In my messages log I get:

Code: Select all

May 29 11:31:45 raspberrypi motion: [1] [NTC] [VID] vid_v4lx_start: Using videodevice /dev/video0 and input -1
May 29 11:31:45 raspberrypi motion: [1] [WRN] [ALL] motion_init: Could not fetch initial image from camera Motion continues using width and height from config file(s)
May 29 11:31:45 raspberrypi motion: [1] [NTC] [ALL] image_ring_resize: Resizing pre_capture buffer to 1 items
May 29 11:31:50 raspberrypi motion: [1] [WRN] [ALL] motion_loop: Retrying until successful connection with camera
... repeats

In my syslog

Code: Select all

May 29 11:33:30 raspberrypi motion: [1] [NTC] [VID] vid_v4lx_start: Using videodevice /dev/video0 and input -1
May 29 11:33:30 raspberrypi motion: [1] [ALR] [VID] vid_v4lx_start: Failed to open video device /dev/video0:
May 29 11:33:40 raspberrypi motion: [1] [WRN] [ALL] motion_loop: Retrying until successful connection with camera
The system is fully up to date. Not sure what I am doing wrong?
Any hints appreciated.

Chris

craigc
Posts: 8
Joined: Mon Jan 23, 2012 12:17 pm
Location: Berkshire, UK

Re: Motion - MMAL camera

Wed May 29, 2013 11:41 am

howarthc wrote:Hi there, long time user of motion on raspi, always found it easy to work with. Been following the instructions here. I have...
  • Installed and tested the camera module
    Replaced the motion binary
    Installed libjpeg62
    replaced the motion.conf with the one included with the binary
Starting it up I can't connect to 8081

In my messages log I get:

Code: Select all

May 29 11:31:45 raspberrypi motion: [1] [NTC] [VID] vid_v4lx_start: Using videodevice /dev/video0 and input -1
May 29 11:31:45 raspberrypi motion: [1] [WRN] [ALL] motion_init: Could not fetch initial image from camera Motion continues using width and height from config file(s)
May 29 11:31:45 raspberrypi motion: [1] [NTC] [ALL] image_ring_resize: Resizing pre_capture buffer to 1 items
May 29 11:31:50 raspberrypi motion: [1] [WRN] [ALL] motion_loop: Retrying until successful connection with camera
... repeats

In my syslog

Code: Select all

May 29 11:33:30 raspberrypi motion: [1] [NTC] [VID] vid_v4lx_start: Using videodevice /dev/video0 and input -1
May 29 11:33:30 raspberrypi motion: [1] [ALR] [VID] vid_v4lx_start: Failed to open video device /dev/video0:
May 29 11:33:40 raspberrypi motion: [1] [WRN] [ALL] motion_loop: Retrying until successful connection with camera
The system is fully up to date. Not sure what I am doing wrong?
Any hints appreciated.

Chris
Hi,

Not an expert on this but it looks like it has a rogue config file, trying to attach to video0 which won't exist.

I had something similar, I can't access the pi to get the exact path but there were multiple montion.conf's on my machine and I used the option to point motion to the correct conf file to make sure. (syntax is further up the thread.)

whereis motion.conf

will show you all the files laying around.

Craig.

howarthc
Posts: 5
Joined: Sun Mar 31, 2013 3:43 pm

Re: Motion - MMAL camera

Wed May 29, 2013 12:36 pm

craigc wrote: I had something similar, I can't access the pi to get the exact path but there were multiple montion.conf's on my machine and I used the option to point motion to the correct conf file to make sure. (syntax is further up the thread.)
Craig.
Craig, thanks for getting back to me. I tried moving all my "backup" snapshots to an archive directory and just left motion.conf in /etc/motion and still had the same problem. I also tried running the binary directly and specifying the conf file on the command line with -c. Nothing seems to work. Frustrating.

Chris

peewee2
Posts: 57
Joined: Sun Apr 14, 2013 7:04 pm

Re: Motion - MMAL camera

Wed May 29, 2013 3:00 pm

You can use the strace command to see what files are being opened by an executable, see below.

As you can see motion never attempts to open /etc/motion/motion.conf.

just put the file in /etc and it will work.

Code: Select all

strace -e trace=open motion
.....
open("/usr/lib/arm-linux-gnueabihf/libstdc++.so.6", O_RDONLY) = 3
open("/lib/arm-linux-gnueabihf/libgpg-error.so.0", O_RDONLY) = 3
open("/root/motion.conf", O_RDONLY)     = -1 ENOENT (No such file or directory)
open("/root/.motion/motion.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/etc/motion.conf", O_RDONLY)      = -1 ENOENT (No such file or directory)
open("/etc/localtime", O_RDONLY)        = 3
.....
Pete

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

Re: Motion - MMAL camera

Wed May 29, 2013 8:17 pm

Hi Chris/@howarthc!

It may be worth triple-checking that you're definitely running my modified motion binary - if somehow you're running an unmodified motion binary with the MMAL camera config file, it won't understand the mmalcam options and will default to trying /dev/video0 instead. Try a fresh unzip of the tarball into a new directory, cd to that directory and verbatim do:

Code: Select all

./motion -n -c motion-mmalcam.conf
and see how that works.

mahtiaivo
Posts: 8
Joined: Sat May 25, 2013 9:05 pm

Re: Motion - MMAL camera

Thu May 30, 2013 12:23 pm

hi all,

it happens on all my Raspberry Pi's with the camera modul sometimes too...
what i did was taking a photo first with raspistill and the starting the modified motion binary.
seems like it needs some sort of initialisation?

:)

jum
Posts: 19
Joined: Wed Mar 20, 2013 12:18 pm

Re: Motion - MMAL camera

Thu May 30, 2013 1:15 pm

Hi dozencrows, thanks for adding rpi camera support to motion.

It partially works for me, runs for about 30 seconds (captures pictures at the default .conf resolution of 1024 x 576) and then freezes the RPi. I can start another terminal session (Ctrl-Alt-F2), run "top", see the CPU usage is quite high (75%), then after another 30 seconds the system freezes completely.

Have done apt-get update and upgrade (to install camera module) on stock Raspian. Will try run raspistill before running motion. If all else fails I will get latest from github and build.

craigc
Posts: 8
Joined: Mon Jan 23, 2012 12:17 pm
Location: Berkshire, UK

Re: Motion - MMAL camera

Thu May 30, 2013 1:44 pm

jum wrote:Hi dozencrows, thanks for adding rpi camera support to motion.

It partially works for me, runs for about 30 seconds (captures pictures at the default .conf resolution of 1024 x 576) and then freezes the RPi. I can start another terminal session (Ctrl-Alt-F2), run "top", see the CPU usage is quite high (75%), then after another 30 seconds the system freezes completely.

Have done apt-get update and upgrade (to install camera module) on stock Raspian. Will try run raspistill before running motion. If all else fails I will get latest from github and build.
As an suggetion try dropping the resolution down to 768x576 (or 640x480) and see if its a bit more stable. I had mine up high to start with but I found it very slow to do anything else on the machine. Overclocking might be your friend if its more stable at the lower resolution.

bjornatic
Posts: 20
Joined: Wed May 15, 2013 4:44 pm

Re: Motion - MMAL camera

Thu May 30, 2013 2:40 pm

I also droped the resolution because of CPU abuse (especialy on the the other pi playing back the MJPG stream via VLC :? ).

So I'm using 768x576 (0.75 ratio), wich, if I use RASPISTILL to take a picture gives me a larger field of view...

How would it be possible to use maximal field of view using motion ? Am I missing something ?

Return to “Camera board”

Who is online

Users browsing this forum: No registered users and 19 guests