added equip ok button check
This commit is contained in:
@@ -8,7 +8,7 @@ from hsvfilter import HsvFilter
|
|||||||
from config_file import UserConfigs
|
from config_file import UserConfigs
|
||||||
import pydirectinput
|
import pydirectinput
|
||||||
import keyboard
|
import keyboard
|
||||||
from utils import check_for_ok_button
|
from utils import dig_point
|
||||||
|
|
||||||
EMITTER_MAIN = "main"
|
EMITTER_MAIN = "main"
|
||||||
EMITTER_MUSH = "mushroom"
|
EMITTER_MUSH = "mushroom"
|
||||||
@@ -47,11 +47,6 @@ def run():
|
|||||||
tresholds = []
|
tresholds = []
|
||||||
masks = []
|
masks = []
|
||||||
|
|
||||||
fixed_merge_pos_1 = []
|
|
||||||
fixed_merge_pos_2 = []
|
|
||||||
fixed_merge_pos_3 = []
|
|
||||||
fixed_merge_pos_4 = []
|
|
||||||
|
|
||||||
if EMITTER_TO_USE == EMITTER_MUSH:
|
if EMITTER_TO_USE == EMITTER_MUSH:
|
||||||
include_books(needles, hsvs, tresholds, masks)
|
include_books(needles, hsvs, tresholds, masks)
|
||||||
include_mushs(needles, hsvs, tresholds, masks)
|
include_mushs(needles, hsvs, tresholds, masks)
|
||||||
@@ -134,9 +129,14 @@ def run():
|
|||||||
|
|
||||||
cv.waitKey(500)
|
cv.waitKey(500)
|
||||||
for rer in range(0, len(needles), 1):
|
for rer in range(0, len(needles), 1):
|
||||||
if check_for_ok_button():
|
screenshot = capture_window.get_screenshot_by_area(config.returnOKWindowPos())
|
||||||
cv.waitKey(60000)
|
rectangles = vision_stun.find(screenshot, cv.imread("dig/ok_button.jpg", cv.IMREAD_UNCHANGED), 0.5, 1)
|
||||||
continue
|
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:
|
while True:
|
||||||
# do object detection
|
# do object detection
|
||||||
screenshot = capture_window.get_screenshot()
|
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)
|
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
|
||||||
@@ -155,7 +155,7 @@ def run():
|
|||||||
pause = True
|
pause = True
|
||||||
break
|
break
|
||||||
|
|
||||||
#sort rectangles by top
|
# sort rectangles by top
|
||||||
rectangles = sorted(rectangles, key=itemgetter(1))
|
rectangles = sorted(rectangles, key=itemgetter(1))
|
||||||
|
|
||||||
points = vision_stun.get_click_points(rectangles)
|
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)
|
# 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)
|
||||||
|
|
||||||
|
|||||||
2
utils.py
2
utils.py
@@ -172,6 +172,4 @@ def check_for_ok_button(cap_win, vis, conf):
|
|||||||
pointis = vis.get_click_points(rectangles)
|
pointis = vis.get_click_points(rectangles)
|
||||||
for pointi in pointis:
|
for pointi in pointis:
|
||||||
dig_point(pointi[0] + offset_left, pointi[1] + offset_down, 150)
|
dig_point(pointi[0] + offset_left, pointi[1] + offset_down, 150)
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user