[libcamera-devel] How to activate AGC control in libcamera, or set the GAIN/EXPOSURE parameter by v4l2 command.

tetsuya.nomura at soho-enterprise.com tetsuya.nomura at soho-enterprise.com
Mon Oct 5 06:36:41 CEST 2020


Dear David-san

According to your instruction, I could confirm the AGC is working, and I could get brighter image under dark condition by changing the "gain" parameter 
>From "1.0, 2.0, 4.0, 6.0, 6.0" to "1.0, 2.0, 4.0, 8.0, 16.0"

However, when changing the y_target value, I could not see the significant change.
It would be great if you show me the example how to change the y_target parameter to get the brighter image under dark condition, if possible.
I'd like to understand how to modify the .json file for fine tuning.

Best Regards,

NOMURA

-----Original Message-----
From: tetsuya.nomura at soho-enterprise.com <tetsuya.nomura at soho-enterprise.com> 
Sent: Tuesday, September 29, 2020 6:33 PM
To: 'David Plowman' <david.plowman at raspberrypi.com>
Cc: 'Laurent Pinchart' <laurent.pinchart at ideasonboard.com>; 'Kieran Bingham' <kieran.bingham at ideasonboard.com>; 'libcamera-devel at lists.libcamera.org' <libcamera-devel at lists.libcamera.org>
Subject: RE: [libcamera-devel] How to activate AGC control in libcamera, or set the GAIN/EXPOSURE parameter by v4l2 command.

Dear David-san

I appreciate your valuable advice.
I'll try it!

Please wait for my report.

Best Regards,

NOMURA
-----Original Message-----
From: David Plowman <david.plowman at raspberrypi.com>
Sent: Tuesday, September 29, 2020 6:21 PM
To: tetsuya.nomura at soho-enterprise.com
Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com>; Kieran Bingham <kieran.bingham at ideasonboard.com>; libcamera-devel at lists.libcamera.org
Subject: Re: [libcamera-devel] How to activate AGC control in libcamera, or set the GAIN/EXPOSURE parameter by v4l2 command.

Hi Nomura-san

Thanks for your reply. If you want to change the AEC/AGC target brightness go to the file

libcamera/src/ipa/raspberrypi/data/imx219.json

Look for the string "y_target". The numbers there are pairs of values <brightness>, <target>. <brightness> is the estimated actual brightness of the scene, in lux, and <target> is the basic target value for the AEC/AGC. It's given pre-gamma and as a proportion of the full dynamic range of the pixels. (Note: you may need to re-install libcamera to be sure it's reading the updated file.)

Further documentation is of course available here:
https://www.raspberrypi.org/documentation/linux/software/libcamera/rpi_SOFT_libcamera_1p0.pdf
(section 5.8)

Bear in mind that you may in some circumstances reach the limit of the exposure time and analogue gain. Search again for the string "exposure_modes"; you'll be using the one named "normal" (unless you have changed it). These parameters are also documented in the same place.

Best regards
David

