Official V4L2 driver


481 posts   Page 20 of 20   1 ... 16, 17, 18, 19, 20
by nandor65 » Tue Nov 22, 2016 3:38 pm
6by9,
thanks for your reply. I use OpenCV 3.1, I think this is the latest version. OK, so if fps is set AE will never use longer exposure time than 1/fps. Lets say fps=45, then max exposure time is 22msec. (and min exposure time = 1 msec?)

So under darker conditions - to force AE to use longest possible exposure time - below two settings should result similar images on the same scenes?

Setting A :: no AE
v4l2-ctl -p 45
v4l2-ctl -c auto_exposure=1
v4l2-ctl -c exposure_time_absolute=22
Setting B :: AE
v4l2-ctl -p 45
v4l2-ctl -c auto_exposure=0

I do use NoIR sensor and IR illumination for night vision experiments. It is true these experiments are started recently.
Posts: 8
Joined: Tue Nov 22, 2016 10:34 am
by 6by9 » Tue Nov 22, 2016 4:15 pm
nandor65 wrote:6by9,
thanks for your reply. I use OpenCV 3.1, I think this is the latest version. OK, so if fps is set AE will never use longer exposure time than 1/fps. Lets say fps=45, then max exposure time is 22msec. (and min exposure time = 1 msec?)

So under darker conditions - to force AE to use longest possible exposure time - below two settings should result similar images on the same scenes?

Setting A :: no AE
v4l2-ctl -p 45
v4l2-ctl -c auto_exposure=1
v4l2-ctl -c exposure_time_absolute=22
Setting B :: AE
v4l2-ctl -p 45
v4l2-ctl -c auto_exposure=0

I do use NoIR sensor and IR illumination for night vision experiments. It is true these experiments are started recently.

http://hverkuil.home.xs4all.nl/spec/uap ... trols.html again
V4L2_CID_EXPOSURE_ABSOLUTE (integer)
Determines the exposure time of the camera sensor. The exposure time is limited by the frame interval. Drivers should interpret the values as 100 µs units, where the value 1 stands for 1/10000th of a second, 10000 for 1 second and 100000 for 10 seconds.

So you'll want
v4l2-ctl -c exposure_time_absolute=220

Min exposure time is about 50usecs IIRC.
AE will naturally adopt the max permitted exposure time if the scene demands it (at night time it will).
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.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4002
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.
by nandor65 » Tue Nov 22, 2016 5:36 pm
6by9, all right, so when exposure_time_absolute=22 is set this means exposure of 2.2ms and not 22ms. I missed a zero somewhere then.
what I wanted to have is a single set of sensor parameters which works for recognizing moving licence plates during the day as well as during the night. AE looks like a very good choice for daylight conditions, but fails when light amount drops. with IR AE does not look like doing a good job because plates are bleached out. I assume an ideal exposure time should be found.
to me now it looks like a set of parameter needed for the day and another set for the night. and I need some more reading. thanks for your kind support.
Posts: 8
Joined: Tue Nov 22, 2016 10:34 am
by 6by9 » Tue Nov 22, 2016 10:31 pm
AE will be looking at the whole scene rather than small patches.
There are options using V4L2_CID_EXPOSURE_METERING to switch the AE metering mode between average, spot, and centre weighted. I'll refer you again to the V4L2 spec. Spot mode is most likely to give the results you want.
Otherwise feel free to go with manual mode, but you may end up with more issues than you expect due to scene changes.
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.
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 4002
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.
by nandor65 » Mon Nov 28, 2016 1:05 pm
As I have learned recently: AE uses maximum exposure time of 1/fps. I would like to use AE and keep my fps but I would like to set my maximum exposure time different from 1/fps. Different means much shorter, and never longer exposure times than 1/fps. How is it possible?
Posts: 8
Joined: Tue Nov 22, 2016 10:34 am
by racer993 » Fri Feb 17, 2017 7:01 am
Today I discovered that one of the raspberry pi cameras in my setup was not functioning as expected. It sometimes skipped taking a picture. I looked at dmesg and found a couple of errors which seem to relate to the v4l2 driver.

I've copied some snippets here below. Any idea what might be causing this?

