dig failed added opencv

This commit is contained in:
2022-05-06 12:50:44 +02:00
parent a969b33c7a
commit 485b3ba7f4
30 changed files with 56 additions and 9 deletions

View File

@@ -1,5 +1,6 @@
from config_file import UserConfigs
import keyboard
import cv2 as cv
from utils import dig_point, check_for_ok_button
from window_capture import WindowCapture
from vision import Vision
@@ -12,6 +13,8 @@ def run():
# initialize the StunWindowCapture class
capture_config = UserConfigs()
capture_window = WindowCapture(None, "screen_conf", capture_config)
# initialize the StunVision class
vision_stun = Vision()
dig_overlay = DiggingOverlay(config)
@@ -22,7 +25,7 @@ def run():
width = 32
depth = 24
plot_size = 45
DIG_TIME = 150
DIG_TIME = 100
while True:
if keyboard.is_pressed('p') == True:
@@ -38,11 +41,15 @@ def run():
continue
dig_overlay.hide_window()
if level == 21:
if level >= 40:
break
if level == 23:
DIG_TIME = 850
if level == 24:
if level == 27:
DIG_TIME = 1850
if level % 2 == 0:
if level <= 10:
plot_size = plot_size - 1
elif level % 2 == 0:
plot_size = plot_size - 1
p1 = int((config.returnDiggingWindowPos2()[0] / 2) + config.returnDiggingWindowPos2()[2])
@@ -64,11 +71,38 @@ def run():
for f in range(0, e, 1):
# up click
tp2 = tp2 - plot_size
if tp2 >= config.returnDiggingWindowPos2()[1] + plot_size:
if tp2 >= config.returnDiggingWindowPos2()[1] + (plot_size / 2):
continue
if tp2 <= config.returnDiggingWindowPos2()[3] + plot_size:
if tp2 <= config.returnDiggingWindowPos2()[3] + (plot_size / 2):
continue
'''
x = int(tp1 - (plot_size / 2))
y = int(tp2 - ((e * plot_size) - (plot_size / 2)))
w = plot_size
h = plot_size * e
capture_win_lanes = WindowCapture(None, "lanes", None, (w, h, x+w, y+h))
screenshot = capture_win_lanes.get_screenshot()
needlew = cv.imread("test1.jpg", cv.IMREAD_UNCHANGED)
res = vision_stun.find(needlew, screenshot, 0.9, 1)
if len(res) >= 1:
break
#vision_stun.draw_rectangles(needlew, res)
#cv.imshow("screenshot", needlew)
#cv.waitKey(150)
# ul[0], ul[1], plot_size, plotsize*e
# ll -> tp1 - plot/2 ooooooooooo
# -> tp2 + plot/2
# ul -> tp1 - plot/2
# -> tp2 - e*plot - plot/2
# lr -> tp1 + plot/2
# -> tp2 - plot/2
# ur -> tp1 + plot/2
# -> tp2 - e*plot - plot/2
'''
dig_point(tp1, tp2, DIG_TIME)
# cv.circle(screenshot, (tp1, tp2), 7, (255, 0, 255), -1)
# cv.imshow("screenshot", screenshot)
@@ -83,8 +117,18 @@ def run():
for g in range(0, e, 1):
# right click
tp1 = tp1 + plot_size
if tp2 <= config.returnDiggingWindowPos2()[3] + plot_size:
if tp2 <= config.returnDiggingWindowPos2()[3] + (plot_size / 2):
continue
# ll -> tp1 - plot/2
# -> tp2 + plot/2
# ul -> tp1 - plot/2
# -> tp2 - plot/2
# lr -> tp1 + e*plot + plot/2
# -> tp2 + plot/2
# ur -> tp1 + e*plot + plot/2
# -> tp2 - plot/2
dig_point(tp1, tp2, DIG_TIME)
# cv.circle(screenshot, (tp1, tp2), 7, (127, 0, 255), -1)
# cv.imshow("screenshot", screenshot)
@@ -117,7 +161,7 @@ def run():
for u in range(0, e, 1):
# left click
tp1 = tp1 - plot_size
if tp2 >= config.returnDiggingWindowPos2()[1] + plot_size:
if tp2 >= config.returnDiggingWindowPos2()[1] + (plot_size / 2):
continue
dig_point(tp1, tp2, DIG_TIME)
# cv.circle(screenshot, (tp1, tp2), 7, (0, 0, 255), -1)