Skip to content

Commit 71bc398

Browse files
committed
Fix S1244 float-eq and use np.nonzero in visual_match (Sonar)
1 parent c69c5c3 commit 71bc398

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

je_auto_control/utils/visual_match/visual_match.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _haystack_gray(haystack: Optional[ImageSource],
8585

8686
def _resize(template, scale: float):
8787
import cv2
88-
if scale == 1.0:
88+
if abs(scale - 1.0) < 1e-9:
8989
return template
9090
height, width = template.shape[:2]
9191
new_size = (max(1, round(width * scale)), max(1, round(height * scale)))
@@ -156,7 +156,7 @@ def match_template_all(template: ImageSource, *,
156156
hay = _haystack_gray(haystack, region)
157157
height, width = tmpl.shape[:2]
158158
result = cv2.matchTemplate(hay, tmpl, cv2.TM_CCOEFF_NORMED)
159-
ys, xs = np.where(result >= float(min_score))
159+
ys, xs = np.nonzero(result >= float(min_score))
160160
candidates = [Match(int(x), int(y), width, height,
161161
round(float(result[y, x]), 4), 1.0)
162162
for y, x in zip(ys, xs)]

0 commit comments

Comments
 (0)