Code: Select all
[688060.901171] bcm2835-v4l2: error 0 waiting for frame completion
[688063.901202] bcm2835_v4l2: error 0 waiting for sync completion
[688066.901228] bcm2835_v4l2: error 0 waiting for sync completion
[688066.901247] bcm2835-v4l2: Failed disabling camera, ret -62
[688066.901255] bcm2835-v4l2: Failed to disable camera
[688066.901263] ------------[ cut here ]------------
[688066.901295] WARNING: CPU: 2 PID: 24933 at drivers/media/v4l2-core/videobuf2-core.c:1670 __vb2_queue_cancel+0xfc/0x160 [videobuf2_core]()
[688066.901303] Modules linked in: bcm2835_v4l2 videobuf2_vmalloc videobuf2_memops videobuf2_v4l2 videobuf2_core v4l2_common videodev media nfsd rpcsec_gss_krb5 snd_bcm2835 snd_pcm snd_timer snd bcm2835_gpiomem bcm2835_wdt uio_pdrv_genirq uio ipv6
[688066.901381] CPU: 2 PID: 24933 Comm: capture Not tainted 4.4.15-v7+ #897
[688066.901388] Hardware name: BCM2709
[688066.901422] [<80018724>] (unwind_backtrace) from [<80014058>] (show_stack+0x20/0x24)
[688066.901442] [<80014058>] (show_stack) from [<80320764>] (dump_stack+0xd4/0x118)
[688066.901463] [<80320764>] (dump_stack) from [<80025300>] (warn_slowpath_common+0x98/0xc8)
[688066.901482] [<80025300>] (warn_slowpath_common) from [<800253ec>] (warn_slowpath_null+0x2c/0x34)
[688066.901504] [<800253ec>] (warn_slowpath_null) from [<7f16928c>] (__vb2_queue_cancel+0xfc/0x160 [videobuf2_core])
[688066.901538] [<7f16928c>] (__vb2_queue_cancel [videobuf2_core]) from [<7f169608>] (vb2_core_queue_release+0x20/0x40 [videobuf2_core])
[688066.901568] [<7f169608>] (vb2_core_queue_release [videobuf2_core]) from [<7f1745f0>] (_vb2_fop_release+0x9c/0xac [videobuf2_v4l2])
[688066.901594] [<7f1745f0>] (_vb2_fop_release [videobuf2_v4l2]) from [<7f174634>] (vb2_fop_release+0x34/0x38 [videobuf2_v4l2])
[688066.901650] [<7f174634>] (vb2_fop_release [videobuf2_v4l2]) from [<7f12e500>] (v4l2_release+0x48/0x84 [videodev])
[688066.901685] [<7f12e500>] (v4l2_release [videodev]) from [<80158be8>] (__fput+0x94/0x1e4)
[688066.901703] [<80158be8>] (__fput) from [<80158da8>] (____fput+0x18/0x1c)
[688066.901723] [<80158da8>] (____fput) from [<8004097c>] (task_work_run+0xa0/0xd4)
[688066.901740] [<8004097c>] (task_work_run) from [<80027968>] (do_exit+0x348/0xab0)
[688066.901755] [<80027968>] (do_exit) from [<80028168>] (do_group_exit+0x4c/0xe4)
[688066.901769] [<80028168>] (do_group_exit) from [<80028220>] (__wake_up_parent+0x0/0x30)
[688066.901785] [<80028220>] (__wake_up_parent) from [<8000fb40>] (ret_fast_syscall+0x0/0x1c)
[688066.901794] ---[ end trace 093d4f1489a09556 ]---
[688070.381263] bcm2835_v4l2: error 0 waiting for sync completion
[688070.384017] bcm2835-v4l2: ==================  END STATUS  ==================
[688151.071855] bcm2835_v4l2: error 0 waiting for sync completion
[688154.071878] bcm2835_v4l2: error 0 waiting for sync completion
[688154.071898] bcm2835-v4l2: vidioc_s_fmt_vid_cap: failed to setup mmal components: -62
[688157.101903] bcm2835_v4l2: error 0 waiting for sync completion
[688160.121922] bcm2835_v4l2: error 0 waiting for sync completion
[688163.141942] bcm2835_v4l2: error 0 waiting for sync completion
[688166.161966] bcm2835_v4l2: error 0 waiting for sync completion
[688169.161986] bcm2835_v4l2: error 0 waiting for sync completion
[688172.162007] bcm2835_v4l2: error 0 waiting for sync completion
[688175.162032] bcm2835_v4l2: error 0 waiting for sync completion
[688175.162049] bcm2835-v4l2: Failed to set fps ret -186
[688178.322059] bcm2835_v4l2: error 0 waiting for sync completion
[688178.322107] bcm2835-v4l2: queue_setup: capture port not configured
[688181.792068] bcm2835_v4l2: error 0 waiting for sync completion
[688181.794473] bcm2835-v4l2: =================  START STATUS  =================

........