On Tue, 29 Sep 2020 at 10:01, <tetsuya.nomura at soho-enterprise.com> wrote:
>
> Dear David-san
>
> I'll investigate the DNG file how the AGC working.
> And if possible, could you tell me how to change AEC/AGC target brighter?
>
> Best Regards,
>
> NOMURA
>
> #2020.7.1本社移転いたしました。
> = = = = = = = = = = = = = = = = = = = = =
> 双峰エンタープライズ株式会社 野村 哲哉
> 〒243-0014 神奈川県厚木市旭町四丁目11番26号 ジェントビル2F
> URL: https://soho-enterprise.com
> Email: tetsuya.nomura at soho-enterprise.com
> Phone: 090-1839-1135
> = = = = = = = = = = = = = = = = = = = = =
>
> -----Original Message-----
> From: David Plowman <david.plowman at raspberrypi.com>
> Sent: Tuesday, September 29, 2020 4:03 PM
> To: tetsuya.nomura at soho-enterprise.com
> Cc: Laurent Pinchart <laurent.pinchart at ideasonboard.com>; Kieran 
> Bingham <kieran.bingham at ideasonboard.com>;
> libcamera-devel at lists.libcamera.org
> Subject: Re: [libcamera-devel] How to activate AGC control in libcamera, or set the GAIN/EXPOSURE parameter by v4l2 command.
>
> Hello again
>
> Thanks to everyone for trying to sort this out! Let me try and explain what I've understood so far.
>
> 1. AGC and AEC are not separate in the AGC/AEC algorithm that runs on the Pi under libcamera.
>
> 2. When qcam saves a jpeg it does *not* record exposure time and analogue gain in the exif data (I've checked this since I last posted).
>
> 3. However, when you save a DNG file ("qcam -s role=viewfinder -s
> role=stillraw") you should find both in the exif data. It doesn't 
> actually record analogue gain directly, I think it multiplies it by
> 100 and saves it as the "ISO".
>
> 4. I can't explain why you're not finding the saved jpeg files. The default folder is I think ~/Pictures, but I don't know why you don't see a file.
>
> 5. The log you've posted just above looks fine, though I think it is stopping before you click to save the jpeg file?
>
> 6. Given that you are able to save DNG files, can you share the exposure time and ISO values from the exif data for images captured in both bright and dark conditions? This would tell us what the AGC is doing.
>
> 7. Testing with the old Raspberry Pi "raspi-cam" apps doesn't really show anything. It's a completely different stack and the control algorithms are all different.
>
> Thanks, and sorry that this all seems to be so confusing!
>
> Best regards
> David
>
> On Tue, 29 Sep 2020 at 01:41, <tetsuya.nomura at soho-enterprise.com> wrote:
> >
> > Dear Laurent-san
> >
> > I don't see the error message.
> >
> > Here is the message log.
> > ---
> > pi at raspberrypi:~/libcamera/build/src/qcam $ qcam
> > qt5ct: using qt5ct plugin
> > [1:02:58.663793968] [1179]  INFO Camera camera_manager.cpp:287 
> > libcamera v0.0.0+1805-f999ee85 [1:02:58.837343652] [1179]  INFO 
> > Camera
> > camera.cpp:797 configuring streams: (0) 800x600-BGR888 
> > [1:02:58.838269394] [1181]  INFO RPI raspberrypi.cpp:116 Mode:
> > 3280x2464 fmt BG10 Score: 2592.49 (best 2592.49) [1:02:58.838444061] 
> > [1181]  INFO RPI raspberrypi.cpp:116 Mode: 1920x1080 fmt BG10 Score:
> > 2066.67 (best 2066.67) [1:02:58.838541969] [1181]  INFO RPI
> > raspberrypi.cpp:116 Mode: 1640x1232 fmt BG10 Score: 1874.49 (best
> > 1874.49) [1:02:58.838635765] [1181]  INFO RPI raspberrypi.cpp:116
> > Mode: 640x480 fmt BG10 Score: 2060 (best 1874.49) 
> > [1:02:58.838741525] [1181]  INFO RPI raspberrypi.cpp:116 Mode: 3280x2464 fmt BA81 Score:
> > 3592.49 (best 1874.49) [1:02:58.838833525] [1181]  INFO RPI
> > raspberrypi.cpp:116 Mode: 1920x1080 fmt BA81 Score: 3066.67 (best
> > 1874.49) [1:02:58.838924155] [1181]  INFO RPI raspberrypi.cpp:116
> > Mode: 1640x1232 fmt BA81 Score: 2874.49 (best 1874.49) 
> > [1:02:58.839013414] [1181]  INFO RPI raspberrypi.cpp:116 Mode:
> > 640x480 fmt BA81 Score: 3060 (best 1874.49) [1:02:58.839107303] 
> > [1181]  INFO RPI raspberrypi.cpp:116 Mode: 3280x2464 fmt pBAA Score:
> > 2092.49 (best
> > 1874.49) [1:02:58.839198377] [1181]  INFO RPI raspberrypi.cpp:116
> > Mode: 1920x1080 fmt pBAA Score: 1566.67 (best 1566.67) 
> > [1:02:58.839310914] [1181]  INFO RPI raspberrypi.cpp:116 Mode:
> > 1640x1232 fmt pBAA Score: 1374.49 (best 1374.49) [1:02:58.839454229] 
> > [1181]  INFO RPI raspberrypi.cpp:116 Mode: 640x480 fmt pBAA Score:
> > 1560 (best 1374.49) [1:02:58.839612156] [1181]  INFO RPI
> > raspberrypi.cpp:496 Sensor: /base/soc/i2c0mux/i2c at 1/imx219 at 10 - 
> > Selected mode: 1640x1232-pBAA [1:02:58.957246497] [1181]  INFO 
> > RPI_S_W
> > staggered_ctrl.cpp:36 Init ctrl 0x00980911 with delay 2 
> > [1:02:58.957479609] [1181]  INFO RPI_S_W staggered_ctrl.cpp:36 Init 
> > ctrl 0x009e0903 with delay 1 Zero-copy enabled [1:02:58.993835570] 
> > [1181]  INFO RPISTREAM rpi_stream.cpp:120 No buffers available for 
> > ISP
> > Output0 [1:02:58.993962033] [1181]  INFO RPISTREAM
> > rpi_stream.cpp:120 No buffers available for ISP Output0 
> > [1:02:59.100047413] [1181]  INFO RPI raspberrypi.cpp:1397 Dropping 
> > frame at the request of the IPA (5
> > left) [1:02:59.147212816] [1181]  INFO RPI raspberrypi.cpp:1397 
> > Dropping frame at the request of the IPA (4 left) 
> > [1:02:59.164827176] [1181]  INFO RPI raspberrypi.cpp:1397 Dropping 
> > frame at the request of the IPA (3 left) [1:02:59.199072801] [1181] 
> > INFO RPI
> > raspberrypi.cpp:1397 Dropping frame at the request of the IPA (2
> > left) libpng warning: iCCP: known incorrect sRGB profile 
> > [1:02:59.229348050] [1181]  INFO RPI raspberrypi.cpp:1397 Dropping 
> > frame at the request of the IPA (1 left) [1:02:59.262649340] [1181] 
> > INFO RPI
> > raspberrypi.cpp:1397 Dropping frame at the request of the IPA (0
> > left)
> > seq: 000006 bytesused: 1440000 timestamp: 3779256059000 fps: 0.00
> > seq: 000007 bytesused: 1440000 timestamp: 3779289386000 fps: 30.01
> > seq: 000008 bytesused: 1440000 timestamp: 3779322716000 fps: 30.00
> > seq: 000009 bytesused: 1440000 timestamp: 3779356040000 fps: 30.01
> > seq: 000010 bytesused: 1440000 timestamp: 3779389368000 fps: 30.00
> > seq: 000011 bytesused: 1440000 timestamp: 3779422699000 fps: 30.00
> >
> > ---
> >
> > Best Regards,
> >
> > NOMURA
> >
> > -----Original Message-----
> > From: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> > Sent: Tuesday, September 29, 2020 9:20 AM
> > To: tetsuya.nomura at soho-enterprise.com
> > Cc: 'David Plowman' <david.plowman at raspberrypi.com>; 'Kieran Bingham'
> > <kieran.bingham at ideasonboard.com>;
> > libcamera-devel at lists.libcamera.org
> > Subject: Re: [libcamera-devel] How to activate AGC control in libcamera, or set the GAIN/EXPOSURE parameter by v4l2 command.
> >
> > Hello Nomura-san,
> >
> > On Tue, Sep 29, 2020 at 08:55:28AM +0900, tetsuya.nomura at soho-enterprise.com wrote:
> > > Dear Laurent-san
> > >
> > > Thank you for your advice.
> > >
> > > I've tried the "Save As" button, specify the file name, and saved, but I cannot find it there.
> >
> > I'm surprised. If you run qcam in a console, does it print an error message when it fails to save ?
> >
> > > On the other hand, I could store the raw data starting with " qcam -s role=viewfinder -s role=stillraw".
> >
> > --
> > Regards,
> >
> > Laurent Pinchart
> >
>



More information about the libcamera-devel mailing list