Official V4L2 driver


481 posts   Page 15 of 20   1 ... 12, 13, 14, 15, 16, 17, 18 ... 20
by 6by9 » Mon Mar 30, 2015 1:07 pm
SandroM wrote:Hi,
I am making some tests with the camera if it’s possible to use it in a commercial application. Therefore it is necessary to use constant light and camera settings. For my tests I have disabled white_balance_auto_present, set the auto_exposure to manual and set the scene_mode to none.
Now when I change the shutter value, especially setting it to 0 and then increasing it, I get an almost white image with a lot of noise.
In the net I have found a spec of the image sensor. I have seen that the chip has an auto gain control and a night mode. I think that these features are making me problems.
I have tried to disable these features by setting the chip registers but it didn’t work. I had a look in the source of the V4L2 driver and it seems that the feature, to set a chip register, is not implemented. When I am wrong please correct me.
So is it possible to disable the auto gain control and night mode?
Cheers,
SandroM

The AGC algorithms on the sensor are all disabled - it is done in the Broadcom ISP within BCM283[5|6]. All the control to the OV5647 is also from the GPU side of BCM283[5|6], so mess with the I2C on port 0 at your peril when the camera is running.
V4L2_CID_EXPOSURE_AUTO to V4L2_EXPOSURE_MANUAL, and then setting V4L2_CID_EXPOSURE_ABSOLUTE to a value in the range 1 to 10,000,000 should set the exposure time in 100usec increments. 0 is not a valid setting.
Have you set V4L2_CID_ISO_SENSITIVITY as well? That is providing gain control.

Setting V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE to V4L2_WHITE_BALANCE_MANUAL generally means you need to set V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE too, otherwise they'll default to 0 and you'll get a totally green image. See www.raspberrypi.org/forums/viewtopic.ph ... 58#p530358

If you're unsure of settings, then I'd suggest downloading the source from http://git.linuxtv.org/cgit.cgi/v4l-uti ... tree/utils and building qv4l2 as a quick and easy swiss-army knife for tweaking anything V4L2 related. You can also use the command-line version which is v4l2-ctl.
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: 4003
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.
by SandroM » Mon Mar 30, 2015 2:22 pm
6by9 wrote:The AGC algorithms on the sensor are all disabled - it is done in the Broadcom ISP within BCM283[5|6]. All the control to the OV5647 is also from the GPU side of BCM283[5|6], so mess with the I2C on port 0 at your peril when the camera is running.
V4L2_CID_EXPOSURE_AUTO to V4L2_EXPOSURE_MANUAL, and then setting V4L2_CID_EXPOSURE_ABSOLUTE to a value in the range 1 to 10,000,000 should set the exposure time in 100usec increments. 0 is not a valid setting.
Have you set V4L2_CID_ISO_SENSITIVITY as well? That is providing gain control.


Oh yes I have set a wrong shutter value in my application. :oops: ;) My default ISO value is 0.

6by9 wrote:Setting V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE to V4L2_WHITE_BALANCE_MANUAL generally means you need to set V4L2_CID_RED_BALANCE and V4L2_CID_BLUE_BALANCE too, otherwise they'll default to 0 and you'll get a totally green image. See viewtopic.php?f=43&t=62364&p=530358#p530358

If you're unsure of settings, then I'd suggest downloading the source from http://git.linuxtv.org/cgit.cgi/v4l-uti ... tree/utils and building qv4l2 as a quick and easy swiss-army knife for tweaking anything V4L2 related. You can also use the command-line version which is v4l2-ctl.

I already use v4l2-ctl tool to check my camera configuration.
I was able to reproduce the effect in qv4l2 application: (the configuration is ISO: 0, Scene Mode: None, Auto Exposure: Manual mode)
1) Start the qv4l2 application
2) Go to tab "Camera controls" and set the exposure control to e.g. 500.
3) Start live mode - I get a "normal" image. This means there is no noise and the image is not to bright.
4) Now set the exp time to 1. The image is black.
5) Close the application.
6) Start the application once again.
7) Start the live mode. The image should be completely black but I see small contours of the image.
8) Set the exposure time back to 500. Now the image has a lot of noise and it is much brighter than before.

Any ideas?

