# New 1062 cam, set\_saturation and set\_brightness problems

**URL:** <https://forums.openmv.io/t/new-1062-cam-set-saturation-and-set-brightness-problems/9531>\
**Category:** OpenMV Boards\
**Created:** [April 30, 2024, 9:20pm UTC](https://forums.openmv.io/t/new-1062-cam-set-saturation-and-set-brightness-problems/9531 "2024-04-30T21:20:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jcmag](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/jcmag/32/2767_2.png) [@jcmag](https://forums.openmv.io/u/jcmag)\
**Post date:** [April 30, 2024, 9:20pm UTC](https://forums.openmv.io/t/new-1062-cam-set-saturation-and-set-brightness-problems/9531/1 "2024-04-30T21:20:19Z")

</div>

Hi,

I’m testing the latest 1062 cam. Here is the initialization:  
sensor.reset()  
sensor.set\_pixformat(sensor.RGB565)  
sensor.set\_framesize(sensor.QVGA)

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?

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [April 30, 2024, 11:34pm UTC](https://forums.openmv.io/t/new-1062-cam-set-saturation-and-set-brightness-problems/9531/2 "2024-04-30T23:34:49Z")

</div>

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

> <https://github.com/openmv/openmv/blob/master/src/omv/sensors/ov5640.c#L986>

> <https://github.com/openmv/openmv/blob/master/src/omv/sensors/ov5640.c#L1003>

> <https://github.com/openmv/openmv/blob/master/src/omv/sensors/ov5640.c#L1020>

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

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [April 30, 2024, 11:36pm UTC](https://forums.openmv.io/t/new-1062-cam-set-saturation-and-set-brightness-problems/9531/3 "2024-04-30T23:36:16Z")

</div>

Try this out if you want to boost the camera image: [Spot in image (not homogeneous) - #9 by kwagyeman](https://forums.openmv.io/t/spot-in-image-not-homogeneous/9344/9)

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

---

<div class="post-metadata">

**Author:** ![jcmag](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/jcmag/32/2767_2.png) [@jcmag](https://forums.openmv.io/u/jcmag)\
**Post date:** [May 1, 2024, 11:13am UTC](https://forums.openmv.io/t/new-1062-cam-set-saturation-and-set-brightness-problems/9531/4 "2024-05-01T11:13:23Z")

</div>

it’s a little better, thanks

---

<div class="post-metadata">

**Author:** ![jcmag](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/jcmag/32/2767_2.png) [@jcmag](https://forums.openmv.io/u/jcmag)\
**Post date:** [May 21, 2024, 1:04pm UTC](https://forums.openmv.io/t/new-1062-cam-set-saturation-and-set-brightness-problems/9531/5 "2024-05-21T13:04:39Z")

</div>

Hi,  
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…

---

<div class="post-metadata">

**Author:** ![jcmag](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/jcmag/32/2767_2.png) [@jcmag](https://forums.openmv.io/u/jcmag)\
**Post date:** [May 21, 2024, 3:22pm UTC](https://forums.openmv.io/t/new-1062-cam-set-saturation-and-set-brightness-problems/9531/6 "2024-05-21T15:22:31Z")

</div>

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

```auto
import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_auto_exposure(False, exposure_us=57200*1)
sensor.set_auto_gain(False)
sensor.set_auto_whitebal(False)
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

while(True):
    clock.tick()
    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…

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [May 21, 2024, 6:01pm UTC](https://forums.openmv.io/t/new-1062-cam-set-saturation-and-set-brightness-problems/9531/7 "2024-05-21T18:01:49Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kwagyeman](https://yyz1.discourse-cdn.com/flex029/user_avatar/forums.openmv.io/kwagyeman/32/4_2.png) [@kwagyeman](https://forums.openmv.io/u/kwagyeman)\
**Post date:** [May 21, 2024, 6:04pm UTC](https://forums.openmv.io/t/new-1062-cam-set-saturation-and-set-brightness-problems/9531/8 "2024-05-21T18:04:37Z")

</div>

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.
