Video4Linux2 driver ready!


108 posts   Page 1 of 5   1, 2, 3, 4, 5
by RpiName » Tue Jul 23, 2013 1:24 am
Hello,
to your knowledge, a Video4Linux2 driver for the CSI Camera Board is available here:

http://www.linux-projects.org/modules/news/article.php?storyid=150
Posts: 63
Joined: Sat Jul 06, 2013 3:14 am
by alexeames » Tue Jul 23, 2013 7:27 am
Is this the "official" driver that the Raspberry Pi Foundation have funded? Or have you done this off your own initiative?
My Pi uses 2 watts - what what? ---- HiRes early production Pi photos RS Front Back | Farnell Front Back
User avatar
Posts: 2018
Joined: Sat Mar 03, 2012 11:57 am
Location: UK
by leol » Tue Jul 23, 2013 8:17 am
alexeames wrote:Is this the "official" driver that the Raspberry Pi Foundation have funded? Or have you done this off your own initiative?

On the web site it says"NOTE: The Raspicam module has NOT be funded by the Raspberry Pi Foundation in any way." So I guess he has done this off his own initiative.
User avatar
Posts: 106
Joined: Fri Jan 13, 2012 4:27 pm
Location: Reading, England
by jbeale » Tue Jul 23, 2013 2:27 pm
Has anyone tried this yet? Is the source code for this available? Who wrote this code? I had a look around http://www.linux-projects.org/listing/u ... /raspbian/ but I'm not sure what directory I'm looking for to find the source code. I see in http://www.linux-projects.org/listing/u ... f/Packages that it lists Maintainer: Luca Risolia but is that just V4L in general, or this Raspbian userspace code in particular?

Not to look a gift horse in the mouth, etc. but would like to have a look at the source, before installing.
User avatar
Posts: 1887
Joined: Tue Nov 22, 2011 11:51 pm
by RpiName » Tue Jul 23, 2013 7:21 pm
is that just V4L in general, or this Raspbian userspace code in particular?


I am not sure what you mean by that question, but UV4L consists of a group of Video4Linux2-compliant user space drivers ported to Raspbian. One of those drivers is for the Rpi CSI Camera Board.

From the documentation available on the website:
[1]
DESCRIPTION
UV4L is a simple framework aiming to provide User
space Video4Linux2-compliant drivers for real or virtual video
input devices. The 'uv4l' core daemon loads a given driver module
passed as argument via command line and creates one device node
file under /dev for the applications to access the device. From
the application's perspective, there is no real difference from
when a kernel driver is being used to control the device. You can
run uv4l as many times as the number of the devices you want to
handle (one process per device).


If you read the examples given in the instructions (from a link in the announcement), you will notice that the applications really "just work" transparently, accessing a device node, as if there was an underlying kernel driver, in other words:
http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=14

[1] http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=9
[2] http://www.linux-projects.org/modules/s ... es&secid=2
Posts: 63
Joined: Sat Jul 06, 2013 3:14 am
by jbeale » Tue Jul 23, 2013 9:01 pm
RpiName wrote:I am not sure what you mean by that question, but UV4L consists of a group of Video4Linux2-compliant user space drivers ported to Raspbian. One of those drivers is for the Rpi CSI Camera Board.


Thank you for your quick response. I meant, who is the author of this particular V4L2 driver specifically for the RPi camera? Luca Risolia is shown as "Maintained by:" but I don't know if he is just maintaining the V4L2 system as a whole, and/or he is also the author of this particular driver. Is the source code available?

thanks,
John Beale
User avatar
Posts: 1887
Joined: Tue Nov 22, 2011 11:51 pm
by RpiName » Tue Jul 23, 2013 9:56 pm
Hello John,