Greetings,
SandroM
Posts: 3
Joined: Fri Mar 27, 2015 8:48 am
by 6by9 » Mon Mar 30, 2015 3:46 pm
SandroM wrote:I already use v4l2-ctl tool to check my camera configuration.
I was able to reproduce the effect in qv4l2 application: (the configuration is ISO: 0, Scene Mode: None, Auto Exposure: Manual mode)
1) Start the qv4l2 application
2) Go to tab "Camera controls" and set the exposure control to e.g. 500.
3) Start live mode - I get a "normal" image. This means there is no noise and the image is not to bright.
4) Now set the exp time to 1. The image is black.
5) Close the application.
6) Start the application once again.
7) Start the live mode. The image should be completely black but I see small contours of the image.
8) Set the exposure time back to 500. Now the image has a lot of noise and it is much brighter than before.

Any ideas?

ISO is setting the analogue gain of the sensor and digital gain in the ISP. Both gains and exposure time are controlled by the AE algorithm.
Leaving ISO at 0 (auto) when you're disabling auto exposure leaves it at a slightly indeterminate state. I'd advise fixing it at ISO 100 - I suspect the AE algo has seen the image is too dark due to you having fixed the exposure time so it tries cranking up the gains to compensate, hence a brighter and noisier image.
If that doesn't work then something funny is going on and I'll try to have a look later.
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: 4003
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.
by SandroM » Tue Mar 31, 2015 7:06 am
Hi 6by9,
6by9 wrote:ISO is setting the analogue gain of the sensor and digital gain in the ISP. Both gains and exposure time are controlled by the AE algorithm.

Is it possible to disable the AE algorithm?
6by9 wrote:Leaving ISO at 0 (auto) when you're disabling auto exposure leaves it at a slightly indeterminate state. I'd advise fixing it at ISO 100 - I suspect the AE algo has seen the image is too dark due to you having fixed the exposure time so it tries cranking up the gains to compensate, hence a brighter and noisier image.
If that doesn't work then something funny is going on and I'll try to have a look later.

Now I have used the same configuration than before except setting the ISO value to 100.
I have done the same test with a different result.
At step 7) the image is really black. That's ok. When I now increase the exposure value 8) the image is green. I don't know if it's getting brighter or darker.
But I have found another effect. I have used the same camera configuration.
1) Start qv4l2 application and do the camera configuration (exposure e.g. 500)
2) Start the capturing mode.
3) Set the exposure to 1000. The image got brighter.
4) Leave the capturing mode and start it once again.
5) Now the image is as bright as in step 2). It got darker. When I now set the exposure value to 1500 it is as bright as in step 3).
When I repeat steps 4) and 5) the exposure value is getting higher and higher but when I start the capturing mode again it is still as bright as in step 2).
Cheers,
SandroM
Posts: 3
Joined: Fri Mar 27, 2015 8:48 am
by labreu » Thu Apr 02, 2015 1:49 pm
Hey guys,

when I type: v4l2-ctl --list-formats I get:
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type: Video Capture
Pixel Format: 'GREY'
Name: Greyscale 8-bit (Y800)

but I want to get raw data or color from this camera: DFK 72BUC02
So I tried to reinstall v4l and followed this:

sudo apt-get install autoconf gettext libtool libjpeg62-dev
cd v4l-utils
autoreconf -vfi
./configure
make
sudo make install

but when I execute this line: autoreconf -vfi
I get: configure.ac:82: required file 'build-aux/config.rpath' not found

I already tried:
touch config.rpath
rpi-update
apt-get update
apt-get upgrade

any suggestions?
thanks
Posts: 2
Joined: Thu Apr 02, 2015 1:41 pm
by 6by9 » Thu Apr 02, 2015 2:48 pm
labreu wrote:Hey guys,

when I type: v4l2-ctl --list-formats I get:
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type: Video Capture
Pixel Format: 'GREY'
Name: Greyscale 8-bit (Y800)

but I want to get raw data or color from this camera: DFK 72BUC02

Wrong thread/forum then. This forum is for the Raspberry Pi camera board rather than arbitrary USB webcams. You're unlikely to find any others trying to use that camera on a Pi, at least not here. Might be worth a more generic trawl with Google
So I tried to reinstall v4l and followed this:

sudo apt-get install autoconf gettext libtool libjpeg62-dev
cd v4l-utils
autoreconf -vfi
./configure
make
sudo make install

but when I execute this line: autoreconf -vfi
I get: configure.ac:82: required file 'build-aux/config.rpath' not found

I already tried:
touch config.rpath
rpi-update
apt-get update
apt-get upgrade

That's only trying to rebuild the v4l2 utilities. The main support is built into the kernel.
If you read the INSTALL file from the v4l-utils source you've just downloaded (http://git.linuxtv.org/cgit.cgi/v4l-uti ... ee/INSTALL), they've updated he install instructions:
If you checked out the source repository you need to install the autotools
environment and gettext first.

