6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5128
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Thu Sep 07, 2017 9:07 am

KeithG wrote:
Thu Sep 07, 2017 8:01 am
Hi,
My first post, hope I'm in the right place. I have just updated my rpi2B with a clean image of the new OS Stretch, now my camera will not work. I cannot find the bcm2835-v4l2 driver on the machine, motion does not start, when I use dmesg I get : bcm2835-v4l2: error -1 while loading driver.
Do I need a file? where do I get it?
If you do

Code: Select all

ls /lib/modules/`uname -r`/kernel/drivers/media/platform/bcm2835
it should list bcm2835-v4l2.ko ("uname -r" should expand to the currently running kernel version).

Check first whether "vcgencmd version" reports the camera as found, and that raspistill or raspivid work. If not then it's much easier to debug using those instead of the V4L2 driver.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

KeithG
Posts: 4
Joined: Thu Sep 07, 2017 7:38 am

Re: Official V4L2 driver

Thu Sep 07, 2017 3:02 pm

hi 6by9,
thanks for the prompt reply. Yes the bcm2835-v4l2.ko is there. vcgencmd returns with
Aug 8 2017 12:05:45
Copyright (c) 2012 Broadcom
version 196063438d7bb0769861c86f948ae653727adb7e (clean) (release)

raspistill -o test.jpg
returns
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
mmal: Failed to create camera component
mmal: main: Failed to create camera component
mmal: Camera is not detected. Please check carefully the camera module is installed correctly
the camera was working before the upgrade. I have checked the orientation of the ribbon

raspivid -t 5000 -o video.h264
mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM)
mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1)
mmal: Failed to create camera component
mmal: main: Failed to create camera component
mmal: Camera is not detected. Please check carefully the camera module is installed correctly

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5128
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Thu Sep 07, 2017 3:10 pm

KeithG wrote:
Thu Sep 07, 2017 3:02 pm
hi 6by9,
thanks for the prompt reply. Yes the bcm2835-v4l2.ko is there. vcgencmd returns with
Aug 8 2017 12:05:45
Copyright (c) 2012 Broadcom
version 196063438d7bb0769861c86f948ae653727adb7e (clean) (release)
Doh, I need to proof read - the command should have been "vcgencmd get_camera", which should return with "supported=1 detected=1" if it has found the camera.
The output from raspistill implies a hardware issue, but vcgencmd would confirm.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

KeithG
Posts: 4
Joined: Thu Sep 07, 2017 7:38 am

Re: Official V4L2 driver

Thu Sep 07, 2017 3:44 pm

vcgencmd get_camera returns
supported=1 detected=0
I take it this does not look good
I have removed the camera ribbon both ends and reconnected it. No change.

KeithG
Posts: 4
Joined: Thu Sep 07, 2017 7:38 am

Re: Official V4L2 driver

Thu Sep 07, 2017 3:58 pm

I have been looking at the camera board with a magnifying glass and noticed that the ribbon from the sensor to j2 was not flat against the connector. When I touched it, it clicked. So I rebooted the pi and reran the command. I now detects the camera and raspistill/raspivid produce files.
thanks for all of your help 6by9.

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5128
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Thu Sep 07, 2017 3:59 pm