the author is the same person; no source code is available from the website.
Posts: 63
Joined: Sat Jul 06, 2013 3:14 am
by jbeale » Wed Jul 24, 2013 1:27 am
As you probably know, both the Raspbian system kernel, and the R-Pi camera firmware are under active development, and code is changing on a weekly basis. If the V4L2 driver is a closed-source project, I'm just wondering about how it might be maintained over the long run.
User avatar
Posts: 1887
Joined: Tue Nov 22, 2011 11:51 pm
by RpiName » Wed Jul 24, 2013 5:11 am
John, again, that V4L2 driver is a 100% user space program; it does not strictly depend on the kernel in any way! In other words, as long as the mmal ABI is stable (isn't it?), unlike a real kernel driver, that driver does not have to be rebuilt each time the kernel or the firmware internals change, if this is what you are wondering about, yet it behaves like a kernel driver in all the ways: the user cannot see the difference. It also means no kernel crashes if a bug occurs, just like any other programs :)
Posts: 63
Joined: Sat Jul 06, 2013 3:14 am
by recantha2 » Wed Jul 24, 2013 6:04 am
It might be worth releasing the source, however, so the Community can help with any bugs that arise or if they think there are any improvements that might be made.
--
Michael Horne - @recantha
Pi blog - http://www.recantha.co.uk/blog

Cambridge Raspberry Jam
Website: http://camjam.me
Facebook: https://www.facebook.com/cambridgeraspberryjam
Follow the Cambridge Raspberry Jam on Twitter - @cambridgejam
User avatar
Posts: 184
Joined: Wed Nov 14, 2012 9:34 am
Location: Potton, Bedfordshire
by jbeale » Wed Jul 24, 2013 2:08 pm
RpiName wrote:as long as the mmal ABI is stable (isn't it?), unlike a real kernel driver, that driver does not have to be rebuilt each time the kernel or the firmware internals change


Yes, userspace code isolates you from kernel development. So far, the RPI camera ABI has not changed (but some meanings have; reversed the default horizontal flip, for example). We are hoping that some additional capabilities may eventually be added, for example the latest fix gave us Gain/ISO control, and we are hoping at some point for full manual exposure control (ability to manually set both Gain/ISO and shutter speed). If that does happen, I assume that would require an ABI change or addition, as the raspistill/raspivid programs do not currently have an option to set shutter speed.
User avatar
Posts: 1887
Joined: Tue Nov 22, 2011 11:51 pm
by jamesh » Wed Jul 24, 2013 2:19 pm
I am adding stuff fairly quickly on the ARM side at the moment; although the mmal ABI won't be changing, I am using more of it.

I think the next batch of changes may be more firmware based though, looking at my bug list. They won;t affect this project.
Raspberry Pi Engineer
Raspberry Pi Engineer
Posts: 10601
Joined: Sat Jul 30, 2011 7:41 pm
by ekoome » Wed Jul 24, 2013 3:00 pm
This Works!

How do i provide raspicam options to mjpg-streamer? Such as rotate camera (not picture)

Thanks.
Posts: 2
Joined: Wed Jul 24, 2013 2:56 pm
by ekoome » Wed Jul 24, 2013 4:23 pm
Anyone got it to work with motion? Getting error unable to open video device. Also getting error /dev/video0 does not support streaming i/o.
Posts: 2
Joined: Wed Jul 24, 2013 2:56 pm
by RpiName » Wed Jul 24, 2013 6:25 pm
Anyone got it to work with motion? Getting error unable to open video device. Also getting error /dev/video0 does not support streaming i/o.

Try to load the driver with the --extension-presence=1 option (man uv4l for more informations why it is necessary in some cases), and run motion as follows:

Code: Select all
pi@raspberrypi ~ $ uv4l --driver raspicam --auto-video_nr --extension-presence=1

Code: Select all
pi@raspberrypi ~ $ LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so motion


Sadly, motion crashes on my Rpi just before the streaming starts (although I got it working on my x86 laptop (and the UVC driver), if uv4l is loaded with the mentioned option).

Edit: it might be a known problem with Motion:

http://www.lavrsen.dk/foswiki/bin/view/Motion/FrequentlyAskedQuestions#Motion_crashes_with_segmentation_fault_the_first_time_it_detects_Motion
Posts: 63
Joined: Sat Jul 06, 2013 3:14 am
by goblin » Wed Jul 24, 2013 7:43 pm
Source or it didn't happen!
Posts: 1
Joined: Wed Jul 24, 2013 7:43 pm
by nickneubrand » Thu Jul 25, 2013 3:47 am
I'm having the same issue as the posts above me. I'm trying to run the raspi camera through python using /dev/video0, which wasn't working at first, now it is.

Now I'm getting an error in the Shell saying that "/dev/video0 does not support streaming i/o"

If anyone has some information on how to fix this it would be greatly appreciated.
Posts: 20
Joined: Fri Apr 26, 2013 4:54 am
by RpiName » Thu Jul 25, 2013 7:09 am
If anyone has some information on how to fix this it would be greatly appreciated.


To enable the streaming I/O, set the LD_PRELOAD environment variable as in the following example:
Code: Select all
$ LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so python ./pyprog.py


The "pygame.camera" python module does not seem to support the JPEG format from the camera, so you ll get something like:

SystemError: ioctl(VIDIOC_S_FMT) failure: no supported formats


If you need to take a snapshot for some reasons, consider using the "dd" system command.
Posts: 63
Joined: Sat Jul 06, 2013 3:14 am
by nickneubrand » Thu Jul 25, 2013 7:16 am
Yeah I eventually got that same error from the Shell as well. I was looking for a video stream, rather than pictures. I'm trying to get a video feed in, then put graphic overlays on top of the video stream. If I find a way to get it to work, I'll post it up.

Does anyone think that using OpenCV could be a work around for this problem?
Posts: 20
Joined: Fri Apr 26, 2013 4:54 am
by RpiName » Thu Jul 25, 2013 8:12 am
I'm trying to get a video feed in, then put graphic overlays on top of the video stream.


Have you had a look at fswebcam? http://www.firestorm.cx/fswebcam/

I think it can overlay PNG images while grabbing. The resulting images can be piped into mencoder to encode a video. To give you an idea, see:

http://andyseasysite.com/?p=33

By looking at the manual, it looks like mencoder itself has overlying capabilities.
Posts: 63
Joined: Sat Jul 06, 2013 3:14 am
by jbeale » Thu Jul 25, 2013 4:57 pm
RpiName wrote:To enable the streaming I/O, set the LD_PRELOAD environment variable as in the following example:
Code: Select all
$ LD_PRELOAD=/usr/lib/uv4l/uv4lext/armv6l/libuv4lext.so python ./pyprog.py


The "pygame.camera" python module does not seem to support the JPEG format from the camera

What output modes does the RPi V4L2 driver support? is it JPEG only? The RPi camera video output (from raspivid) is .h264 format, at up to 30 fps. But I suppose few if any programs taking webcam input, can deal with that format (?) Then there is raspiYUV but I think that is only for low frame rate stills.
User avatar
Posts: 1887
Joined: Tue Nov 22, 2011 11:51 pm
by nickneubrand » Sun Jul 28, 2013 12:27 am
Just wondering if anyone as made any progress with getting this driver to work with the camera and python.

I tried to get it to work by using this driver in addition to SimpleCV and OpenCV, both seem to work as far as communicating with the camera, because the camera light does turn on. But every time my program loads it freezes my pi. Does anyone have any solutions I might be able to try?

I figure that the combination of using a newly released driver paired with SimpleCV/OpenCV as a work around for the jpeg issue in the above posts would account for the issues that I'm having.
Posts: 20
Joined: Fri Apr 26, 2013 4:54 am
by RpiName » Sat Aug 03, 2013 5:09 am
What output modes does the RPi V4L2 driver support? is it JPEG only?

For now, yes.
Posts: 63
Joined: Sat Jul 06, 2013 3:14 am
by RpiName » Sat Aug 03, 2013 5:12 am
nickneubrand wrote:I tried to get it to work by using this driver in addition to SimpleCV and OpenCV, both seem to work as far as communicating with the camera, because the camera light does turn on. But every time my program loads it freezes my pi. Does anyone have any solutions I might be able to try?


Upgrade UV4L to the latest version eventually. If you still have problems, post your code.
Posts: 63
Joined: Sat Jul 06, 2013 3:14 am
by RpiName » Sat Aug 03, 2013 5:14 am
ekoome wrote:Anyone got it to work with motion? Getting error unable to open video device. Also getting error /dev/video0 does not support streaming i/o.


There is a basic guide on the website to use the driver with Motion:
http://www.linux-projects.org/modules/sections/index.php?op=viewarticle&artid=16
Posts: 63
Joined: Sat Jul 06, 2013 3:14 am