Skip to content

Commit

Permalink
Merge pull request #64 from hhslepicka/fix-cv
Browse files Browse the repository at this point in the history
FIX: Order find results by best match.
  • Loading branch information
hhslepicka committed Sep 2, 2022
2 parents 90cad69 + ab82146 commit d8da757
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion botcity/web/cv2find.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,5 +136,8 @@ def locate_all_opencv(needle_image, haystack_image, grayscale=False, limit=10000
# use a generator for API consistency:
matchx = matches[1] * step + region[0] # vectorized
matchy = matches[0] * step + region[1]
for x, y in zip(matchx, matchy):

# Order results before sending back
ordered = sorted(zip(matchx, matchy), key=lambda p: result[p[1]][p[0]], reverse=True)
for x, y in ordered:
yield Box(x, y, needle_width, needle_height)

0 comments on commit d8da757

Please sign in to comment.