Open cornato55 opened 3 months ago
Hi, there is unfortunately no way to adjust the weight of the differing metering zones at runtime.
However, you could add some simple AEC/AGC type processing of your own to adjust the exposure target so that you get a better result. I'd try something like this.
Define a low resolution stream as part of your preview configuration which you can use to monitor the brightness of different parts of the image. Maybe set it to something like 256x192 to start with. A YUV420 image would do - you could just look at the greyscale part of the image (the first 192 rows, in this case, of the array you get back).
Use numpy to find the average brightness of the area of interest. It it's too bright, set the EV to -0.5 (picam2.set_controls('ExposureValue': -0.5}
). Wait a few frames for it to take effect.
Now repeat. If it's still too bright, subtract another 0.5. If it's too dark, add 0.5. You'll have to experiment a bit, but I'm sure you get the idea.
Might that work for you?
I made a program that uses a camera to take a photo, that photo is then processed with an April Tag script to find April tags in it, it is used for inventory tracking. The issue is that the camera is outside and some parts of the day there are massive shadows because of the building. During these parts of the day a lot of the image is washed out and the program can't find the April tags in it.
There is a grid pattern we use to locate the April Tags, and I have a custom script setup that sets separate Auto-Focus areas for each grid pattern to be sure that grid is in focus since they are so far apart. I want to set the custom Auto-Exposure setting to use the same coordinates so that the Exposure and Focus are perfect allowing us to see all the tags in that area.
I'm using a Raspberry Pi 5 and an Arducam OwlSight OV64A40 64Mp camera sensor. It is being processed using pupil-labs April Tag detector script. Here are the camera's settings that produced the picture above.
The camera iterates over the AOI outlined in another script to set the autofocus. So, if there are 5 AOIs, it will take 5 pictures adjusting the focus for each AOI. To set up the AOIs when you start the program it takes an initial photo and prompts the user the make sectors using Inkscape and edit geometrical shapes. The shape's xml data is imported and converted to a text file that is read as coordinates.
There is a lot of code and different scripts, I don't want to make a wall of text here. I just need to find a way to compensate for fluctuating lighting conditions to allow my program to detect April Tags as best as possible.