-
Notifications
You must be signed in to change notification settings - Fork 240
Description
Describe the bug
This is a intermittent bug, so it is hard to be concise. I am giving lots of details in the hope you may have an idea that helps us isolate the bug.
On the OpenFlexure Microscope we have quite a string custom lens shading table to adjust for the light coming from a microscope objective. We tend to have the main stream at a preview rate of about 0.5MP (plus a lores stream for some other algorithms). When we scan images we switch the main stream to the full sensor resolution, and we stop streaming it (streaming the lores to our client).
During the switchover sometimes we seem to have one of the lens shading tables not load into the camera, as we get either strong vignetting or sometimes weird colours plus vignetting. When we cancel the scan (switching the streams back again) everything will reload fine. This is very intermittent, it may happen one in 30 scans. There are no obvious warnings or setting changes we can poll to detect it automatically.
To Reproduce
This is where things get weird. So I cannot directly reproduce it in an easy script as of yet, but I can give some background to how we are doing things and what we have learned from testing.
We always use create_video_configuration to set up the camera. If we are in scan mode (where we see this bug) then we are using start_recording and start_encoder on the lores stream.
We always pass our control values to the controls arg of create_video_configuration. We noticed when using the PiCamera2 that if we pass an ExposureTime that was read from the camera, then the camera will always round down to the next available value. This means that over time the ExposureTime "drifts" downwards.
When we had the exposure time drifting on the PiCamera 2 we saw this bug. Suddenly the stream might be bright green and vignettetted (both in the lores stream and the captured images). We have fixed this by always requesting the controls with 1 added to ExposureTime.
We are now using the PiCamera HQ. Simply adding 1 to the ExposureTime doesn't reliably stop exposure drifting. (We have a very slow unit test to check for this, but again it wrapped up in a lot of our framework so hard to provide a minimal example). Now with the PiCamera HQ we see this bug re-appearing; we seem to be able to make it less frequent by adding 5 rather than 1 to the requested ExposureTime. But at long exposure times adding 5 doesn't stop the ExposureTime drifting.
My hope is that if we can get to the bottom of the Exposure Time drifting issue this will fix the bug I am talk about. Sorry that this is sort of a double bug report.
Console Output, Screenshots
This is a stitched microscope image with an HQ camera without the intermittent bug:
But sometimes we get something like:
Note the The images overlap by about 20%, we don't do averaging we choose at each pixel location we take the pixel directly from the image whos centre is closest to prevent spurious averaging artifacts, so this isn't a weird averaging bug.
Hardware :
This is with a Pi 4 in an OpenFlexure Microscope. We have seen this in some form with PiCamera v2, but as described above we seems to have fixed it. The above report is with the PiCamera HQ

