Fix: relative_hsv_count was counting pixels in 3 channels

causing lots of predict_current_fleet() mis-detection
This commit is contained in:
LmeSzinc 2024-05-02 16:47:11 +08:00
parent 24fa10c509
commit 5be152baf1

View File

@ -159,8 +159,9 @@ class GridPredictor:
cv2.cvtColor(image, cv2.COLOR_RGB2HSV, dst=image)
lower = (h[0] / 2, s[0] * 2.55, v[0] * 2.55)
upper = (h[1] / 2 + 1, s[1] * 2.55 + 1, v[1] * 2.55 + 1)
cv2.inRange(image, lower, upper, dst=image)
count = image[image > 0].shape[0]
# Don't set `dst`, output image is (50, 50) but `image` is (50, 50, 3)
image = cv2.inRange(image, lower, upper)
count = cv2.countNonZero(image)
return count
def predict_enemy_scale(self):