The autotools/gettext should be updated to the version that are shipped
on your distro. This can be done by running:
$ ./bootstrap.sh

Then you need to configure any any desired options with:
$ ./configure

You can get a summary of possible configurations via the --help option.
If used without arguments, it will set the install prefix to /usr/local/.

After configuration you need to start the build process with:
$ make

Look at bootstrap.sh and you'll see it creates that config.rpath file for you.
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: 4003
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.
by labreu » Mon Apr 06, 2015 12:14 pm
thank you 6by9

and it seems to me that this "v4l2-cel --list-formats" lists properties from the connected device..right? I didnt know that, I tought it was the formats that the driver could accept.

because today when I tried this again (with the camera disconnected), it returned: Failed to open /dev/video0: No such file or directory.
Posts: 2
Joined: Thu Apr 02, 2015 1:41 pm
by 6by9 » Mon Apr 06, 2015 3:47 pm
labreu wrote:and it seems to me that this "v4l2-cel --list-formats" lists properties from the connected device..right? I didnt know that, I tought it was the formats that the driver could accept.

because today when I tried this again (with the camera disconnected), it returned: Failed to open /dev/video0: No such file or directory.

It lists the formats that the driver says it can produce, and that driver will be specific (or at least customised) for your device.
Applications will also have a set of formats that they can support, and you have to hope that there is some overlap in the two sets.
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: 4003
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.
by Jasimo » Tue May 26, 2015 6:32 am
Hi,
I am using motioneye on a raspberry Pi2 with a CSI Camera Board (https://bitbucket.org/ccrisan/motioneye/wiki/Home).
It´s using motion and the V4L2 Driver (bcm2835_v4l2 module). After some time using the cam I got problems with the colors of the picture and captured movies. I played around with the parameters for white_balance_auto_preset, iso_sensitivity and auto_exposure but without luck. See the pictures below:
Image
Image
Image

After a reinitialization of the V4L2 Driver (or a reboot of the Pi) it went back to normal.

Any help on this would be fine.

rgs
Posts: 50
Joined: Mon Apr 27, 2015 11:50 am
by gordon77 » Tue May 26, 2015 11:55 am
I've struggled with the v4l2 and setting iso, also the brightness appears to change even if set to auto
Posts: 2847
Joined: Sun Aug 05, 2012 3:12 pm
by Feuerengel » Sun Jun 07, 2015 11:59 am
Hello!

I'm using V4L2 driver with Python 2.7 and OpenCV 2.4.11 for my project. So, I have a problem with auto white balance. When orange object is infront of camera colors looks correct, but when camera see only white objects all goes to yellow. (Watch screenshots). This make imposible to use color tracking.
I tried to turn off AWB by using this commands: "v4l2-ctl --set-ctrl=white_balance_auto_preset=X", "v4l2-ctl --set-ctrl=red_balance=XXXX", "v4l2-ctl --set-ctrl=blue_balance=XXXX" (I tried different numbers instead X), but nothing happens. AWB still working.

Where I'm wrong?

P.S.
Sorry for my grammar mistakes. English is not my mother tongue :)
Attachments
Yellow.png
Incorrect colors
Yellow.png (63.38 KiB) Viewed 4089 times
Normal.png
Normal White Balance
Normal.png (61.12 KiB) Viewed 4089 times
User avatar
Posts: 2
Joined: Sun Jun 07, 2015 11:10 am
by 6by9 » Sun Jun 07, 2015 7:28 pm
Feuerengel wrote:I'm using V4L2 driver with Python 2.7 and OpenCV 2.4.11 for my project. So, I have a problem with auto white balance. When orange object is infront of camera colors looks correct, but when camera see only white objects all goes to yellow. (Watch screenshots). This make imposible to use color tracking.
I tried to turn off AWB by using this commands: "v4l2-ctl --set-ctrl=white_balance_auto_preset=X", "v4l2-ctl --set-ctrl=red_balance=XXXX", "v4l2-ctl --set-ctrl=blue_balance=XXXX" (I tried different numbers instead X), but nothing happens. AWB still working.

Where I'm wrong?

I've not checked on a live system, but based on previous comments it MUST be "v4l2-ctl --set-ctrl=white_balance_auto_preset=0" for manual AWB. At that point red_balance and blue_balance should do appropriate things. Otherwise auto mode will be enabled with varying target values.
Please confirm with just v4l2-ctl whether that works. If not, then I'll try to find a few moments to have a look. Seeing as I haven't heard any complaints from users using raspistill/vid, I've be surprised if there were a firmware bug here.
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: 4003
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.
by Feuerengel » Sun Jun 07, 2015 7:58 pm
MUST be "v4l2-ctl --set-ctrl=white_balance_auto_preset=0"

