Unstable exposure time (fixed exposure time)

Hi there,


I am using H7 with Global Shutter Camera.

I am having a problem with unstable exposure time when there is time-consuming process before sensor.snapshot().

This problem can be reproduced when using below example modified from sensor_exposure_control.py

I believe that this can be observed in the other examples with fixed exposure time and time-consuming algorithms.

...
while(True):
    clock.tick()                    # Update the FPS clock.

    t0 = pyb.millis()
    while (pyb.millis() - t0) < 500:
        pyb.delay(10) # Some time-consuming process
    sensor.skip_frames(1) # THIS MUST BE HERE. Otherwise, sensor.snapshot() will have unstable exposure.
    t_snapshot = pyb.millis()
    
    img = sensor.snapshot()         # Take a picture and return the image.
    print('t_snapshot()=',pyb.millis()-t_snapshot)              # Note: OpenMV Cam runs about half as fast when connected

    while (pyb.millis() - t_snapshot) < 500:
        pyb.delay(10)  # Some time-consuming process

For example, I used fixed exposure as 20000us (20ms).

BEFORE FIX (no sensor.skip_frames(1))

t_snapshot()= 20
t_snapshot()= 13
t_snapshot()= 21
t_snapshot()= 12
t_snapshot()= 21

AFTER FIX (with sensor.skip_frames(1) just before sensor.snapshot())

t_snapshot()= 18
t_snapshot()= 18
t_snapshot()= 18
t_snapshot()= 18
t_snapshot()= 18
t_snapshot()= 18
t_snapshot()= 18
t_snapshot()= 18
t_snapshot()= 18
t_snapshot()= 18
t_snapshot()= 18

When I check with oscilloscope, when t_snapshot is 13, t_snapshot happens in the middle of the VSYNC pulse)

For now, I can include sensor.skip_frames() to produce a consistent exposure but it will always waste exposure time every loop (20ms in above case).

Would it be a bug that can be fixed in the firmware?


Thank you and I look forward to your reply,

Kind regards,
Phil

The time it takes snapshot to return has nothing to do with the camera exposure. This isn’t a bug…

Snapshot just grabs a frame from the camera sensor. The camera controls the exposure internally, what you are seeing is the affect of how our frame grabber architecture grabs the next frame coming out the camera.

To note. The camera generated frame asynchronously, snapshot just waits and grabs the next value one. Each frame has the same exposure.