IOCTL_SET_TRIGGERED_MODE problem

Hello guys and Merry Christmas first of all!!!
I’d like to ask 2 questions regarding IOCTL_SET_TRIGGERED_MODE.

I want to synchronize to cameras, and since i have a global shutter on both of my H7 cameras i went to use IOCTL_SET_TRIGGERED_MODE,True.
Before doing so, I tested the function in one of the example programs for global shutter, the high_fps.py and added the function.

I realized a HUGE drop of frames, from about 200 to about 100 frames in QQVGA when IOCTL_SET_TRIGGERED_MODE was true. I must mention here
that high fps for my project is very important (ball tracking project)


import sensor, image, time

sensor.reset() # Reset and initialize the sensor.
sensor.set_pixformat(sensor.GRAYSCALE) # Set pixel format to GRAYSCALE
sensor.set_framesize(sensor.QQVGA) # Set frame size to QQVGA (160x120) - make smaller to go faster
sensor.skip_frames(time = 2000) # Wait for settings take effect.
clock = time.clock() # Create a clock object to track the FPS.

sensor.set_auto_exposure(True, exposure_us=5000) # make smaller to go faster
sensor.ioctl(sensor.IOCTL_SET_TRIGGERED_MODE, True)

while(True):
clock.tick() # Update the FPS clock.
img = sensor.snapshot() # Take a picture and return the image.
print(clock.fps()) # Note: OpenMV Cam runs about half as fast when connected

to the IDE. The FPS should increase once disconnected.

I thought that this mode would make fps even better ( i think i read it somewhere) , since the module does not wait for previous image to finish. Am i doing something wrong here?


The second problem was when i asked the program to take snapshots every 2 seconds, apart from the first image, all the others were full of snow … with a lot of noise. Why is that? When i run the same program with triggered mode set False, everything was fine.

\

Untitled - By: giaag - Πεμ Δεκ 24 2020

import sensor, image, time, pyb
from pyb import Pin

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.QQVGA)
sensor.skip_frames(time = 2000)

sensor acquisition trigger when calling snapshot()

sensor.ioctl(sensor.IOCTL_SET_TRIGGERED_MODE, True)

Create a clock object to track the FPS.

clock = time.clock()



i=0
led = pyb.LED(1) # Red LED = 1, Green LED = 2, Blue LED = 3, IR LEDs = 4.

for i in range(10):
led.on()
fn=‘imgg_’+str(i)+‘.jpg’
clock.tick()
img = sensor.snapshot()
img.save(fn,quality=100)
#print(fn)

time.sleep_ms(1000)
led.off()
time.sleep_ms(1000)





any suggestions would be welcome

Happy new Year guys!!!

Yeah, when you trigger the cameras they run at the rate of the main script loop… so, the camera doesn’t start generating the next frame anymore until you call snapshot again. So, this is expected. It does help the FPS when the resolution is really really low.

Regarding the snow issue… that’s not expected. Setting triggered mode just flips 1 bit in the camera registers. However… if you are triggering at 0.5 Hz then this may cause an issue with the camera module. You’d need to look at the datasheet for it. We allow you low level register control with the OpenMV Cam so you can play with the camera image generation settings.

What is probably happening is that at the low speed of triggering the camera the exposure of the image is messed up. I don’t know why however. Maybe turn off the auto exposure and force it to be a constant value.

Thank you for your quick reply and happy new year :slight_smile:
Well the drop in fps was seen in 160x120 image size that I consider low resolution. And the drop is huge! just run the code I posted with IOCTL on and off

It doesn’t matter the resolution. When the camera is triggered it doesn’t read out an image until the next trigger.

Triggered mode gives you precise control of the exposure at the expense of loosing all pipelining in the image capture process.

I have the same trouble with the trigger mode and lot of snow. Did you find a solution to resolve the problems. The exposure is constant

Hello,

I’m new on this forum. I have also the snow issue on triggered mode. I’m using MT9V034 sensor. exposure duration and gain are fixed. When the triggered mode is actived there is a kind of snow. But, this snow is static. I’m wondering if there is a sensor calibration losse (Non uniformity correction, or Bad pixel replacement). see attached snapshot, i would like to point that the noise is static (always the same on any frame).

Someone can help me to get a clear image on triggered mode ?

Thanks,

Yann

Hi, this is an artifact of triggered mode because you’ve set a fixed gain/exposure time and the camera can’t freely adjust it anymore. If you want to get rid of this you need to increase the exposure time and decrease the gain.

You are free to play with register settings if you want to use sensor.__write_reg() and sensor.__read_reg(). https://www.uctronics.com/download/Image_Sensor/MT9V034_DS.pdf

Also, if you don’t want to change any of those setting then you should use the image processing library to cleanup the image. img.median(3) will do a really good job cleaning most of that up.

Hello kwagyeman

Thank you very much for your quick answer.
It doesn’t seem to be due to fixed gain/exposure as I observe the same thing when I set the sensor to auto gain/exposure.
I’ll do some tests with registers, i’ll let you know if i find something interesting. Thank you for the datasheet.

Yann