This is the first thing wich I tried to solve this problemm.
For taking images from camera in my Python code I'm using this:
Code: Select all
camera=cv2.VideoCapture(0)

def get_image():
   retval, im=camera.read() 
   return im

img=get_image()

I've tride another options of driver, like "color_effects" and it's working fine.

P.S.
I'm didn't say about it before: my camera is "RPI Camera Rev 1.3" if it does matter =)
User avatar
Posts: 2
Joined: Sun Jun 07, 2015 11:10 am
by skm2222 » Thu Jun 11, 2015 9:34 am
hi
gettiing an error during installation
every step work fine but when i write ./configure its giving an error
./configure line 21526 test : unary operator expected
configure: creating ./configure.status
config.status : error cannot find input file 'Makefile.in'


and next step make is also giving an error
make +++ no target specified and no makefile found .stop

plz help me regarding this
Posts: 2
Joined: Thu Jun 04, 2015 9:08 am
by 6by9 » Thu Jun 11, 2015 11:34 am
skm2222 wrote:hi
gettiing an error during installation
every step work fine but when i write ./configure its giving an error
./configure line 21526 test : unary operator expected
configure: creating ./configure.status
config.status : error cannot find input file 'Makefile.in'


and next step make is also giving an error
make +++ no target specified and no makefile found .stop

What exactly are you trying to build? If it is v4l-utils then don't bother as the default versions in the Raspbian repo have been updated (hence the big bold "edit" text at the top of the first post)

If you are trying to build v4l-utils, then they've altered the build steps (read "INSTALL" in the repo), so you now need to do
Code: Select all
sudo apt-get install autoconf gettext libtool libjpeg62-dev
cd v4l-utils
./bootstrap.sh
./configure
make

