mirror of
https://github.com/opencv/opencv.git
synced 2026-12-02 21:22:43 -06:00
Fix find_obj sample when image descriptors are unavailable 🤖🤖🤖 (#30812)
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.
This commit is contained in:
committed by
GitHub
parent
4cab9c8fa5
commit
8251b372fe
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user