import sensor, time, image,pyb
led=pyb.LED(2)
Reset sensor
sensor.reset()
Sensor settings
sensor.set_contrast(3)
sensor.set_gainceiling(16)
sensor.set_framesize(sensor.QQVGA)
sensor.set_windowing((160, 120))
sensor.set_pixformat(sensor.GRAYSCALE)
sensor.skip_frames(time = 2000)
sensor.set_auto_gain(False, value=100)
kpts=["/0.orb","1.orb","2.orb","3.orb"]
#kpts1 = image.load_descriptor("/desc.orb")
clock = time.clock()
while (True):
clock.tick()
img = sensor.snapshot()
kpts2 = img.find_keypoints(max_keypoints=150, threshold=10, normalized=True)
if (kpts2):
for t in kpts:
kpts=image.load_descriptor(t)
match = image.match_descriptor(kpts, kpts2, threshold=85)
if (match.count()>10):
led.on()
# 匹配度大于10
img.draw_rectangle(match.rect())
img.draw_cross(match.cx(), match.cy(), size=10)
else:
led.off()
print(kpts2, "matched:%d dt:%d"%(match.count(), match.theta()))
img.draw_string(0, 0, "FPS:%.2f"%(clock.fps()))