(You may want to switch into the utils/v4l2-ctl directory first, as I've just got a build failure in the DVB tools when trying to make everything)
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: 4003
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.
by byterg » Tue Jun 23, 2015 12:25 pm
Hello!
Now I try use V4L2 for get image from sensor, linux 3.18 (commit 79176013396e2a84897fd2b871973402adbcbef1).
Unfortunately linux log contained follow message:
Code: Select all
[12744.964927] ------------[ cut here ]------------
[12744.969800] WARNING: CPU: 0 PID: 522 at drivers/media/v4l2-core/videobuf2-core.c:2135 __vb2_queue_cancel+0xec/0x158 [videobuf2_core]()
[12744.981955] Modules linked in: bcm2835_v4l2 videobuf2_vmalloc videobuf2_memops videobuf2_core v4l2_common videodev [last unloaded: bcm2835_v4l2]
[12744.995150] CPU: 0 PID: 522 Comm: ld-linux.so.3 Tainted: G        W      3.18.16+ #1
[12745.002953] Backtrace:
[12745.005481] [<c0011d18>] (dump_backtrace) from [<c0011eb4>] (show_stack+0x18/0x1c)
[12745.013121]  r6:bf0355c8 r5:00000009 r4:00000000 r3:00000000
[12745.018919] [<c0011e9c>] (show_stack) from [<c03906a0>] (dump_stack+0x20/0x28)
[12745.026235] [<c0390680>] (dump_stack) from [<c0020b30>] (warn_slowpath_common+0x70/0x90)
[12745.034416] [<c0020ac0>] (warn_slowpath_common) from [<c0020b74>] (warn_slowpath_null+0x24/0x2c)
[12745.043271]  r8:d700f010 r7:d66ef340 r6:d66ef1e0 r5:d66ef370 r4:d66ef340
[12745.050129] [<c0020b50>] (warn_slowpath_null) from [<bf0355c8>] (__vb2_queue_cancel+0xec/0x158 [videobuf2_core])
[12745.060427] [<bf0354dc>] (__vb2_queue_cancel [videobuf2_core]) from [<bf0363f4>] (vb2_queue_release+0x20/0x40 [videobuf2_core])
[12745.071983]  r8:d700f010 r7:d6c717f8 r6:d66ef1e0 r5:d66ef370 r4:d66ef340 r3:bf015ef8
[12745.079884] [<bf0363d4>] (vb2_queue_release [videobuf2_core]) from [<bf036468>] (_vb2_fop_release+0x54/0x7c [videobuf2_core])
[12745.091262]  r5:d66ef060 r4:d63fc780
[12745.094981] [<bf036414>] (_vb2_fop_release [videobuf2_core]) from [<bf0364bc>] (vb2_fop_release+0x2c/0x30 [videobuf2_core])
[12745.106355]  r6:d63fc780 r5:00000008 r4:d63fc780 r3:bf015ef8
[12745.112435] [<bf036490>] (vb2_fop_release [videobuf2_core]) from [<bf0003a0>] (v4l2_release+0x40/0x80 [videodev])
[12745.122875]  r4:d66ef060 r3:bf036490
[12745.126631] [<bf000360>] (v4l2_release [videodev]) from [<c00ddd8c>] (__fput+0x88/0x200)
[12745.134893]  r5:00000008 r4:d6c73720
[12745.138511] [<c00ddd04>] (__fput) from [<c00ddf5c>] (____fput+0x10/0x14)
[12745.145296]  r10:d65e9334 r9:418004fc r8:d5bf4000 r7:00000000 r6:c08d7fb0 r5:d664ce00
[12745.153291]  r4:d664d274
[12745.155853] [<c00ddf4c>] (____fput) from [<c0037acc>] (task_work_run+0x94/0xc4)
[12745.163252] [<c0037a38>] (task_work_run) from [<c002298c>] (do_exit+0x298/0x948)
[12745.170721]  r7:d65e9300 r6:d664ce00 r5:d5bf4000 r4:00000000
[12745.176450] [<c00226f4>] (do_exit) from [<c00230bc>] (do_group_exit+0x44/0xd4)
[12745.183733]  r7:d66ac520
[12745.186323] [<c0023078>] (do_group_exit) from [<c002c70c>] (get_signal+0x17c/0x60c)
[12745.194058]  r5:d5bf5edc r4:d5bf4000
[12745.197730] [<c002c590>] (get_signal) from [<c038d4c0>] (do_signal+0x8c/0x3d8)
[12745.205022]  r10:00000000 r9:d5bf4000 r8:b6bae5b8 r7:b6bae5bc r6:fffffe00 r5:00000001
[12745.212985]  r4:d5bf5fb0
[12745.215579] [<c038d434>] (do_signal) from [<c00116e8>] (do_work_pending+0xa8/0xec)
[12745.223212]  r10:00000000 r8:c000e9a8 r7:d5bf5fb0 r6:d5bf4000 r5:d5bf4000 r4:00000009
[12745.231224] [<c0011640>] (do_work_pending) from [<c000e828>] (work_pending+0xc/0x20)
[12745.238988]  r8:c000e9a8 r7:00000036 r6:b089bb44 r5:b1f15d30 r4:00000009 r3:b089bbac
[12745.246888] ---[ end trace f425fe4565343504 ]---

Can you help me fix this?
Thank you and excuse my bad english.
Posts: 56
Joined: Tue Jul 15, 2014 8:16 am
by 6by9 » Tue Jun 23, 2015 12:43 pm
byterg wrote:Hello!
Now I try use V4L2 for get image from sensor, linux 3.18 (commit 79176013396e2a84897fd2b871973402adbcbef1).
Unfortunately linux log contained follow message:
Code: Select all
[12744.964927] ------------[ cut here ]------------
[12744.969800] WARNING: CPU: 0 PID: 522 at drivers/media/v4l2-core/videobuf2-core.c:2135 __vb2_queue_cancel+0xec/0x158 [videobuf2_core]()
[12744.981955] Modules linked in: bcm2835_v4l2 videobuf2_vmalloc videobuf2_memops videobuf2_core v4l2_common videodev [last unloaded: bcm2835_v4l2]
[12744.995150] CPU: 0 PID: 522 Comm: ld-linux.so.3 Tainted: G        W      3.18.16+ #1
[12745.002953] Backtrace:
[12745.005481] [<c0011d18>] (dump_backtrace) from [<c0011eb4>] (show_stack+0x18/0x1c)
[12745.013121]  r6:bf0355c8 r5:00000009 r4:00000000 r3:00000000
[12745.018919] [<c0011e9c>] (show_stack) from [<c03906a0>] (dump_stack+0x20/0x28)
[12745.026235] [<c0390680>] (dump_stack) from [<c0020b30>] (warn_slowpath_common+0x70/0x90)
[12745.034416] [<c0020ac0>] (warn_slowpath_common) from [<c0020b74>] (warn_slowpath_null+0x24/0x2c)
[12745.043271]  r8:d700f010 r7:d66ef340 r6:d66ef1e0 r5:d66ef370 r4:d66ef340
[12745.050129] [<c0020b50>] (warn_slowpath_null) from [<bf0355c8>] (__vb2_queue_cancel+0xec/0x158 [videobuf2_core])
[12745.060427] [<bf0354dc>] (__vb2_queue_cancel [videobuf2_core]) from [<bf0363f4>] (vb2_queue_release+0x20/0x40 [videobuf2_core])
[12745.071983]  r8:d700f010 r7:d6c717f8 r6:d66ef1e0 r5:d66ef370 r4:d66ef340 r3:bf015ef8
[12745.079884] [<bf0363d4>] (vb2_queue_release [videobuf2_core]) from [<bf036468>] (_vb2_fop_release+0x54/0x7c [videobuf2_core])
[12745.091262]  r5:d66ef060 r4:d63fc780
[12745.094981] [<bf036414>] (_vb2_fop_release [videobuf2_core]) from [<bf0364bc>] (vb2_fop_release+0x2c/0x30 [videobuf2_core])
[12745.106355]  r6:d63fc780 r5:00000008 r4:d63fc780 r3:bf015ef8
[12745.112435] [<bf036490>] (vb2_fop_release [videobuf2_core]) from [<bf0003a0>] (v4l2_release+0x40/0x80 [videodev])
[12745.122875]  r4:d66ef060 r3:bf036490
[12745.126631] [<bf000360>] (v4l2_release [videodev]) from [<c00ddd8c>] (__fput+0x88/0x200)
[12745.134893]  r5:00000008 r4:d6c73720
[12745.138511] [<c00ddd04>] (__fput) from [<c00ddf5c>] (____fput+0x10/0x14)
[12745.145296]  r10:d65e9334 r9:418004fc r8:d5bf4000 r7:00000000 r6:c08d7fb0 r5:d664ce00
[12745.153291]  r4:d664d274
[12745.155853] [<c00ddf4c>] (____fput) from [<c0037acc>] (task_work_run+0x94/0xc4)
[12745.163252] [<c0037a38>] (task_work_run) from [<c002298c>] (do_exit+0x298/0x948)
[12745.170721]  r7:d65e9300 r6:d664ce00 r5:d5bf4000 r4:00000000
[12745.176450] [<c00226f4>] (do_exit) from [<c00230bc>] (do_group_exit+0x44/0xd4)
[12745.183733]  r7:d66ac520
[12745.186323] [<c0023078>] (do_group_exit) from [<c002c70c>] (get_signal+0x17c/0x60c)
[12745.194058]  r5:d5bf5edc r4:d5bf4000
[12745.197730] [<c002c590>] (get_signal) from [<c038d4c0>] (do_signal+0x8c/0x3d8)
[12745.205022]  r10:00000000 r9:d5bf4000 r8:b6bae5b8 r7:b6bae5bc r6:fffffe00 r5:00000001
[12745.212985]  r4:d5bf5fb0
[12745.215579] [<c038d434>] (do_signal) from [<c00116e8>] (do_work_pending+0xa8/0xec)
[12745.223212]  r10:00000000 r8:c000e9a8 r7:d5bf5fb0 r6:d5bf4000 r5:d5bf4000 r4:00000009
[12745.231224] [<c0011640>] (do_work_pending) from [<c000e828>] (work_pending+0xc/0x20)
[12745.238988]  r8:c000e9a8 r7:00000036 r6:b089bb44 r5:b1f15d30 r4:00000009 r3:b089bbac
[12745.246888] ---[ end trace f425fe4565343504 ]---

Can you help me fix this?
Thank you and excuse my bad english.

https://github.com/raspberrypi/linux/issues/817
Warning, not error. Everything still works even when this is tripped.
Are you actually seeing an issue, or just reporting the message?
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: 4003
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.
by byterg » Wed Jun 24, 2015 12:07 pm
Hello!
I write simple patch for support VIDIOC_S_CROP, unfortunately output image not changed.
Can you help me modify it for correct work?
Thank you and excuse my bad english.
Attachments
0001-bcm2835-camera.c-added-VIDIOC_S_CROP-support.patch.gz
VIDIOC_S_CROP support
(1.44 KiB) Downloaded 192 times
Posts: 56
Joined: Tue Jul 15, 2014 8:16 am
by 6by9 » Wed Jun 24, 2015 1:33 pm
byterg wrote:Hello!
I write simple patch for support VIDIOC_S_CROP, unfortunately output image not changed.
Can you help me modify it for correct work?
Thank you and excuse my bad english.

Thanks for the effort.

MMAL_PARAMETER_INPUT_CROP is using relative values, not absolute pixel counts, so a rectangle of 0,0,0x1000,0x1000 is the full field of view, having cropped the image to the output aspect ratio. This was the reason that I hadn't tackled it before - the way the Broadcom GPU code works didn't seem to quite map onto the V4L2 one, and I ran out of time. I'm not sure whether that has actually changed, or my previous reading was wrong. Perhaps I was looking to implement the selection API for cropping, composing, and scaling - I can't quite remember now.

Adding in clipping to the hardware limits, I think what you want is something along the lines of:
Code: Select all
mmal_rect.x = (min(v4l2.left, res->width) << 16 ) /res->width;
mmal_rect.y = (min(v4l2.top, res->height)  << 16 ) /res->height;
mmal_rect.w = (min(v4l2.width, res->width - v4l2.left) << 16) / res->width;
mmal_rect.h = (min(v4l2.height, res->height - v4l2.top) << 16 ) / res->height);