KeithG wrote:
Thu Sep 07, 2017 3:44 pm
vcgencmd get_camera returns
supported=1 detected=0
I take it this does not look good
I have removed the camera ribbon both ends and reconnected it. No change.
That means the GPU can't talk to the camera over the I2C bus, so totally unrelated to the V4L2 driver.
The quick things to check:
- flex connectors are the correct way up and seated properly (sounds like you've already done that one)
- if a V1.3 camera module, does the LED come on?
- the little connector between the camera PCB and the camera module itself can become dislodged. Push down on top of it to make sure it is fully home.
...
And you've just replied with that last one being the cause!
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

jatta
Posts: 1
Joined: Thu Mar 16, 2017 11:35 am

Re: Official V4L2 driver

Tue Oct 17, 2017 1:46 pm

Hey guys,

What are the best settings for cctv at night?

I'm using:

[*]PI NoIR camera with external IR illuminator
[*]MotionEyeOS for surveillance

The image/video quality at night is perfect with:

[*]scene_mode=8 (night)
[*]exposure_dynamic_framerate=1
[*]color_effects=1 (black/white)

But the caveat with this is that moving subjects such as cars and people are blurred out due to the long exposure:
dynamic-exposure-framerate-enabled.png
dynamic-exposure-framerate-enabled.png (54.83 KiB) Viewed 2266 times
If I keep the same settings but disable exposure_dynamic_framerate the image is too dark :| :
current-settings-dynamic-exposure-disabled.png
current-settings-dynamic-exposure-disabled.png (69.27 KiB) Viewed 2266 times
I wouldn't be surprised if I am understanding the settings incorrectly so any pointers are much appreciated!

y3egjsk
Posts: 5
Joined: Thu Oct 26, 2017 1:55 pm

Re: Official V4L2 driver

Wed Nov 15, 2017 4:40 pm

I am running an application to display 1920x1080 video acquired in YUYV from
the Raspberry Pi v2 camera. That application uses the bcm2835-v4l2 device driver to access
the camera. The application uses the VIDIOC_S_FMT ioctl to set the YUYV format. I am running
using ioctls to set V4L2_CID_EXPOSURE_ABSOLUTE to 10000 (1 second exposures) and
V4L2_CID_AUTO_EXPOSURE set to V4L2_EXPOSURE_MANUAL.

If I run the program immediately after reboot, and loading the device driver I get a very dark image.

If I reboot, load the device driver, and run this --
v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=4
before my program, the YUYV image is a dramatically brighter, properly exposed image.

I just double checked that the VIDIOC_S_FMT ioctl in my program has the correct parameters either way.

Something somewhere is getting initialized by the temporary .h264 mode. Any ideas on what that could be?
Is .h264 mode more heavily tested than the YUYV mode?

Steve

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5128
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Thu Nov 16, 2017 10:01 am

y3egjsk wrote:
Wed Nov 15, 2017 4:40 pm
I am running an application to display 1920x1080 video acquired in YUYV from
the Raspberry Pi v2 camera. That application uses the bcm2835-v4l2 device driver to access
the camera. The application uses the VIDIOC_S_FMT ioctl to set the YUYV format. I am running
using ioctls to set V4L2_CID_EXPOSURE_ABSOLUTE to 10000 (1 second exposures) and
V4L2_CID_AUTO_EXPOSURE set to V4L2_EXPOSURE_MANUAL.

If I run the program immediately after reboot, and loading the device driver I get a very dark image.

If I reboot, load the device driver, and run this --
v4l2-ctl --set-fmt-video=width=1920,height=1080,pixelformat=4
before my program, the YUYV image is a dramatically brighter, properly exposed image.

I just double checked that the VIDIOC_S_FMT ioctl in my program has the correct parameters either way.

Something somewhere is getting initialized by the temporary .h264 mode. Any ideas on what that could be?
Is .h264 mode more heavily tested than the YUYV mode?
This is most likely due to the camera support not neatly mapping on to V4L2.
We have the concept of a stills capture vs a video capture, where one is optimised for image quality and the other is optimised for speed.
H264 and MJPEG obviously fall into the video category. JPEG falls into the stills. But what about RGB and YUV raw pixel formats?
The default imnplementation assumes that anything <= 720p is video, and above that is stills. From your report I suspect there may be a bug in asking for stills with fixed exposure, but I haven't got time to look into it at the moment.
As a workaround there are module parameters max_video_width and max_video_height that allow you to specify your own point to switch between video and stills. If you load the driver with "sudo modprobe bcm2835-v4l2 max_video_width=1920 max_video_height=1080" your YUYV frame will be judged to be a video mode and I expect will respond correctly to V4L2_CID_EXPOSURE_ABSOLUTE.

If it does fix it, you can create a file in /etc/modprobe.d with the contents

Code: Select all

options bcm2835-v4l2 max_video_width=1920
options bcm2835-v4l2 max_video_height=1080
to make the change automatic.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

y3egjsk
Posts: 5
Joined: Thu Oct 26, 2017 1:55 pm

Re: Official V4L2 driver

Thu Nov 16, 2017 3:50 pm

Thanks 6by9! The max_video_height and max_video_width did not make a difference in the behavior. You should know that with this problem, the image does respond throughout the range of V4L2_CID_EXPOSURE_ABSOLUTE, it is just that the exposure varies thru a much darker range. With my temporary set to h264, the image varies over a brighter range. When using 640x480 mode, things are brighter still, and my workaround is not needed.

It is very helpful to know that 720p (1280x720) is at the top of the default YUYV video threshold. This image is just as bright as the 640x480, and does not need any workaround, either the h264 I used, or the driver load parameters you mentioned.

Since this is for astrophotography, brightness and resolution are important. Switching to 1280x720 is big improvement. I appreciate your answer!

Steve

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5128
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Thu Nov 16, 2017 4:21 pm

y3egjsk wrote:
Thu Nov 16, 2017 3:50 pm
Thanks 6by9! The max_video_height and max_video_width did not make a difference in the behavior. You should know that with this problem, the image does respond throughout the range of V4L2_CID_EXPOSURE_ABSOLUTE, it is just that the exposure varies thru a much darker range. With my temporary set to h264, the image varies over a brighter range. When using 640x480 mode, things are brighter still, and my workaround is not needed.

It is very helpful to know that 720p (1280x720) is at the top of the default YUYV video threshold. This image is just as bright as the 640x480, and does not need any workaround, either the h264 I used, or the driver load parameters you mentioned.

Since this is for astrophotography, brightness and resolution are important. Switching to 1280x720 is big improvement. I appreciate your answer!
It sounds like we may have a typo then.
If you run "dmesg" to print out the kernel log, loading the V4L2 driver should have logged

Code: Select all

bcm2835-v4l2: V4L2 device registered as video0 - stills mode > 1920x1080
Having said that, playing with qv4l2(*), JPEG appears at 1280x720 appears to be giving a different image brightness to any of the raw image formats at that resolution. Switching up to 1280x960(**) (ie stills mode) appears to give similar results between the two. So something appears to be wrong there, but it'll require a fair amount of investigation to find out what.

I assume you are setting a low frame rate too if you want 1sec exposures. Either that or setting V4L2_CID_EXPOSURE_AUTO_PRIORITY so that AE is allowed to alter the frame rate as required.

(*) one of the standard V4L2 test apps available with apt-get. Uncheck "Use OpenGL Rendering" from the Capture menu to get it to work.
(**) Annoyingly you can't change resolution in qv4l2. Quit the app, run "v4l2-ctl -v width=1280,height=960" (or whatever resolution), and then rerun qv4l2 (remembering to disable OpenGL again).
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

y3egjsk
Posts: 5
Joined: Thu Oct 26, 2017 1:55 pm

Re: Official V4L2 driver

Thu Nov 16, 2017 11:55 pm

Hi 6by9,
My script that starts my program always sets the frame rate to 1 fps before starting the application.
v4l2-ctl -p 1

The application is now set up to run at 1920x1080 (with the .h264 prelim setup), 1280x720, and at 640x480.
I will probably run at 1280x720, since this is somewhat brighter video than the 1920x1080.

sudo dmesg
The log shows
bcm2835-v4l2: V4L2 device registered as video - stills mode > 1280x720
sometimes the message shows stills mode > 1920x1080.
The value shown in the log doesn't seem to affect the behavior.
Doing things the same way after a reboot produces the same video characteristics, but sometimes different log messages.

Steve

Gearloose
Posts: 2
Joined: Wed Dec 27, 2017 10:03 pm

Re: Official V4L2 driver

Wed Jan 10, 2018 1:04 pm

Hello,

I'm trying to build a simple project to monitor (with the official camera) a room and also control some relays.
I've been trying for some time now to figure out how to feed the video to a web page hosted by the Raspberry Pi 3 (I'm using nginx).
The idia is to access the page form my mobile, view the video and/or control the relays status.

