Skip to content

Commit d8da757

Browse files
authored
Merge pull request #64 from hhslepicka/fix-cv
FIX: Order find results by best match.
2 parents 90cad69 + ab82146 commit d8da757

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

botcity/web/cv2find.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,5 +136,8 @@ def locate_all_opencv(needle_image, haystack_image, grayscale=False, limit=10000
136136
# use a generator for API consistency:
137137
matchx = matches[1] * step + region[0] # vectorized
138138
matchy = matches[0] * step + region[1]
139-
for x, y in zip(matchx, matchy):
139+
140+
# Order results before sending back
141+
ordered = sorted(zip(matchx, matchy), key=lambda p: result[p[1]][p[0]], reverse=True)
142+
for x, y in ordered:
140143
yield Box(x, y, needle_width, needle_height)

0 commit comments

Comments
 (0)