refactor digging

This commit is contained in:
2022-05-01 17:18:19 +02:00
parent 3691bb9f78
commit 6d6cabfa42

View File

@@ -16,6 +16,9 @@ def run():
# initialize the user-class # initialize the user-class
config = UserConfigs() config = UserConfigs()
# PLOT_TO_USE = "business"
PLOT_TO_USE = "main_plot"
# initialize the StunWindowCapture class # initialize the StunWindowCapture class
try: try:
capture_window = WindowCapture( capture_window = WindowCapture(
@@ -27,6 +30,9 @@ def run():
# capture_window = cv.VideoCapture("snip_slam.mp4") # capture_window = cv.VideoCapture("snip_slam.mp4")
video_mode = True video_mode = True
# plot_to_use = "business"
plot_to_use = "main_plot"
# initialize the StunVision class # initialize the StunVision class
vision_stun = Vision() vision_stun = Vision()
# initialize the StunOverlay class # initialize the StunOverlay class
@@ -49,8 +55,6 @@ def run():
print("pausing") print("pausing")
continue continue
if video_mode: if video_mode:
break break
else: else:
@@ -67,24 +71,25 @@ def run():
# continue # continue
needles = [] needles = []
#needles.append(cv.imread("wtf.jpg", cv.IMREAD_UNCHANGED)) if PLOT_TO_USE == "business":
needles.append(cv.imread("dig/Brown0.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("dig/Brown0.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("dig/1.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("dig/1.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("dig/2.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("dig/2.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("dig/3.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("dig/3.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("dig/4.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("dig/4.jpg", cv.IMREAD_UNCHANGED))
#needles.append(cv.imread("H1.jpg", cv.IMREAD_UNCHANGED)) else:
#needles.append(cv.imread("H2.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("H1.jpg", cv.IMREAD_UNCHANGED))
#needles.append(cv.imread("H3.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("H2.jpg", cv.IMREAD_UNCHANGED))
#needles.append(cv.imread("H4.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("H3.jpg", cv.IMREAD_UNCHANGED))
# needles.append(cv.imread("D1.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("H4.jpg", cv.IMREAD_UNCHANGED))
# needles.append(cv.imread("D2.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("D1.jpg", cv.IMREAD_UNCHANGED))
# needles.append(cv.imread("D3.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("D2.jpg", cv.IMREAD_UNCHANGED))
# needles.append(cv.imread("D3.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("D3.jpg", cv.IMREAD_UNCHANGED))
# needles.append(cv.imread("D4.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("D3.jpg", cv.IMREAD_UNCHANGED))
# needles.append(cv.imread("D5.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("D4.jpg", cv.IMREAD_UNCHANGED))
# needles.append(cv.imread("D6.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("D5.jpg", cv.IMREAD_UNCHANGED))
# needles.append(cv.imread("D7.jpg", cv.IMREAD_UNCHANGED)) needles.append(cv.imread("D6.jpg", cv.IMREAD_UNCHANGED))
needles.append(cv.imread("D7.jpg", cv.IMREAD_UNCHANGED))
for needle in needles: for needle in needles:
# do object detection # do object detection
@@ -131,8 +136,10 @@ def run():
pause = True pause = True
break break
if PLOT_TO_USE == "main_plot":
screenshot = capture_window.get_screenshot() screenshot = capture_window.get_screenshot()
rectangles = vision_stun.find(screenshot, cv.imread("dig/ok_button.jpg", cv.IMREAD_UNCHANGED), 0.8, 1) rectangles = vision_stun.find(screenshot, cv.imread("dig/ok_button.jpg", cv.IMREAD_UNCHANGED), 0.8,
1)
# 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)
if len(rectangles) == 1: if len(rectangles) == 1:
@@ -153,6 +160,14 @@ def run():
if keyboard.is_pressed('p') == True or pause == True: if keyboard.is_pressed('p') == True or pause == True:
pause = True pause = True
break break
if keyboard.is_pressed('p') == True or pause == True:
pause = True
break
if keyboard.is_pressed('p') == True or pause == True:
pause = True
break
# debug the loop rate # debug the loop rate
print('FPS {}'.format(1 / (time() - loop_time))) print('FPS {}'.format(1 / (time() - loop_time)))