New 1062 cam, set_saturation and set_brightness problems


I’m testing the latest 1062 cam. Here is the initialization:

then if I call: sensor.set_contrast(3), or set_contrast(-3), I clearly see the difference in the output image.
But calling sensor.set_saturation(x) or sensor.set_brightness(x) does nothing.
Am I missing something?

Those features are implemented for the OV5640. However, honestly they are kinda obsolete features. I’d avoid using them at all.

We followed the reference manual on implementation. But, they are basically useless. You want to use auto gain control, and auto exposure control.

Try this out if you want to boost the camera image: Spot in image (not homogeneous) - #9 by kwagyeman

Will probably merge something like this into main soon since it improves the image quality. However, it’s not quite there yet.

it’s a little better, thanks

what about sensor.set_auto_exposure with the new 1062 cam? when I set it to true, if the light decreases, the image goes very dark, and printing: print(f"exposure: {sensor.get_exposure_us()}") always return 57200, as if set_auto_exposure(true) didn’t work…

2nd question, I’m trying to adjust the exposure in my code:

import sensor, image, time

sensor.set_auto_exposure(False, exposure_us=57200*1)
sensor.skip_frames(time = 500)
clock = time.clock()

min_exposure_us = 57200
max_exposure_us = 57200 * 10
target_brightness = 20
tolerance = 4
exposure_step = 57200

    img = sensor.snapshot()
    stats = img.get_statistics()
    brightness = stats[0]

    img.draw_string(0, 0, "Brightness: %.2f" % brightness, color=(255, 255, 255))
    img.draw_string(0, 10, "Exposure: %d us" % sensor.get_exposure_us(), color=(255, 255, 255))

    if brightness < target_brightness - tolerance:
        exposure_us = sensor.get_exposure_us()
        if exposure_us < max_exposure_us:
            sensor.set_auto_exposure(False, exposure_us=min(exposure_us + exposure_step, max_exposure_us))
    elif brightness > target_brightness + tolerance:
        exposure_us = sensor.get_exposure_us()
        if exposure_us > min_exposure_us:
            sensor.set_auto_exposure(False, exposure_us=max(exposure_us - exposure_step, min_exposure_us))

    print(f"clock: {clock.avg()} ms")
    img.draw_string(240, 0, "%.2f ms" % clock.avg(), color=(255, 255, 255))

The change of exposure works, but what is weird is that clock.avg() keeps increasing, even when there is no more light change (so " if brightness < target_brightness - tolerance:" and the elif are not called anymore)

If I put both “sensor.set_auto_exposure” calls in comments, the clock.avg is constant (but of course the exposure doesn’t change)

I don’t understand what’s happening…

Yeah, the camera will lower the exposure to increase the gain.

However, given what I discovered with the lens correction registers I think the camera brightness can be improved by turning lens correction back on. I just haven’t had time to work on this.

The average can move rather slowly, sometimes to its final value. We use a running average that doesn’t drop old samples. So, if the initial values are widely different from the final then it will take a while for the average to remove the bias of the original samples.