I tried the raspivid and, nc, raspvid and vlc with or without transcoding and now V4L2 with vlc without success.
I'm very sure I'm doing something wrong since I do not fully understand the encoding I need to use so it is more like trial and error based on the examples in forums.

How could I feed the video in a format stream-able from http?
Do you have any working example?

Thank you!

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5128
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Wed Jan 10, 2018 3:34 pm

Gearloose wrote:
Wed Jan 10, 2018 1:04 pm
Hello,

I'm trying to build a simple project to monitor (with the official camera) a room and also control some relays.
I've been trying for some time now to figure out how to feed the video to a web page hosted by the Raspberry Pi 3 (I'm using nginx).
The idia is to access the page form my mobile, view the video and/or control the relays status.

I tried the raspivid and, nc, raspvid and vlc with or without transcoding and now V4L2 with vlc without success.
I'm very sure I'm doing something wrong since I do not fully understand the encoding I need to use so it is more like trial and error based on the examples in forums.

How could I feed the video in a format stream-able from http?
Do you have any working example?

Thank you!
Please start a new thread - you're likely to get little attention buried on page 21 of a generic thread.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

mrtom31
Posts: 3
Joined: Sat Mar 31, 2018 4:38 pm

Re: Official V4L2 driver

Sat Mar 31, 2018 5:13 pm

