There's a gentleman over at the Raspberry Pi forums who has broken down the example code and figured out the MMAL API that is being used. The thread with all of his info is here: http://www.raspberrypi.org/phpBB3/viewtopic.php?t=44982&p=356842.
I am attempting to make a node for the Raspberry Pi camera as well so I've been working on this for a little while.
EDIT: I found a solution that works pretty well using existing software! Here are the steps that are required:
- Get the Raspberry Pi UV4L camera driver from www.linux-projects.org.
- Download
gencam_cu
from http://prairiedog.googlecode.com/svn/trunk/gencam_cu/ (this is still a dry package so you'll have to create a separate rosbuild workspace, overlay it on your catkin workspace using the instructions at http://wiki.ros.org/catkin/Tutorials/using_rosbuild_with_catkin and build it using rosmake [BUT DON'T BUILD YET]).
- Modify
gencam_cu
to include a link to the uv4l driver at build-time by modifying ~/rosbuild_ws/gencam_cu/src/CMakeLists.txt. Add the line link_directories(/usr/lib/uv4l/uv4lext/armv6l/)
at the top and the line target_link_libraries(gencam_cu uv4lext)
at the end.
- Now you can
rosmake gencam_cu
.
- Launch the uv4l driver using
uv4l --driver raspicam --auto-video_nr --width 640 --height 480 --nopreview
which will create an MJPEG-based camera at /dev/videoX (where X is auto-incremented starting at 0).
- Launch
roscore
, then rosrun gencam_cu gencam_cu
.
I get about 16-18 fps at 640x480 and you get compressed image streams!
Originally posted by Josh Whitley with karma: 1766 on 2013-06-22
This answer was NOT ACCEPTED on the original site
Post score: 2
Original comments
Comment by Marco Poli on 2013-07-05:
It will be greatly appreciated!:)
Comment by kalectro on 2013-08-13:
any progress on this? Maybe a github repo? I would be willing to contribute
Comment by Josh Whitley on 2013-08-13:
The problem so far has been that the conversion from the camera's YUV stream to an RGB stream (needed for ROS) has caused too much overhead. However, Broadcom has recently modified the RPi firmware to allow this in the GPU. I've got an app that outputs a raw YUV stream (next comment)
Comment by Josh Whitley on 2013-08-13:
https://github.com/circpeoria/raspividYUV - This just needs to now output RGB. See the updated raspistillYUV with the -rgb option from Userland on how to accomplish this (though I've been unable to so far). Once this is added to my app, we should be able to wrap it up in C++ and make a node.
Comment by Josh Whitley on 2013-08-13:
FYI - my app may be missing the vcos_semaphore that is necessary at the end of each frame since it isn't being run through the encoder. Can't remember - it's been a little while since I worked on it.
Comment by kalectro on 2013-08-13:
thanks, I will look into it
Comment by joq on 2013-08-13:
A ROS driver could publish a "yuv422" encoding instead of "rgb8". Maybe conversion from YUV420p to YUV422 would be easier. (I don't know whether the ROS image pipeline handles that correctly or not.)
Comment by machack on 2013-09-02:
There is a node that I've been developping for the camera module of the raspberry pi.
The node is designed to output images in jpeg format to a topic. More information can be obtained from http://www.raspberrypi.org/phpBB3/viewtopic.php?f=43&t=54092