IMX462 (SKU B0444) long exposure issue

I am setting up a system to use this SKU for astrophotography. I successfully get it working, taking images as intended with 3-4 seconds long exposure and captured in DNG raw format using libcamera-still command.

But when I try to automate the process using a python script (which I have been using for a Pi HQ IMX477 camera for many months), then a problem appears. The scipt will ask the camera to take a number of images in sequence so that it can be processed by astrophoto softwares.

For long exposures, it is necessary to disable the AEC/AGC alogrithm in Pi to avoid a long delay where the Pi will take some sample frames to set the exposure etc for each frame. I specify the shutter speed, the gain, the awb and no preview. When I use the HQ camera, the cycle time for a 4 second capture is about 10s. However with the B0444 the cycle time goes up to almost 30s. It seems that the libcamera-still app is still taking frames for calibration. The only setting that can really override this is to specify awbgains figures. Then the cycle time fall back to about 10s. But by doing so, the camera become unstable and not every images is exposed as intended. Only 50% of the images are successful. I need to revert back to use --awb option instead of --awbgains to achieve 100% success. But then the very long cycle time comes. Is there something in the firmware that make setting awbgains become unstable in the B0444?

To provide more info on this. I tested different options for a 3s exposure, by directly using the terminal. Here is what I get:

libcamera-still --immediate --nopreview -t 50 -r --width 1920 --height 1080 --shutter 3000000 --gain 50 -o test1.jpg

The above command does not specify any white balance setting, and the images come out good consistently. Cycle time is about 18-20s.

libcamera-still --immediate --nopreview -t 50 -r --width 1920 --height 1080 --shutter 3000000 --gain 50 --awb daylight -o test2.jpg

The above command specify a daylight white balance setting. The images come out good consistently. Cyle time again is about 20s.

libcamera-still --immediate --nopreview -t 50 -r --width 1920 --height 1080 --shutter 3000000 --gain 50 --awbgains 1,1 -o test3.jpg

The above command specify a white balance gain setting for the red and blue channel. The images are wrong which is dark completely. The whole command finishs in about 2-3s.

So somehow the camera does not understand the --awbgains option, which is a standard libcamera-still option.
Any advices?

I do more tests and I am more confused.

This time I try to play around with the preview function and find that if I do not add the “–immediate” option, then the awbgains option is not creating any problem. So the best I can get now is with:

libcamera-still --nopreview -t 50 -r --width 1920 --height 1080 --shutter 3000000 --gain 50 --awbgains 1.2,1.2 -o test.jpg

The cycle time is about 15s. If I increase shutter to 4s, the cycle time is about 22s. So it seems that the overall cycle time is about 5X the desired shutter time. This is still disturbing and confusing.

UB_Astro: Have you got the B0444 working satisfactorily?

I am getting jpgs that look, by eye, to be actually exposed differently from the --shutter that was requested even though exiftool reports an exposure time that matches --shutter. The included image shows thumbnails of some results. The number in the filenames gives the --shutter setting used. All were taken with minutes of each other.

I have posted on this issue (search B0444 in this forum) and as well tried to contact support at arducam but have gotten no replies. I have read through your post on the RPi forums.

Do you have any suggestions?

Hi jimz, to make a long story short, yes I managed to make this working to a satisfactory level. The main issue I faced was the strange behavior that with the --immediate option in libcamera-still I get a high percentage of failed exposure. The breakthrough I got did not come from this forum unfortunately but the official Raspberry Pi forum. It was noted in that forum that IMX462 is not stable when it starts, so occasionly the very first frame it delivers is a bad frame. When I used the --immediate option, the camera is forced to deliver the first frame as the final frame so I saw a number of bad frame. Using libcamera-still you essentially starts the camera everytime you call it. I do not know what command you use but for libcamera-still without --immedate option, I think it will take 3-4 frames to calibrate the gain, white balance etc. If the first frame of this shot is bad, then the average calibrated setting will go wrong and you get an image with strange exposure results. Maybe that’s the reason?

I solve the problem by switching to picamera2 instead of libcamera apps. In picamera2 you start the camera once and you then go on capturing images unless you stop it. Still you might get a first bad frame but that’s 1 frame instead of randomly appearing bad frames. Knowing this I can just skip this first image and the rest are good. Not a perfect solution, but working OK for me in my application.