Hi,

I tried to install v4l2 with commands from post and installation failed:

Code: Select all

autoreconf -vfi

configure.ac:79: installing 'build-aux/missing'
contrib/cobalt-ctl/Makefile.am: installing 'build-aux/depcomp'
autoreconf: automake failed with exit status: 1

phill54
Posts: 3
Joined: Thu Feb 07, 2013 7:56 am

Re: Official V4L2 driver

Tue Apr 24, 2018 9:09 am

Code: Select all

phill54@pi3:~ $ sudo apt-get install autoconf gettext libtool libjpeg62-dev
[sudo] password for phill54:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libjpeg62-dev : Depends: libjpeg62 (= 1:6b2-2)
E: Unable to correct problems, you have held broken packages.
so i tried "libjpeg-dev" instead of "libjpeg62-dev", and the installer reported no problem
then:

Code: Select all

phill54@pi3:~/v4l-utils $ autoreconf -vfi
autoreconf: Entering directory `.'
[...]
configure.ac:88: installing 'build-aux/config.guess'
configure.ac:95: error: required file 'build-aux/config.rpath' not found
[...]
contrib/cobalt-ctl/Makefile.am: installing 'build-aux/depcomp'
autoreconf: automake failed with exit status: 1
So, how do i fix this? :-) Thanks for the help.
btw, i'm on

Code: Select all

phill54@pi3:~/v4l-utils $ uname -r
4.14.34-v7+

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5128
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Tue Apr 24, 2018 9:20 am

Are you following the first post verbatim, having skipped the first line
EDIT: the default kernel includes v4l2 driver and the latest raspbian image includes the v4l2 utilities (like v4l2-ctl) so the initial steps can be skipped. Skip forward to the modprobe line.
"sudo apt install v4l-utils" will get you a recent enough version of all the tools.

If you really want to build from source, then things have changed slightly in the 4 years since the first post. Read the README file in the v4l-utils repo as it includes the full build steps - https://git.linuxtv.org/v4l-utils.git/tree/README#n23
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

lkt
Posts: 5
Joined: Sun May 06, 2018 5:42 pm

Re: Official V4L2 driver

Fri May 18, 2018 8:52 pm

Is there any way to set the quantisation parameter with this? (-qp on raspivid)

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 5128
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: Official V4L2 driver

Sat May 19, 2018 4:57 pm

lkt wrote:
Fri May 18, 2018 8:52 pm
Is there any way to set the quantisation parameter with this? (-qp on raspivid)
Not currently, but it looks like V4L2_CID_MPEG_VIDEO_H264_I_FRAME_QP, V4L2_CID_MPEG_VIDEO_H264_P_FRAME_QP, V4L2_CID_MPEG_VIDEO_H264_MIN_QP, and V4L2_CID_MPEG_VIDEO_H264_MAX_QP (see https://www.linuxtv.org/downloads/v4l-d ... -reference) may offer an option to implement them.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
Please don't send PMs asking for support - use the forum.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

Return to “Camera board”

Who is online

Users browsing this forum: RDPUser and 7 guests