mirror of
https://github.com/TheFunny/ArisuAutoSweeper
synced 2025-12-17 00:15:13 +00:00
fix: use correct color space for template matching
This commit is contained in:
parent
1a66e767f3
commit
8d2882e752
@ -54,8 +54,7 @@ class Cafe(UI):
|
|||||||
@staticmethod
|
@staticmethod
|
||||||
def _extract_clickable_from_image(image):
|
def _extract_clickable_from_image(image):
|
||||||
# convert to hsv for better color matching
|
# convert to hsv for better color matching
|
||||||
image = cv2.cvtColor(image, cv2.COLOR_RGB2BGR)
|
hsv = cv2.cvtColor(image, cv2.COLOR_RGB2HSV)
|
||||||
hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)
|
|
||||||
# set color range
|
# set color range
|
||||||
lower_hsv = np.array([18, 200, 220])
|
lower_hsv = np.array([18, 200, 220])
|
||||||
upper_hsv = np.array([30, 255, 255])
|
upper_hsv = np.array([30, 255, 255])
|
||||||
@ -65,8 +64,8 @@ class Cafe(UI):
|
|||||||
return cv2.bitwise_and(image, image, mask=mask)
|
return cv2.bitwise_and(image, image, mask=mask)
|
||||||
|
|
||||||
def _match_clickable_points(self, image, threshold=0.8):
|
def _match_clickable_points(self, image, threshold=0.8):
|
||||||
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
|
||||||
template = cv2.cvtColor(self.template.matched_button.image, cv2.COLOR_BGR2GRAY)
|
template = cv2.cvtColor(self.template.matched_button.image, cv2.COLOR_RGB2GRAY)
|
||||||
|
|
||||||
res = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
|
res = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
|
||||||
loc = np.where(res >= threshold)
|
loc = np.where(res >= threshold)
|
||||||
|
|||||||
@ -131,8 +131,8 @@ class StageList:
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _match_clickable_points(image, template, threshold=0.85):
|
def _match_clickable_points(image, template, threshold=0.85):
|
||||||
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
image = cv2.cvtColor(image, cv2.COLOR_RGB2GRAY)
|
||||||
template = cv2.cvtColor(template, cv2.COLOR_BGR2GRAY)
|
template = cv2.cvtColor(template, cv2.COLOR_RGB2GRAY)
|
||||||
|
|
||||||
res = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
|
res = cv2.matchTemplate(image, template, cv2.TM_CCOEFF_NORMED)
|
||||||
loc = np.where(res >= threshold)
|
loc = np.where(res >= threshold)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user