Program execution stuck problem

Excuse me, please help me find out what’s wrong with the following code, and why OpenMV always gets stuck and disconnects during execution. Hope you can give me some advice.

import sensor, image, time
import sensor, image

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.UXGA)
sensor.skip_frames(time=2000)
sensor.set_windowing((128,368,1400,706))

template = image.Image(“/model1.pgm”)
print(template)
kpts2 = template.find_keypoints(threshold=5,scale_facter=1.2,max_keypoints=150)
print(type(kpts2))

while True:
img = sensor.snapshot()

blobs = img.find_blobs([(178, 251)],area_threshold=1000)

if blobs:
    print(blobs)

    for blob in blobs:
      
        x, y = blob.cx(), blob.cy()
        
   
        roi = img.crop(blob.rect())
        print(roi)

        kpts1 = roi.find_keypoints(threshold=5,scale_facter=1.2,max_keypoints=150)
        print(type(kpts1))
    

        if len(kpts1) > 0:
            match = image.match_descriptor(kpts2, kpts1, threshold=75)
            if match:
          
                img.draw_rectangle(blob.rect(), color=(255, 0, 0))  
time.sleep(3)
print(clock.fps())

Can find the particular line it fails on?

Sorry, I am only replying to you now, I got stuck on this line of code.

roi.find_keypoints(threshold=5,scale_facter=1.2,max_keypoints=150)

Then when I use Copy, it shows memory overflow.

@iabdalkader - Seems like a bug in find_keypoints()

Is there any solution? :grinning:

Are you running out of memory or does it get stuck ? If you attach the script and template I can test this tomorrow, also please mention the camera you’re using.

I have installed an 8G memory card. If you change crop to copy, it will also be disconnected during operation. I am using OpenMV4 Cam 7 plus and use a zoom lens. Below is a picture of my template.
model1

import sensor, image, time
import sensor, image

sensor.reset()
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.set_framesize(sensor.UXGA)
sensor.skip_frames(time=2000)
sensor.set_windowing((128,368,1400,706))

clock = time.clock()
template = image.Image("/model1.pgm")
print(template)
kpts2 = template.find_keypoints(threshold=5,scale_facter=1.2,max_keypoints=150)
print(type(kpts2)) 
while True:
    img = sensor.snapshot()
    blobs = img.find_blobs([(178, 251)],area_threshold=1000)
    if blobs:
        print(blobs)
        for blob in blobs:
            x, y = blob.cx(), blob.cy()
            roi = img.crop(blob.rect())
            print(roi)
            kpts1 = roi.find_keypoints(threshold=5,scale_facter=1.2,max_keypoints=150)
            print(type(kpts1))
            if len(kpts1) > 0:
                match = image.match_descriptor(kpts2, kpts1, threshold=75)
                if match:
              
                    img.draw_rectangle(blob.rect(), color=(255, 0, 0))  
    print(clock.fps())

Hi, yes it was a bug the corner detector didn’t handle higher resolutions, it should be fixed now, you can install the latest development release for this fix.

Okay, I’ll give it a try.