Color blob tracking with fixed white balance

Dear Sirs,
I have met following negative experience with H7 model.
My aim is tracking color blobs with repeatable result after cycling power. Following commands are used to activate camera:
sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.set_auto_gain(False, 5.744431)
sensor.set_auto_whitebal(False,(-6.296998, -3.762909, 2.616725) )
sensor.set_auto_exposure(False, 6576)
sensor.skip_frames(time = 2000)

Result of tracking depends on camera directed to bright white surface or to dark surface at time of activation. If camera was directed to most bright surface in environment then white balance stays unchanged during session and image is dark at all time. If camera was directed to dark surface at time of activation then image seems brighter at initial period, but then can change to dark image if camera is turned to bright light, at following period image does not return to initial brightness. Together with reduced brightness of image several blobs disappear from detection. During both experiments gain, exposure and rgb_gain were inspected. Result is below.
gain = 5.459351
exposure = 6576
whitebal = (-6.438398, -3.658832, 2.766099)

These three values were same at both experiments and never changed together with image brightness. Gain and rgb_gain had never match the same values in set_auto_gain and set_auto_whitebal . If I change these values in set_auto_gain and set_auto_whitebal then inspected values appear to be different anyway.

Please advise how to stabilize measurements from jumping of white balance in image.

Sincerely Azer

You have to pass a keyword argument:

sensor.set_auto_gain(False, gain_db=5.744431)
sensor.set_auto_whitebal(False, rgb_gain_db=(-6.296998, -3.762909, 2.616725) )
sensor.set_auto_exposure(False, exposure_us=6576)

This seems to work:

# Hello World Example
#
# Welcome to the OpenMV IDE! Click on the green run arrow button below to run the script!

import sensor, image, time

sensor.reset()
sensor.set_pixformat(sensor.RGB565)
sensor.set_framesize(sensor.QVGA)
sensor.skip_frames(time = 1000)
sensor.set_auto_gain(False, 5.744431)
sensor.set_auto_whitebal(False,(-6.296998, -3.762909, 2.616725) )
sensor.set_auto_exposure(False, 6576)
clock = time.clock()                # Create a clock object to track the FPS.

while(True):
    clock.tick()                    # Update the FPS clock.
    img = sensor.snapshot()         # Take a picture and return the image.
    print(clock.fps(), sensor.get_gain_db(), sensor.get_rgb_gain_db(), sensor.get_exposure_us())              # Note: OpenMV Cam runs about half as fast when connected
                                    # to the IDE. The FPS should increase once disconnected.

Note that the camera might ignore you if you turn the auto gain methods off immediately before waiting a bit. Always wait a bit for the camera to stabilize. The camera chips have a micro-processor on that that will ignore settings if they are busy sometimes.

The gains you gave me BTW seem to make the image blue. I would recommend pointing the camera at a scene that’s not one color.

Dear Sir,

I have used your advice with keyword arguments and with sensor.skip_frames(time = 1000).
At least I have one positive result : brightness of image doesn’t change during one session. Thank you for this.
Other important negative feature remains: brightness of surface where camera initially directed. If I keep camera covered at time of activation by hand then whole session image is bright. If I direct camera to light at time of activation then whole session image is dark. Inspected values of gain, exposure and rgb_gain are same in both sessions. Is there any method to equalize image brightness conditions depending on activation scene? I can believe that one of methods is to cover camera each time at activation by hand, but we understand that this is not perfect solution.

Sincerely, Azer

No need to do that. Just run the script without turning all the auto controls off and record the values. Once you do that then apply those new settings to the script I gave you above and you should be good.

As for the initial frames that come out of the camera, skip frames ignores those. They don’t matter.