Issue with set readout window

Hi,

Sorry to be the bearer of firmware problems I know you must be very busy…However, please can you look at the sensor.IOCTL_SET_READOUT_WINDOW. I am using it for Digital PTZ, but it seems to have stopped working properly. It fails in both the examples in the latest firmware as well…

I have tried it on two H7 plus OV5640 cameras, flashed today with 4.1.0

I guess it could be related to the DMA work you have been doing to speed up capture…?

Thanks.

No, this is because Ibrahim changed the code that parses the arguments and it got broken. The latest unreleased firmware has a fix.

@iabdalkader can you post an H7 plus binary?

Hi,

I see. No problem I can wait until the next release…I will carry on testing without that.

Cheers

Yes it was fixed, for now if you just add any extra arg (0 or False) it should work.

Hi,

Thanks I will try that, but I think there are other problems.

# 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()    
print ("Setup Cam")
sensor.set_gainceiling(128)
print ("Set auto gain")
sensor.set_auto_gain(True)
print ("Set auto exposure")
sensor.set_auto_exposure(True)
print ("Set framesize")
sensor.set_framesize(sensor.HD)
print ("Set pixformat")
sensor.set_pixformat(sensor.RGB565)
print ("Set framerate")
sensor.set_framerate(1)
print ("Set buffers")
sensor.set_framebuffers(8)

                  # Reset and initialize the sensor.
#sensor.set_pixformat(sensor.RGB565) # Set pixel format to RGB565 (or GRAYSCALE)
#sensor.set_framesize(sensor.QVGA)   # Set frame size to QVGA (320x240)
sensor.skip_frames(time = 2000)     # Wait for settings take effect.
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())              # Note: OpenMV Cam runs about half as fast when connected
                                    # to the IDE. The FPS should increase once disconnected.

This stalls at the sensor.set_pixformat, but only if the set framerate is run. If you comment out set framerate and buffers it runs…

I think there may be others, but I will have to track them down.

Hi,

Yes there was another crash in my code, but it appears to be just further instances of set_framerate. When they are all commented out, all is well again…

I’m not sure I can understand the issue, can you be more clear ?

CC @kwagyeman

Of course.

Please run the modified hello world sample below. I have added an LED to be sure below.

It never reaches the main loop. The USB disconnects and the LED flashing does not occur.
(However if you remove the set_framerate and set_framebuffers lines it does work.)
So there is a new problem with set_framerate (I believe, though it may be the set_framebuffers) but it is quite difficult to tell which line as the USB print seems to be lost in buffering when the USB disconnects.

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

import sensor, image, time, pyb

from pyb import LED

red_led   = LED(1)
green_led = LED(2)
blue_led  = LED(3)
ir_led    = LED(4)

def led_control(x):
    if   (x&1)==0: red_led.off()
    elif (x&1)==1: red_led.on()
    if   (x&2)==0: green_led.off()
    elif (x&2)==2: green_led.on()
    if   (x&4)==0: blue_led.off()
    elif (x&4)==4: blue_led.on()
    if   (x&8)==0: ir_led.off()
    elif (x&8)==8: ir_led.on()

sensor.reset()
print ("Setup Cam")
sensor.set_gainceiling(128)
print ("Set auto gain")
sensor.set_auto_gain(True)
print ("Set auto exposure")
sensor.set_auto_exposure(True)
print ("Set framesize")
sensor.set_framesize(sensor.HD)
print ("Set pixformat")
sensor.set_pixformat(sensor.RGB565)
led_control(1)
                  # Reset and initialize the sensor.
sensor.skip_frames(time = 2000)     # Wait for settings take effect.
clock = time.clock()                # Create a clock object to track the FPS.
print ("Set framerate")
sensor.set_framerate(1)
print ("Set buffers")
sensor.set_framebuffers(8)

led_control(0)
while(True):
    led_control(1)
    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
    pyb.delay(100)
    led_control(0)
    pyb.delay(100)
                                    # to the IDE. The FPS should increase once disconnected.

I have tried two cameras and cables.

It should print an exception message? Or is the system just crashing? Set_framerate definitely should work.

There is no error message, just a disconnect from USB and no main loop running. So I assume a crash, yes.

Confirmed it’s bug in sensor.set_framerate, it’s a bad check for null… will fix. set_framebuffers should be working fine.

Please modify the PR slightly.

Hi, Thanks for the info… I will keep the set_framerate commented out for now.