Do i have to skipframe if i change format or frame size without ressetting ?

Dear all,

I have different light conditions and i want to test the lmean before taking the first snapshot.
Unfortunately, i cant do sensor.snapshot().histogram().get_statistics() in RGB565 and VGA configuration.

Therefore i do it in smaller configuration i change after like this :

import sensor, image, pyb, time

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.VGA)
sensor.skip_frames(time=500)

mean=sensor.snapshot().histogram().get_statistics()[1]
tmean = 80
maxtrial=50
trialnb=0
while mean < tmean and trialnb < maxtrial:
   mean=sensor.snapshot().histogram().get_statistics()[1]
   trialnb=trialnb+1
   if trialnb==15: 
       sensor.__write_reg(0x0E,0xF5)              
sensor.set_auto_exposure(False)
sensor.set_auto_gain(False)
sensor.set_auto_whitebal(False)
sensor.set_pixformat(sensor.RGB565)
#sensor.skip_frames(time=500) ??????
print(mean, trialnb, sensor.get_exposure_us(), sensor.get_gain_db())
while True :
   sensor.snapshot()

Do i have to skipframe after changing format ?

Thanks,

If you don’t the camera output is garbage for a while. So, you will experience bad frames.

Thanks, i effectively met this case.

How can i be sure of the lmean level before taking the first snapshot in RGB565 and VGA configuration ?

There’s no real certainty other than waiting enough time for the camera to stabilize. The OmniVision cameras are designed for cell phones so they offer no values for how long things take to stabilize. Please use the global shutter sensor if you want precision.