From 8251b372fe06ae87df00c37a2492b18df7344e93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20Mert=20=C3=96zacar?= Date: Wed, 2 Dec 2026 12:31:42 +0300 Subject: [PATCH] =?UTF-8?q?Fix=20find=5Fobj=20sample=20when=20image=20desc?= =?UTF-8?q?riptors=20are=20unavailable=20=F0=9F=A4=96=F0=9F=A4=96?= =?UTF-8?q?=F0=9F=A4=96=20(#30812)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Keep the feature-matching samples find_obj.py and asift.py usable when the second image has no feature descriptors. find_obj.py receives None and asift.py receives an empty NumPy array in this case. Both samples skip knnMatch() and continue through the existing zero-match visualization. --- samples/python/asift.py | 2 +- samples/python/find_obj.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/samples/python/asift.py b/samples/python/asift.py index e21ef5b07a..6f40dd7b22 100755 --- a/samples/python/asift.py +++ b/samples/python/asift.py @@ -143,7 +143,7 @@ def main(): def match_and_draw(win): with Timer('matching'): - raw_matches = matcher.knnMatch(desc1, trainDescriptors = desc2, k = 2) #2 + raw_matches = matcher.knnMatch(desc1, trainDescriptors=desc2, k=2) if desc2.size else [] p1, p2, kp_pairs = filter_matches(kp1, kp2, raw_matches) if len(p1) >= 4: H, status = cv.findHomography(p1, p2, cv.RANSAC, 5.0) diff --git a/samples/python/find_obj.py b/samples/python/find_obj.py index c5783bf456..27662deaf4 100755 --- a/samples/python/find_obj.py +++ b/samples/python/find_obj.py @@ -174,7 +174,7 @@ def main(): def match_and_draw(win): print('matching...') - raw_matches = matcher.knnMatch(desc1, trainDescriptors = desc2, k = 2) #2 + raw_matches = matcher.knnMatch(desc1, trainDescriptors=desc2, k=2) if desc2 is not None else [] p1, p2, kp_pairs = filter_matches(kp1, kp2, raw_matches) if len(p1) >= 4: H, status = cv.findHomography(p1, p2, cv.RANSAC, 5.0)