bugfix matching loop break
This commit is contained in:
@@ -20,7 +20,7 @@ HSV_DEFAULT = HsvFilter(0, 0, 0, 179, 255, 255, 0, 0, 0, 0)
|
|||||||
|
|
||||||
|
|
||||||
def run():
|
def run():
|
||||||
EMITTER_TO_USE = EMITTER_STAFF
|
EMITTER_TO_USE = EMITTER_RING
|
||||||
SPAWN_COUNT = 15
|
SPAWN_COUNT = 15
|
||||||
# initialize the user-class
|
# initialize the user-class
|
||||||
config = UserConfigs()
|
config = UserConfigs()
|
||||||
@@ -134,9 +134,9 @@ def run():
|
|||||||
|
|
||||||
rectangles = vision_stun.find_by_mask_and_validate(screenshot, needles[rer], masks[rer], 5)
|
rectangles = vision_stun.find_by_mask_and_validate(screenshot, needles[rer], masks[rer], 5)
|
||||||
# draw the detection results onto the original image
|
# draw the detection results onto the original image
|
||||||
# output_image = vision_stun.draw_rectangles(screenshot, rectangles)
|
#output_image = vision_stun.draw_rectangles(screenshot, rectangles)
|
||||||
# cv.imshow("output_image", output_image)
|
#cv.imshow("output_image", output_image)
|
||||||
# cv.waitKey(150)
|
#cv.waitKey(150)
|
||||||
|
|
||||||
if len(rectangles) is not 5:
|
if len(rectangles) is not 5:
|
||||||
break
|
break
|
||||||
@@ -145,24 +145,30 @@ def run():
|
|||||||
break
|
break
|
||||||
|
|
||||||
points = vision_stun.get_click_points(rectangles)
|
points = vision_stun.get_click_points(rectangles)
|
||||||
check_and_move_tile(capture_window, vision_stun, config,
|
move_breaker = check_and_move_tile(capture_window, vision_stun, config,
|
||||||
[70, 70, rectangles[0][0] + 70, rectangles[0][1]], needles[rer],
|
[70, 70, rectangles[0][0] + 70, rectangles[0][1]], needles[rer],
|
||||||
hsvs[rer], tresholds[rer], masks[rer],
|
hsvs[rer], tresholds[rer], masks[rer],
|
||||||
points[1], [points[0][0] + 70, points[0][1]])
|
points[1], [points[0][0] + 70, points[0][1]])
|
||||||
|
if move_breaker:
|
||||||
|
break
|
||||||
if keyboard.is_pressed('p') == True or pause == True:
|
if keyboard.is_pressed('p') == True or pause == True:
|
||||||
pause = True
|
pause = True
|
||||||
break
|
break
|
||||||
check_and_move_tile(capture_window, vision_stun, config,
|
move_breaker = check_and_move_tile(capture_window, vision_stun, config,
|
||||||
[70, 70, rectangles[0][0], rectangles[0][1] + 70], needles[rer],
|
[70, 70, rectangles[0][0], rectangles[0][1] + 70], needles[rer],
|
||||||
hsvs[rer], tresholds[rer], masks[rer],
|
hsvs[rer], tresholds[rer], masks[rer],
|
||||||
points[2], [points[0][0], points[0][1] + 70])
|
points[2], [points[0][0], points[0][1] + 70])
|
||||||
|
if move_breaker:
|
||||||
|
break
|
||||||
if keyboard.is_pressed('p') == True or pause == True:
|
if keyboard.is_pressed('p') == True or pause == True:
|
||||||
pause = True
|
pause = True
|
||||||
break
|
break
|
||||||
check_and_move_tile(capture_window, vision_stun, config,
|
move_breaker = check_and_move_tile(capture_window, vision_stun, config,
|
||||||
[70, 70, rectangles[0][0] + 70, rectangles[0][1] + 70],
|
[70, 70, rectangles[0][0] + 70, rectangles[0][1] + 70],
|
||||||
needles[rer], hsvs[rer], tresholds[rer], masks[rer],
|
needles[rer], hsvs[rer], tresholds[rer], masks[rer],
|
||||||
points[3], [points[0][0] + 70, points[0][1] + 70])
|
points[3], [points[0][0] + 70, points[0][1] + 70])
|
||||||
|
if move_breaker:
|
||||||
|
break
|
||||||
move_tile(config, points[4], [points[0][0], points[0][1]])
|
move_tile(config, points[4], [points[0][0], points[0][1]])
|
||||||
if keyboard.is_pressed('p') == True or pause == True:
|
if keyboard.is_pressed('p') == True or pause == True:
|
||||||
pause = True
|
pause = True
|
||||||
@@ -174,12 +180,17 @@ def run():
|
|||||||
|
|
||||||
|
|
||||||
def check_and_move_tile(capture_win, visio, conf, rect, needl, hsv, tresh, mask, point_source, point_dest):
|
def check_and_move_tile(capture_win, visio, conf, rect, needl, hsv, tresh, mask, point_source, point_dest):
|
||||||
screenshot_pos = capture_win.get_screenshot()
|
screenshot_p = capture_win.get_screenshot()
|
||||||
|
screenshot_p_w = screenshot_p.shape[1]
|
||||||
|
screenshot_p_h = screenshot_p.shape[0]
|
||||||
w = rect[0]
|
w = rect[0]
|
||||||
h = rect[1]
|
h = rect[1]
|
||||||
x = rect[2]
|
x = rect[2]
|
||||||
y = rect[3]
|
y = rect[3]
|
||||||
screenshot_pos = screenshot_pos[y:y + h, x:x + w] # (w, h, x+w, y+h)
|
if h >= screenshot_p_h or w >= screenshot_p_w:
|
||||||
|
return True
|
||||||
|
|
||||||
|
screenshot_pos = screenshot_p[y:y + h, x:x + w] # (w, h, x+w, y+h)
|
||||||
# processed_screenshot = visio.apply_hsv_filter(screenshot_pos, hsv)
|
# processed_screenshot = visio.apply_hsv_filter(screenshot_pos, hsv)
|
||||||
# processed_needle = visio.apply_hsv_filter(needl, hsv)
|
# processed_needle = visio.apply_hsv_filter(needl, hsv)
|
||||||
result2 = cv.matchTemplate(screenshot_pos, needl, cv.TM_CCOEFF_NORMED)
|
result2 = cv.matchTemplate(screenshot_pos, needl, cv.TM_CCOEFF_NORMED)
|
||||||
@@ -188,10 +199,12 @@ def check_and_move_tile(capture_win, visio, conf, rect, needl, hsv, tresh, mask,
|
|||||||
# output_by_area = vision_stun.draw_rectangles(screenshot_pos2, rectangles)
|
# output_by_area = vision_stun.draw_rectangles(screenshot_pos2, rectangles)
|
||||||
# cv.imshow("output_image_by_area", screenshot_pos)
|
# cv.imshow("output_image_by_area", screenshot_pos)
|
||||||
# cv.waitKey(150)
|
# cv.waitKey(150)
|
||||||
print("thresh in movecheck:" + str(_maxVal2))
|
#print("thresh in movecheck:" + str(_maxVal2))
|
||||||
if _maxVal2 <= 0.9:
|
if _maxVal2 <= 0.9:
|
||||||
move_tile(conf, point_source, point_dest)
|
move_tile(conf, point_source, point_dest)
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def click_point(conf, x, y):
|
def click_point(conf, x, y):
|
||||||
offset_left = conf.returnEquipmentWindowPos()[2]
|
offset_left = conf.returnEquipmentWindowPos()[2]
|
||||||
|
|||||||
Reference in New Issue
Block a user