mirror of
https://github.com/openmv/openmv.git
synced 2025-11-04 14:49:50 +08:00
Update descriptor scripts.
* Use the new match_descriptor. * Add commented line that loads descriptor from file
This commit is contained in:
parent
08f7cb8832
commit
c050509b9d
@ -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()))
|
||||
|
||||
@ -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):
|
||||
|
||||
@ -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):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user