logo

特征点匹配过程中经常出现descriptors have different types!报错,怎么解决啊?

2021-03-14 16:02
U
_2yu5
import sensor, image, time

sensor.reset()
sensor.set_contrast(3)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.QVGA)
sensor.set_pixformat(sensor.RGB565)
sensor.skip_frames(time = 2000)
clock = time.clock()
sensor.set_auto_gain(False, value=100)
sensor.set_windowing((320, 240))


def draw_keypoints(img, kpts):
    if kpts:
        print(kpts)
        img.draw_keypoints(kpts)
        img = sensor.snapshot()
        time.sleep_ms(1000)


clock = time.clock()
thresholds = (61, 255)


while(True):

    clock.tick()
    kptsF = image.load_descriptor("kptsBF.orb")
    kptsC = image.load_descriptor("kptsBC.orb")
    img = sensor.snapshot()
    img.binary([(0, 100, 11, 127, -2, 30),(16, 57, -24, -12, -28, 3)])
    img.to_grayscale
    
    for blob in img.find_blobs([thresholds], pixels_threshold=50, merge=False):#10米处50cm大小约为13像素
        pixel = blob.pixels()
        kpts2 = img.find_keypoints(max_keypoints=150, threshold=1, normalized=True)
        if (pixel < 4900):#距离较远,图像不够清晰时
            match = image.match_descriptor(kptsF, kpts2, threshold=85)
        elif (pixel > 4900):#距离较近,图像清晰时
            match = image.match_descriptor(kptsC, kpts2, threshold=85)
                
        if (match.count()>1):
            print("matched:%d dt:%d  x:%d y:%d"%(match.count(), match.theta(),blob.w(), blob.h()))
U
_2yu5
51e5cf01-8c4a-4dec-9858-c12c12911bf5.png