(You'd also managed to swap x and y offsets in you conversion).
If you save the values after the min functions, then I believe those are the values that should be returned on G_CROP.

edit I think you also need to implement .vidioc_cropcap/VIDIOC_CROPCAP before you can really make use of s_crop and g_crop. QV4L2 is probably your friend here as it provides an easy mechanism to make control changes whilst viewing the output. Report back where you get to with the above suggested changes and I'll try to do some debugging myself.
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: 4003
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.
by byterg » Wed Jun 24, 2015 2:29 pm
6by9 wrote:MMAL_PARAMETER_INPUT_CROP is using relative values, not absolute pixel counts, so a rectangle of 0,0,0x1000,0x1000 is the full field of view, having cropped the image to the output aspect ratio. This was the reason that I hadn't tackled it before - the way the Broadcom GPU code works didn't seem to quite map onto the V4L2 one, and I ran out of time. I'm not sure whether that has actually changed, or my previous reading was wrong. Perhaps I was looking to implement the selection API for cropping, composing, and scaling - I can't quite remember now.

Adding in clipping to the hardware limits, I think what you want is something along the lines of:
Code: Select all
mmal_rect.x = (min(v4l2.left, res->width) << 16 ) /res->width;
mmal_rect.y = (min(v4l2.top, res->height)  << 16 ) /res->height;
mmal_rect.w = (min(v4l2.width, res->width - v4l2.left) << 16) / res->width;
mmal_rect.h = (min(v4l2.height, res->height - v4l2.top) << 16 ) / res->height);

