Program stuck problem and Copy memory overflow

Excuse me, please help me find out what is wrong with the following code, and why OpenMV always gets stuck and disconnected at the code

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

during execution. connect. Hope you can give me some advice.The following is the entire code of the program

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())

If I replace corp with copy, there will be a memory overflow.

Please do not create duplicate posts.