Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4455

Troubleshooting • Camera woes migrating from raspistill to rpicam-still

$
0
0
Hello all,

I'm at the limit of my own troubleshooting abilities on this one. We have a Pi3 B+ running the HQ camera for a computer vision application. We need to integrate some new software with the system, unfortunately the existing Pi is running an ancient copy of stretch which doesn't have distros for a new enough version of python and a few other libraries we need. I spun up a new version of bookworm only to find that the old camera raspistill interface is gone and has been replaced with the libcamera based rpicam-still.

As we use the images semi-quantitatively consistent acquisition parameters are important so the old raspistill-based implementation used a fixed ISO/gain, shutter speed, and white balance color gains. However when translating those same settings to rpicam-still the resultant image appears considerably less exposed.

An example from the old system, acquired with the following command:

Code:

raspistill -o test_img.jpg -rot 0 -br 50 -co 0 -sa 0 -sh 0 -ex auto -ev 0 -awbg 3.4795,1.1079 -ss 100 -ISO 100 -v -w 1332 -h 990
https://imgur.com/a/fY4YBaw
And the associated metadata from exiftool:

Code:

File Type                       : JPEGFile Type Extension             : jpgMIME Type                       : image/jpegExif Byte Order                 : Big-endian (Motorola, MM)Make                            : RaspberryPiCamera Model Name               : RP_testcX Resolution                    : 72Y Resolution                    : 72Resolution Unit                 : inchesModify Date                     : 2024:07:05 22:20:20Y Cb Cr Positioning             : CenteredExposure Time                   : 1/8772F Number                        : 2.0Exposure Program                : Aperture-priority AEISO                             : 100Exif Version                    : 0220Date/Time Original              : 2024:07:05 22:20:20Create Date                     : 2024:07:05 22:20:20Components Configuration        : Y, Cb, Cr, -Shutter Speed Value             : 1/8772Aperture Value                  : 2.0Brightness Value                : 1.67Max Aperture Value              : 2.0Metering Mode                   : Center-weighted averageFlash                           : No FlashFocal Length                    : 3.0 mmMaker Note Unknown Text         : (Binary data 338 bytes, use -b option to extract)Flashpix Version                : 0100Color Space                     : sRGBExif Image Width                : 1332Exif Image Height               : 990Interoperability Index          : R98 - DCF basic file (sRGB)Exposure Mode                   : AutoWhite Balance                   : AutoCompression                     : JPEG (old-style)Thumbnail Offset                : 1056Thumbnail Length                : 24576Image Width                     : 1332Image Height                    : 990Encoding Process                : Baseline DCT, Huffman codingBits Per Sample                 : 8Color Components                : 3Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)Aperture                        : 2.0Image Size                      : 1332x990Megapixels                      : 1.3Shutter Speed                   : 1/8772Thumbnail Image                 : (Binary data 24576 bytes, use -b option to extract)Focal Length                    : 3.0 mmLight Value                     : 15.1
Plus the pertinent stuff in the Maker Note:

Code:

{ev=-1 mlux=-1 exp=114 ag=592 focus=255 gain_r=3.636 gain_b=1.230 greenness=0 ccm=8254,-3916,-238,-492,6632,-2042,266,-1710,5548,0,0,0 md=0 tg=435 435 oth=435 615 b=0 f=435 615 fi=0 ISP Build Date: Aug 15 2019, 12:08:19 VC_BUILD_ID_VERSION: 0e6daa5106dd4164474616408e0dc24f997ffcf3 (clean) VC_BUILD_ID_USER: dom VC_BUILD_ID_BRANCH: master '}
So the actual shutter speed was 114 us, the analog gain corresponding to 100 ISO is 592/256 = 2.3125 and while the color gains aren't quite the target they're close enough.

Now the new image on the bookworm install, acquired with

Code:

rpicam-still -o test_img.jpg --exposure normal --awbgains 3.4795,1.1079 --shutter 100 --analoggain 2.3125 --verbose --metadata test_img.txt --width 1332 --height 990
looks like this:
https://imgur.com/a/AKmelm3

The Exiftool metadata is lacking.

Code:

File Type                       : JPEGFile Type Extension             : jpgMIME Type                       : image/jpegExif Byte Order                 : Little-endian (Intel, II)Make                            : Raspberry PiCamera Model Name               : imx477Software                        : rpicam-appsModify Date                     : 2024:07:03 13:40:22Exposure Time                   : 1/10989ISO                             : 254Date/Time Original              : 2024:07:03 13:40:22Create Date                     : 2024:07:03 13:40:22Compression                     : JPEG (old-style)Thumbnail Offset                : 304Thumbnail Length                : 5454Image Width                     : 1332Image Height                    : 990Encoding Process                : Baseline DCT, Huffman codingBits Per Sample                 : 8Color Components                : 3Y Cb Cr Sub Sampling            : YCbCr4:2:0 (2 2)Image Size                      : 1332x990Megapixels                      : 1.3Shutter Speed                   : 1/10989Thumbnail Image                 : (Binary data 5454 bytes, use -b option to extract)
but the output of the --metadata option seems to have most of the content of the maker note field from raspistill:

Code:

{    "ExposureTime": 91,    "SensorTimestamp": 4772631734000,    "ScalerCrop": "(0, 14)/4056x3014",    "ColourCorrectionMatrix": [ 2.306927, -0.974214, -0.332713, -0.308010, 2.328706, -1.020706, -0.178458, -0.556480, 1.734927 ],    "FocusFoM": 2727,    "ColourTemperature": 8789,    "ColourGains": [ 3.479500, 1.107900 ],    "DigitalGain": 1.099371,    "AeLocked": true,    "SensorTemperature": 23.000000,    "Lux": 36973.070312,    "FrameDuration": 24994,    "SensorBlackLevels": [ 4096, 4096, 4096, 4096 ],    "AnalogueGain": 2.311512}
While there are some small differences in the gains and shutter speed actually achieved, they're not enough to explain the differences in the image exposure. After some testing, it seems like rpicam-still needs about twice the exposure of raspistill to achieve similar image histograms.

Anyone have any ideas on why this is happening and how I can fix it (preferably without needing to manually run tests to find new acquisition settings that are "close enough")?

Statistics: Posted by asloan — Fri Jul 12, 2024 9:16 pm — Replies 0 — Views 4



Viewing all articles
Browse latest Browse all 4455

Trending Articles