diff --git a/equipment_main.py b/equipment_main.py index 7f575ec..5006758 100644 --- a/equipment_main.py +++ b/equipment_main.py @@ -8,7 +8,7 @@ from hsvfilter import HsvFilter from config_file import UserConfigs import pydirectinput import keyboard -from utils import check_for_ok_button +from utils import dig_point EMITTER_MAIN = "main" EMITTER_MUSH = "mushroom" @@ -47,11 +47,6 @@ def run(): tresholds = [] masks = [] - fixed_merge_pos_1 = [] - fixed_merge_pos_2 = [] - fixed_merge_pos_3 = [] - fixed_merge_pos_4 = [] - if EMITTER_TO_USE == EMITTER_MUSH: include_books(needles, hsvs, tresholds, masks) include_mushs(needles, hsvs, tresholds, masks) @@ -134,9 +129,14 @@ def run(): cv.waitKey(500) for rer in range(0, len(needles), 1): - if check_for_ok_button(): - cv.waitKey(60000) - continue + screenshot = capture_window.get_screenshot_by_area(config.returnOKWindowPos()) + rectangles = vision_stun.find(screenshot, cv.imread("dig/ok_button.jpg", cv.IMREAD_UNCHANGED), 0.5, 1) + if len(rectangles) == 1: + pointis = vision_stun.get_click_points(rectangles) + for pointi in pointis: + dig_point(pointi[0] + config.returnOKWindowPos()[2], pointi[1] + config.returnOKWindowPos()[3], 150) + cv.waitKey(60000) + continue while True: # do object detection screenshot = capture_window.get_screenshot() @@ -145,9 +145,9 @@ def run(): rectangles = vision_stun.find_by_mask_and_validate(screenshot, needles[rer], masks[rer], 5) # draw the detection results onto the original image - #output_image = vision_stun.draw_rectangles(screenshot, rectangles) - #cv.imshow("output_image", output_image) - #cv.waitKey(150) + # output_image = vision_stun.draw_rectangles(screenshot, rectangles) + # cv.imshow("output_image", output_image) + # cv.waitKey(150) if len(rectangles) is not 5: break @@ -155,7 +155,7 @@ def run(): pause = True break - #sort rectangles by top + # sort rectangles by top rectangles = sorted(rectangles, key=itemgetter(1)) points = vision_stun.get_click_points(rectangles) @@ -214,7 +214,7 @@ def check_and_move_tile(capture_win, visio, conf, rect, needl, hsv, tresh, mask, # output_by_area = vision_stun.draw_rectangles(screenshot_pos2, rectangles) # cv.imshow("output_image_by_area", screenshot_pos) # cv.waitKey(150) - #print("thresh in movecheck:" + str(_maxVal2)) + # print("thresh in movecheck:" + str(_maxVal2)) if _maxVal2 <= 0.9: move_tile(conf, point_source, point_dest) diff --git a/utils.py b/utils.py index 54bd190..6d77d82 100644 --- a/utils.py +++ b/utils.py @@ -172,6 +172,4 @@ def check_for_ok_button(cap_win, vis, conf): pointis = vis.get_click_points(rectangles) for pointi in pointis: dig_point(pointi[0] + offset_left, pointi[1] + offset_down, 150) - return True - return False