Thank you, 6by9!
Questions:
- you are sure in frame size limits 0x1000
- why you use shift on 16 if frame size limit is 0x1000
Thank you and excuse my bad english.

P.S. I try use your example, unfortunately result image not croped.
Posts: 56
Joined: Tue Jul 15, 2014 8:16 am
by 6by9 » Wed Jun 24, 2015 3:21 pm
byterg wrote:Thank you, 6by9!
Questions:
- you are sure in frame size limits 0x1000
- why you use shift on 16 if frame size limit is 0x1000
Thank you and excuse my bad english.

P.S. I try use your example, unfortunately result image not croped.

Oops, meant 0x10000, ie 1<<16 for a 16P16 fixed point value.
Comments in the headers (https://github.com/raspberrypi/userland ... era.h#L570) do declare
Code: Select all
 MMAL_RECT_T rect; /**< Crop rectangle as 16P16 fixed point values */

The same is used from the raspicam apps - https://github.com/raspberrypi/userland ... ol.c#L1342

I haven't built and tested a kernel for a while, but I will sync and kick off a build tonight to see what is going on.
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: 4003
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.
by byterg » Thu Jun 25, 2015 8:53 am
Unfortunately image not cropped ;(
Attachments
0001-bcm2835-camera.c-added-VIDIOC_S_CROP-VIDOC_G_CROP-an.patch.gz
patch v2: VIDIOC_S_CROP, VIDIOC_G_CROP and VIDIOC_CROPCAP support
(1.77 KiB) Downloaded 189 times
Posts: 56
Joined: Tue Jul 15, 2014 8:16 am
by chfakht » Thu Jul 09, 2015 11:24 pm
hi ,
when doing autoreconf -vfi : autoreconf: 'configure.ac' or 'configure.in' is required
plz help
Posts: 30
Joined: Sat Jul 04, 2015 4:38 pm
by 6by9 » Fri Jul 10, 2015 7:01 am
chfakht wrote:hi ,
when doing autoreconf -vfi : autoreconf: 'configure.ac' or 'configure.in' is required
plz help

Did you read the edit on the first post?
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.


If you do want to rebuild the latest v4l2-ctl, then they've changed the build process. In common with almost all Linux projects, there is a file called "INSTALL" in the v4l2-utils tree which includes full building instructions:
Building:
---------
]If you checked out the source repository you need to install the autotools
environment and gettext first.

The autotools/gettext should be updated to the version that are shipped
on your distro. This can be done by running:
$ ./bootstrap.sh

Then you need to configure any any desired options with:
$ ./configure

You can get a summary of possible configurations via the --help option.
If used without arguments, it will set the install prefix to /usr/local/.

After configuration you need to start the build process with:
$ make

Installing:
-----------
To install it at the prefix configured by ./configure, do, as root:
# make install
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: 4003
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.
by airsports » Sat Jul 11, 2015 7:05 pm
Hello,

Is V4L2 driver supported with fully updated raspbian (with rpi-update)?
I was using a working setup of raspberry camera with v4l2 driver + motion software. It stopped working after I ran "rpi-update". I think there was a message during the update warning that this update is rather major and could break things.

When I run dmesg, I see looping messages:
[ 455.414274] bcm2835-v4l2: vidioc_s_fmt_vid_cap: failed to setup mmal components: -62
[ 459.085974] bcm2835_v4l2: error 0 waiting for sync completion
...

When I look at /var/log/messages I see:
Jul 11 21:59:03 raspberrypi motion: [1] cap.driver: "bm2835 mmal"
Jul 11 21:59:03 raspberrypi motion: [1] cap.card: "mmal service -1089743524.-10897"
Jul 11 21:59:03 raspberrypi motion: [1] cap.bus_info: "platform:bcm2835-v4l2"
Jul 11 21:59:03 raspberrypi motion: [1] cap.capabilities=0x85200005
Jul 11 21:59:03 raspberrypi motion: [1] - VIDEO_CAPTURE
Jul 11 21:59:03 raspberrypi motion: [1] - VIDEO_OVERLAY
Jul 11 21:59:03 raspberrypi motion: [1] - READWRITE
Jul 11 21:59:03 raspberrypi motion: [1] - STREAMING
Jul 11 21:59:03 raspberrypi motion: [1] Test palette YU12 (1040x720)
Jul 11 21:59:06 raspberrypi motion: [1] Config palette index 8 (YU12) doesn't work.
Jul 11 21:59:06 raspberrypi motion: [1] Supported palettes:
Jul 11 21:59:06 raspberrypi motion: [1] 0: YU12 (4:2:0, packed YUV)
Jul 11 21:59:06 raspberrypi motion: [1] 1: YUYV (4:2:2, packed, YUYV)
Jul 11 21:59:06 raspberrypi motion: [1] 2: RGB3 (RGB24 (LE))
Jul 11 21:59:06 raspberrypi motion: [1] 3: JPEG (JPEG)
Jul 11 21:59:06 raspberrypi motion: [1] 4: H264 (H264)
Jul 11 21:59:06 raspberrypi motion: [1] 5: MJPG (MJPEG)
Jul 11 21:59:06 raspberrypi motion: [1] 6: YVYU (4:2:2, packed, YVYU)
Jul 11 21:59:06 raspberrypi motion: [1] 7: VYUY (4:2:2, packed, VYUY)
Jul 11 21:59:06 raspberrypi motion: [1] 8: UYVY (4:2:2, packed, UYVY)
Jul 11 21:59:06 raspberrypi motion: [1] 9: NV12 (4:2:0, packed, NV12)
Jul 11 21:59:06 raspberrypi motion: [1] 10: BGR3 (RGB24 (BE))
Jul 11 21:59:06 raspberrypi motion: [1] 11: YV12 (4:2:0, packed YVU)
Jul 11 21:59:06 raspberrypi motion: [1] 12: NV21 (4:2:0, packed, NV21)
Jul 11 21:59:06 raspberrypi motion: [1] 13: BGR4 (RGB32 (BE))
Jul 11 21:59:06 raspberrypi motion: [1] Selected palette YU12
Jul 11 21:59:06 raspberrypi motion: [1] Test palette YU12 (1040x720)
...
And looping from here.

I am running "Raspbian GNU/Linux 7 (wheezy)"
Linux raspberrypi 4.0.7+ #802 PREEMPT Wed Jul 8 17:35:23 BST 2015 armv6l GNU/Linux

I am running this camera for security surveillance, would appreciate any suggestions on how to restore this camera to working condition.
Posts: 3
Joined: Wed Feb 12, 2014 8:14 am