Page 1 of 19

Motion - MMAL camera

Posted: Sat May 25, 2013 11:06 am
by dozencrows
I've had some success writing a new module for Motion that reads frames directly from the Pi camera via the MMAL API. A test binary and config file is available here: https://www.dropbox.com/s/xdfcxm5hu71s9 ... mal.tar.gz

This binary is based on Motion SVN trunk at revision 557, and is compiled without MySQL, PostgreSQL or SDL support. Because it's based on trunk and not the 3.2 release branch, the syntax for the config file is different to the available documentation on the Motion wiki.

Next likely steps with this are:
* Tidy up, make command line build work and share the source publically.
* Add an option to support Pi camera settings available in raspivid/raspistill.
* Try optimising some obvious hotspots for the Pi (in reference frame tuning and frame difference code).

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 11:27 am
by bjornatic
Hi !

Would it be to much to ask for a little step by step tutorial or if, by asking, I suggest I would not be able to make it work anyway ? :D

Even just global hints would do...

Thanks !

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 11:34 am
by fturiot
thanks for your good job
can you send me your patch and option compilation
I would like compil and generate deb
thanks

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 11:57 am
by yusuk
How can I test this?

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 12:27 pm
by dozencrows
@bjornatic - you can find out lots of information about using Motion here: http://www.lavrsen.dk/foswiki/bin/view/Motion/WebHome. Most of the information should apply to this version of motion, as the only part I have modified is the image capture side (and not compiled in the SQL database support).

Please also read through the example .conf file in the tarball to work out where the syntax differs from the documentation. Note that these differences are not down to me, they've been done by the actual motion developers (see http://www.lavrsen.dk/foswiki/bin/view/Motion/RoadMap). I've added one option "mmalcam_name" that is used to provide the camera's ID - this should be "vc.ril.camera" to work with the Pi camera.

If you're having a specific issue with Motion when using the MMAL camera module, please post details ideally attaching your .conf file and the command line arguments you're using.

@fturiot - the code's not quite ready to deliver as a deb, there's a few changes still to make and I need to test a bit more (e.g. with latest Raspian updates and firmware). I'm planning to put it all up on Github in the next few days so that should give you what you need.

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 1:13 pm
by fturiot
ok thanks,
I have problem with libjbeg with Motion of you compil.
fred

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 1:23 pm
by dozencrows
fturiot wrote:ok thanks,
I have problem with libjbeg with Motion of you compil.
fred
Which version of libjpeg to you have installed?
When I run this on my Pi:

Code: Select all

find /usr/lib -iname libjpeg*
I get

Code: Select all

/usr/lib/arm-linux-gnueabihf/libjpeg.a
/usr/lib/arm-linux-gnueabihf/libjpeg.so.8
/usr/lib/arm-linux-gnueabihf/libjpeg.so.8.4.0
/usr/lib/arm-linux-gnueabihf/libjpeg.la
/usr/lib/arm-linux-gnueabihf/libjpeg.so.62.0.0
/usr/lib/arm-linux-gnueabihf/libjpeg.so.62
/usr/lib/arm-linux-gnueabihf/libjpeg.so
What do you get?

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 1:35 pm
by fturiot
i have this

Code: Select all

/usr/lib/arm-linux-gnueabihf/libjpeg.so.8
/usr/lib/arm-linux-gnueabihf/libjpeg.so.8.4.0
/usr/lib/arm-linux-gnueabihf/libjpeg.so
/usr/lib/arm-linux-gnueabihf/libjpeg.a

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 1:37 pm
by dozencrows
Try installing libjpeg62 via

Code: Select all

sudo apt-get install libjpeg62
That's what the test binary is linking against.

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 1:41 pm
by fturiot
yes ok but why not work with lipjpeg8 ?
any raisons ?
thanks for all
fred

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 1:43 pm
by dozencrows
It may well work with libjpeg8 - I will have to try it.
libjpeg62 is listed as the dependent package for Debian in the Motion wiki, which is why I used it - see http://www.lavrsen.dk/foswiki/bin/view/ ... or_Install

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 1:46 pm
by fturiot
ok thanks for all.

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 2:34 pm
by fturiot
it's work but 3/4 min i have freezing of soc broadcom and i must reboot.
I test for reduce picture width.
fred

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 3:11 pm
by craigc
Hi, Thanks for the updated version, the rotation works well.

I'll leave it running and let you know if I spot any problems.

Craig.

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 3:15 pm
by dozencrows
@bjornatic, @yusuk - my apologies - I suspect you're wanting information on how to install and run my test version, which I haven't made clear.

I would recommend trying the following:
1. Install the standard Raspbian motion package via apt-get. This should add all the dependencies.

2. Unzip the motion-mmal tarball into your home folder.

3. Try running motion from your home folder -

Code: Select all

./motion -h
If that works, you should get the help text for the tool.

4. Then try running it with the provided config file -

Code: Select all

./motion -n -c motion-mmalcam.conf
. This should work - test it out by checking the webcam feed on your Pi on port 8081.

If you have a problem with libjpeg, see the post above about installing libjpeg62.

Let me know if you have any issues - please provide relevant details (e.g. command lines, changes to .conf files, error messages).

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 3:37 pm
by bjornatic
This is super nice from you ! Thanks.

I'll try it out asap and let you know. :)

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 3:41 pm
by yusuk
great!! motion is working with csi camera module.
I'll feed back after testing more.

My Pi is rev.b and wifi connected.
The latency is less than using vlc. But the framerate is about 1frame per second.

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 4:19 pm
by bjornatic
All working this is great !! Thanks again :D

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 5:03 pm
by fturiot
i have always freeze with motion with model b rev 2 on raspbian last.
I test with minimal raspbian img.
fred

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 5:18 pm
by dozencrows
Hi fred - sorry to hear you're getting these problems. I personally haven't been experiencing freezes, and have had motion-mmal running for half an hour successfully (then stopped it myself).

Please supply a copy of your motion config file and command line if these are changed, so I can try them.

Are you using the latest Raspbian and firmware updates? What hardware do you have plugged in to your Pi's USB ports?

BTW I'm working on getting the source up to GitHub...

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 5:37 pm
by dozencrows
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.

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 7:28 pm
by dpguest
How do I install the test version on the pi? You indicate there is no ability to make that is build the software, but I assume the prebuilt components are there. What specific steps do I need to follow to install and then proceed to test ...

thanks from a neophyte...

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 7:33 pm
by dozencrows
Hi dpguest - please see my post above here for that info: http://www.raspberrypi.org/phpBB3/viewt ... 14#p356814

You can get the tarball containing the binary and config file from the first post in this thread.

I'm working on the command line build for the Github source at the moment - will post when that's available.

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 8:49 pm
by dpguest
thanks much for your prompt reply ... I'll try to follow your instructions.

have a nice day...

Re: Motion - MMAL camera

Posted: Sat May 25, 2013 9:08 pm
by mahtiaivo
i could not find an option to mirror the picture vertically, did i miss it?

thought there was some discussion on the motion site and even a patch, it seems it's not in the actual motion version included...
http://www.lavrsen.dk/foswiki/bin/view/ ... irrorPatch