[698560.689390] bcm2835-v4l2: ==================  END STATUS  ==================
[698565.476695] bcm2835_v4l2: error 0 waiting for sync completion
[698568.476713] bcm2835_v4l2: error 0 waiting for sync completion
[698568.476733] bcm2835-v4l2: vidioc_s_fmt_vid_cap: failed to setup mmal components: -62
[698571.506735] bcm2835_v4l2: error 0 waiting for sync completion
[698574.526759] bcm2835_v4l2: error 0 waiting for sync completion
[698578.596808] bcm2835_v4l2: error 0 waiting for sync completion
[698581.616837] bcm2835_v4l2: error 0 waiting for sync completion
[698584.616849] bcm2835_v4l2: error 0 waiting for sync completion
[698587.616877] bcm2835_v4l2: error 0 waiting for sync completion
[698590.616896] bcm2835_v4l2: error 0 waiting for sync completion
[698590.616909] bcm2835-v4l2: Failed to set fps ret -186
[698593.766895] bcm2835_v4l2: error 0 waiting for sync completion
[698593.766939] bcm2835-v4l2: queue_setup: capture port not configured
[698597.226937] bcm2835_v4l2: error 0 waiting for sync completion
[698597.229360] bcm2835-v4l2: =================  START STATUS  =================
[698597.229379] bcm2835-v4l2: Saturation: 0
[698597.229395] bcm2835-v4l2: Sharpness: 0
[698597.229405] bcm2835-v4l2: Contrast: 15
[698597.229416] bcm2835-v4l2: Brightness: 50
[698597.229427] bcm2835-v4l2: ISO Sensitivity: 100000
[698597.229438] bcm2835-v4l2: ISO Sensitivity, Auto: Auto
[698597.229450] bcm2835-v4l2: Image Stabilization: false
[698597.229460] bcm2835-v4l2: Auto Exposure: Manual Mode
[698597.229471] bcm2835-v4l2: Exposure Time, Absolute: 125
[698597.229482] bcm2835-v4l2: Auto Exposure, Bias: 0
[698597.229493] bcm2835-v4l2: Exposure, Dynamic Framerate: false
[698597.229503] bcm2835-v4l2: Exposure, Metering Mode: Average
[698597.229514] bcm2835-v4l2: White Balance, Auto & Preset: Manual
[698597.229525] bcm2835-v4l2: Red Balance: 1520
[698597.229535] bcm2835-v4l2: Blue Balance: 1600
[698597.229546] bcm2835-v4l2: Color Effects: None
[698597.229556] bcm2835-v4l2: Color Effects, CbCr: 32896
[698597.229568] bcm2835-v4l2: Rotate: 0
[698597.229578] bcm2835-v4l2: Horizontal Flip: true
[698597.229588] bcm2835-v4l2: Vertical Flip: true
[698597.229599] bcm2835-v4l2: Video Bitrate Mode: Variable Bitrate
[698597.229610] bcm2835-v4l2: Video Bitrate: 10000000
[698597.229620] bcm2835-v4l2: Compression Quality: 30
[698597.229631] bcm2835-v4l2: Power Line Frequency: 50 Hz
[698597.229642] bcm2835-v4l2: Repeat Sequence Header: false
[698597.229652] bcm2835-v4l2: H264 Profile: High
[698597.229663] bcm2835-v4l2: H264 Level: 4
[698597.229673] bcm2835-v4l2: Scene Mode: None
[698597.229684] bcm2835-v4l2: H264 I-Frame Period: 60
[698597.229695] bcm2835-v4l2: ==================  END STATUS  ==================

........

[1275967.519489] INFO: task vcgencmd:29142 blocked for more than 120 seconds.
[1275967.519510]       Tainted: G        W       4.4.15-v7+ #897
[1275967.519518] "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message.
[1275967.519527] vcgencmd        D 805b4e4c     0 29142      1 0x00000005
[1275967.519574] [<805b4e4c>] (__schedule) from [<805b53c4>] (schedule+0x50/0xa8)
[1275967.519593] [<805b53c4>] (schedule) from [<805b82b4>] (schedule_timeout+0x1e8/0x270)
[1275967.519611] [<805b82b4>] (schedule_timeout) from [<805b7000>] (__down+0x88/0xc0)
[1275967.519631] [<805b7000>] (__down) from [<800690ac>] (down+0x54/0x68)
[1275967.519652] [<800690ac>] (down) from [<803cf73c>] (vchiq_release+0x12c/0x314)
[1275967.519673] [<803cf73c>] (vchiq_release) from [<80158be8>] (__fput+0x94/0x1e4)
[1275967.519692] [<80158be8>] (__fput) from [<80158da8>] (____fput+0x18/0x1c)
[1275967.519711] [<80158da8>] (____fput) from [<8004097c>] (task_work_run+0xa0/0xd4)
[1275967.519729] [<8004097c>] (task_work_run) from [<80027968>] (do_exit+0x348/0xab0)
[1275967.519745] [<80027968>] (do_exit) from [<80028168>] (do_group_exit+0x4c/0xe4)
[1275967.519762] [<80028168>] (do_group_exit) from [<800332a0>] (get_signal+0x370/0x6dc)
[1275967.519782] [<800332a0>] (get_signal) from [<8001341c>] (do_signal+0xc4/0x3c0)
[1275967.519801] [<8001341c>] (do_signal) from [<80013900>] (do_work_pending+0xb8/0xd0)
[1275967.519819] [<80013900>] (do_work_pending) from [<8000fb68>] (slow_work_pending+0xc/0x20)
(END)
Posts: 41
Joined: Mon Feb 18, 2013 7:27 pm