diff --git a/usr/examples/face_tracking.py b/usr/examples/face_tracking.py index 8388b297c..fac1aea07 100644 --- a/usr/examples/face_tracking.py +++ b/usr/examples/face_tracking.py @@ -44,10 +44,10 @@ while (kpts1 == None): if objects: # Expand the ROI by 11 pixels in each direction (half the pattern scale) face = (objects[0][0]-22, objects[0][1]-22,objects[0][2]+22*2, objects[0][3]+22*2) - # Draw a rectangle around the first face - img.draw_rectangle(objects[0]) # Extract keypoints using the detect face size as the ROI kpts1 = img.find_keypoints(threshold=KEYPOINTS_THRESH, normalized=NORMALIZED, roi=face) + # Draw a rectangle around the first face + img.draw_rectangle(objects[0]) # Draw keypoints print(kpts1) @@ -60,17 +60,16 @@ clock = time.clock() while (True): clock.tick() img = sensor.snapshot() - kpts2=None # Extract keypoints using the detect face size as the ROI kpts2 = img.find_keypoints(threshold=KEYPOINTS_THRESH, normalized=NORMALIZED) - # Match the first set of keypoints with the second one - if (kpts2): - c=img.match_keypoints(kpts1, kpts2, MATCHING_THRESH) - # If more than 10% of the keypoints match draw the matching set - if (c[2]>25): - img.draw_cross(c[0], c[1], size=5) - img.draw_string(0, 10, "Match %d%%"%(c[2])) + if (kpts2): + # Match the first set of keypoints with the second one + c=image.match_descriptor(image.FREAK, kpts1, kpts2, threshold=MATCHING_THRESH) + # If more than 10% of the keypoints match draw the matching set + if (c[2]>25): + img.draw_cross(c[0], c[1], size=5) + img.draw_string(0, 10, "Match %d%%"%(c[2])) # Draw FPS img.draw_string(0, 0, "FPS:%.2f"%(clock.fps())) diff --git a/usr/examples/keypoints.py b/usr/examples/keypoints.py index 0bc8e11c5..2bbe58a95 100644 --- a/usr/examples/keypoints.py +++ b/usr/examples/keypoints.py @@ -1,4 +1,4 @@ -import sensor, time +import sensor, time, image # Rotation. NORMALIZED=False @@ -28,6 +28,8 @@ for i in range(0, 30): img.draw_string(0, 0, "Please wait...") kpts1 = None +# Uncomment to load keypoints from file +#kpts1 = image.load_descriptor(image.FREAK, "/desc.freak") clock = time.clock() while (True): @@ -37,11 +39,9 @@ while (True): if (kpts1==None): kpts1 = kpts2 - kpts2 = None print(kpts1) - - if kpts2: - c=img.match_keypoints(kpts1, kpts2, MATCHING_THRESH) + elif kpts2: + c = image.match_descriptor(image.FREAK, kpts1, kpts2, threshold=MATCHING_THRESH) # C[3] contains the percentage of matching keypoints. # If more than 25% of the keypoints match, draw stuff. if (c[2]>25): diff --git a/usr/examples/lbp_desc.py b/usr/examples/lbp_desc.py index 05118e76f..73a610d5e 100644 --- a/usr/examples/lbp_desc.py +++ b/usr/examples/lbp_desc.py @@ -22,6 +22,7 @@ for i in range(0, 30): img.draw_string(0, 0, "Please wait...") d0 = None +#d0 = image.load_descriptor(image.LBP, "/desc.lbp") clock = time.clock() while (True):