Camera settings of a program that recognizes both color and circle

I tried to identify color block and circles in one program at the same time. image.find_circle and image.find_blobs have different settings for the image. The settings for the circle are as follows:

Sensor.set_pixformat(sensor.RGB565) # use RGB565.
Sensor.set_framesize(sensor.QQVGA) # use QQVGA for speed.
Sensor.set_contrast(3)
Sensor.set_gainceiling(16)

After the circle is recognized, the color block settings are as follows:

Sensor.set_pixformat(sensor.RGB565) # use RGB565.
Sensor.set_framesize(sensor.QVGA) # use QQVGA for speed.
Sensor.set_auto_whitebal(False)

But when it recognized the circle after color block recognition, I found that the color of the image is abnormal, I think

Sensor.set_contrast(3)
Sensor.set_gainceiling(16)

is the reason, What do I do to get this working?

When you change the settings the sensor needs time to adjust and settle down, you could either skip some frames

 sensor.skip_frames(100)

to skip 100 frames or

 sensor.skip_frames(time=300)

to skip frames for 300ms or you could keep the settings the same (maybe use set_windowing to reduce the frame).

I tried it, but failed. The color of the image is abnormal when it recognize the color after recognizing the circle. I think I should change contrast and gainceiling to the default parameter using

Sensor.set_contrast(default parameter)
Sensor.set_gainceiling(default parameter)

but I don’t know what the parameters are?

abnormal how ? can you post a screenshot ?

P2 is the picture that identifies the circle
P1 is an abnormal picture when recognizing colors


Hi, you need to turn auto white balance off immediately. It changes the color of the image when the picture isn’t staring at a complex scene. So, before the skip frames call turn auto white balance off using the set_auto_whitebalance() method.

I tried , but it did not work too

Okay, I don’t really understand the problem you having then. The images look okay. Can you be more detailed?