summaryrefslogtreecommitdiff
path: root/samples/python/tutorial_code/features2D/feature_homography/SURF_FLANN_matching_homography_Demo.py
diff options
context:
space:
mode:
Diffstat (limited to 'samples/python/tutorial_code/features2D/feature_homography/SURF_FLANN_matching_homography_Demo.py')
-rw-r--r--samples/python/tutorial_code/features2D/feature_homography/SURF_FLANN_matching_homography_Demo.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/samples/python/tutorial_code/features2D/feature_homography/SURF_FLANN_matching_homography_Demo.py b/samples/python/tutorial_code/features2D/feature_homography/SURF_FLANN_matching_homography_Demo.py
index 8820addce2..5172b4f303 100644
--- a/samples/python/tutorial_code/features2D/feature_homography/SURF_FLANN_matching_homography_Demo.py
+++ b/samples/python/tutorial_code/features2D/feature_homography/SURF_FLANN_matching_homography_Demo.py
@@ -28,10 +28,9 @@ knn_matches = matcher.knnMatch(descriptors_obj, descriptors_scene, 2)
#-- Filter matches using the Lowe's ratio test
ratio_thresh = 0.75
good_matches = []
-for matches in knn_matches:
- if len(matches) > 1:
- if matches[0].distance / matches[1].distance <= ratio_thresh:
- good_matches.append(matches[0])
+for m,n in knn_matches:
+ if m.distance / n.distance <= ratio_thresh:
+ good_matches.append(m)
#-- Draw matches
img_matches = np.empty((max(img_object.shape[0], img_scene.shape[0]), img_object.shape[1]+img_scene.shape[1], 3), dtype=np.uint8)