Noise in image after applying image corresction


I have written some code for the H7 camera. This was late in 2020. When i now have updated the firmware/IDE i have some problems.

When i run either lens_corr or rotation_corr i get a lot of noise in and arround the detecting area of my blob detection. It looks like the noise comes from the drawing of the ROI frame. The histogram also jumps arround in tandem with the glitches. This makes contrast detection unstable.
This worked fine before. The image is noise free when i do not use any image correction.

I use a H7 with a global shutter camera, telephoto lens and the latest firmware/IDE.

Any ideas?

Can you post the code. I’ll try to run it and see (e.g. not an image).

Thank you. Here is the code i am running:

import sensor, image, time, math
from pyb import UART

thresholds = (200, 255) #definerer grenseverdi for gråskala på sider
thresholds_v = (220, 255) #definerer grenseverdi for gråskala på sider
#threshold_S = (10, 200) #definerer grenseverdi for gråskala i senter av bildet

felt_blob_V1 = 123,70,8,150   # ROI for detektering
felt_blob_V2 = 77,100,3,30
felt_blob_V3 = 83,190,3,30
#felt_blob_S = 90,130,120,8

status_V1 = False        # Lagret status for her ROI-sone
status_V2 = False
status_V3 = False
status_S = False

arduino_ok = b'\x00'    # Status fra Arduino
antall = 0              # holder orden på hvor mange overscan som skal kjøres
#arduino_ok = 0

# UART 3, og baudrate.
uart = UART(3, 9600)
uart_kode = 1

#THRESHOLD = (0, 101) # test gråskala



sensor.skip_frames(time = 1000)
sensor.set_auto_gain(False) # slå av for å kjøre RGB
#sensor.set_auto_whitebal(False) # Slå av for å kjøre RGB
sensor.set_auto_exposure(False, exposure_us = int (600)) # setter fast eksponering.
sensor.set_contrast(3) # øker kontrast til maks for å øke detektering av gråskala
clock = time.clock()

print("Kamera start")  # Debug

w_sens = sensor.width()
h_sens = sensor.height()

TARGET_POINTS = [(-11, 0),   # (x, y) Venstre topp
                 (w_sens-0, 0),   # (x, y)# Topp høyre
                 (w_sens-0, h_sens-0), # (x, y) # høyre hjørne nede
                 (0,   h_sens-0)] # (x, y) Drar venstre hjørne nede

    if (uart.any()):
        arduino_ok =
        print(arduino_ok)  # Debug

    img = sensor.snapshot().rotation_corr(corners = TARGET_POINTS)#.binary([THRESHOLD]).negate()
    img.draw_rectangle((felt_blob_V1), color = (200, 150, 50))
    for blob in img.find_blobs([thresholds],roi = (felt_blob_V1), pixels_threshold=800, merge=True):
        # These values depend on the blob not being circular - otherwise they will be shaky.
        if blob.elongation() > 0.5:
            status_V1 = True
            img.draw_edges(blob.min_corners(), color=0)
            img.draw_line(blob.major_axis_line(), color=0)
            img.draw_line(blob.minor_axis_line(), color=0)
             # These values are stable all the time.
            img.draw_rectangle(blob.rect(), color=127)
            img.draw_cross(,, color=127)
            # Note - the blob rotation is unique to 0-180 only.
            img.draw_keypoints([(,, int(math.degrees(blob.rotation())))], size=40, color=127)
        else :
           status_V1 = False

I have an idea why… it might be related to the new frame grabber driver. Our latest firmware should fix this.

I tried running your demo and I get a black image. Anyway, I’ll have the latest firmware pushed to the IDE very soon. Let me know if this fixes the issue for you.