diff --git a/dig/1.jpg b/dig/1.jpg deleted file mode 100644 index 4b9f2e0..0000000 Binary files a/dig/1.jpg and /dev/null differ diff --git a/dig/2.jpg b/dig/2.jpg deleted file mode 100644 index 606538a..0000000 Binary files a/dig/2.jpg and /dev/null differ diff --git a/dig/3.jpg b/dig/3.jpg deleted file mode 100644 index dcc8791..0000000 Binary files a/dig/3.jpg and /dev/null differ diff --git a/dig/4.jpg b/dig/4.jpg deleted file mode 100644 index a765952..0000000 Binary files a/dig/4.jpg and /dev/null differ diff --git a/dig/Brown0.jpg b/dig/Brown0.jpg deleted file mode 100644 index acdde21..0000000 Binary files a/dig/Brown0.jpg and /dev/null differ diff --git a/dig/D1.jpg b/dig/D1.jpg deleted file mode 100644 index b7e7bdb..0000000 Binary files a/dig/D1.jpg and /dev/null differ diff --git a/dig/D2.jpg b/dig/D2.jpg deleted file mode 100644 index 5faf0b8..0000000 Binary files a/dig/D2.jpg and /dev/null differ diff --git a/dig/D3.jpg b/dig/D3.jpg deleted file mode 100644 index 195b20e..0000000 Binary files a/dig/D3.jpg and /dev/null differ diff --git a/dig/D4.jpg b/dig/D4.jpg deleted file mode 100644 index c96b42f..0000000 Binary files a/dig/D4.jpg and /dev/null differ diff --git a/dig/D5.jpg b/dig/D5.jpg deleted file mode 100644 index ebe36fc..0000000 Binary files a/dig/D5.jpg and /dev/null differ diff --git a/dig/D6.jpg b/dig/D6.jpg deleted file mode 100644 index deb99ba..0000000 Binary files a/dig/D6.jpg and /dev/null differ diff --git a/dig/D7.jpg b/dig/D7.jpg deleted file mode 100644 index cdfb526..0000000 Binary files a/dig/D7.jpg and /dev/null differ diff --git a/dig/H1.jpg b/dig/H1.jpg deleted file mode 100644 index 2c4fe44..0000000 Binary files a/dig/H1.jpg and /dev/null differ diff --git a/dig/H2.jpg b/dig/H2.jpg deleted file mode 100644 index 89ac528..0000000 Binary files a/dig/H2.jpg and /dev/null differ diff --git a/dig/H3.jpg b/dig/H3.jpg deleted file mode 100644 index 9c090c5..0000000 Binary files a/dig/H3.jpg and /dev/null differ diff --git a/dig/H4.jpg b/dig/H4.jpg deleted file mode 100644 index 6cc4922..0000000 Binary files a/dig/H4.jpg and /dev/null differ diff --git a/dig/digging.jpg b/dig/digging.jpg deleted file mode 100644 index 250e0e9..0000000 Binary files a/dig/digging.jpg and /dev/null differ diff --git a/dig/ok_button.jpg b/dig/ok_button.jpg deleted file mode 100644 index d78f586..0000000 Binary files a/dig/ok_button.jpg and /dev/null differ diff --git a/dig/wtf.jpg b/dig/wtf.jpg deleted file mode 100644 index 2b3242f..0000000 Binary files a/dig/wtf.jpg and /dev/null differ diff --git a/digging_main.py b/digging_main.py deleted file mode 100644 index 0805f15..0000000 --- a/digging_main.py +++ /dev/null @@ -1,182 +0,0 @@ -import random -from time import time -from window_capture import WindowCapture -from vision import Vision -import cv2 as cv -import pytesseract -from hsvfilter import HsvFilter -from config_file import UserConfigs -# import pyautogui -import pydirectinput -import keyboard -from tresh_util import super_tresh_main, super_tresh_needle - - -def run(): - # initialize the user-class - config = UserConfigs() - - # PLOT_TO_USE = "business" - PLOT_TO_USE = "main_plot" - GRID_SIZE_WIDTH = 30 - GRID_SIZE_DEPTH = 24 - DIG_TIME = 150 - - # initialize the StunWindowCapture class - try: - capture_window = WindowCapture( - None, "dig", config) - video_mode = False - except: - # StunWindowCapture.list_window_names() - # print("Game not running, switching to video mode") - # capture_window = cv.VideoCapture("snip_slam.mp4") - video_mode = True - - # plot_to_use = "business" - plot_to_use = "main_plot" - - # initialize the StunVision class - vision_stun = Vision() - # initialize the StunOverlay class - hsv_filter = HsvFilter(0, 0, 124, 15, 255, 168, 0, 255, 0, 0) - - loop_time = time() - event_time = 0.0 - pointstore = [] - max_results = 0 - pause = True - while True: - if keyboard.is_pressed('p') == True: - pause = True - print('q pressed') - elif keyboard.is_pressed('o') == True: - pause = False - print('o pressed') - if pause: - # cv.waitKey(500) - print("pausing") - continue - - if video_mode: - break - else: - try: - # get an updated image of the game - screenshot = capture_window.get_screenshot() - # screenshot = cv.imread("buffbar.jpg") - except: - capture_window.release() - print("Game window not available - shutting down application") - break - # cv.imshow("screenshot", screenshot) - # cv.waitKey(150) - # continue - - needles = [] - if PLOT_TO_USE == "business": - 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/2.jpg", cv.IMREAD_UNCHANGED)) - needles.append(cv.imread("dig/3.jpg", cv.IMREAD_UNCHANGED)) - needles.append(cv.imread("dig/4.jpg", cv.IMREAD_UNCHANGED)) - else: - needles.append(cv.imread("dig/H1.jpg", cv.IMREAD_UNCHANGED)) - needles.append(cv.imread("dig/H2.jpg", cv.IMREAD_UNCHANGED)) - needles.append(cv.imread("dig/H3.jpg", cv.IMREAD_UNCHANGED)) - needles.append(cv.imread("dig/H4.jpg", cv.IMREAD_UNCHANGED)) - needles.append(cv.imread("dig/D1.jpg", cv.IMREAD_UNCHANGED)) - needles.append(cv.imread("dig/D2.jpg", cv.IMREAD_UNCHANGED)) - needles.append(cv.imread("dig/D3.jpg", cv.IMREAD_UNCHANGED)) - needles.append(cv.imread("dig/D3.jpg", cv.IMREAD_UNCHANGED)) - needles.append(cv.imread("dig/D4.jpg", cv.IMREAD_UNCHANGED)) - needles.append(cv.imread("dig/D5.jpg", cv.IMREAD_UNCHANGED)) - needles.append(cv.imread("dig/D6.jpg", cv.IMREAD_UNCHANGED)) - needles.append(cv.imread("dig/D7.jpg", cv.IMREAD_UNCHANGED)) - - for needle in needles: - # do object detection - screenshot = capture_window.get_screenshot() - rectangles = vision_stun.find(screenshot, needle, 0.8, 1) - # draw the detection results onto the original image - if len(rectangles) == 0: - continue - #output_image = vision_stun.draw_rectangles(screenshot, rectangles) - #cv.imshow("output_image", output_image) - #cv.waitKey(150) - - # only trigger ocr reading if a stun is detected - points = vision_stun.get_click_points(rectangles) - for point in points: - # 46 + 1 * 30 1410 == 1815 - 405 return [1410, 1128, 402, 22] - # 44 + 1 * 30 1350 == 1790 - 440 - # left_border = 402, 432 - # right_border = 1812, 1782 - # upper_border = 22, 50 - # lower_border = 1150, 1120 - - size = rectangles[0][2] + 1 - - left = int(round(rectangles[0][0] / size, 0)) # 4 - down = int(round(rectangles[0][1] / size, 0)) # 23 - offset_left = config.returnDiggingWindowPos()[2] - offset_down = config.returnDiggingWindowPos()[3] - # 167 1055 start - # 3x47 left 26x right to 30 - # 1x down 22x up to 24 - - # start 167, end 167 - (47 * 3), step -47 - start_left = point[0] - (size * left) - start_up = point[1] - (size * down) - for f in range(start_up, start_up + (size * GRID_SIZE_DEPTH), size): - for i in range(start_left, start_left + (size * GRID_SIZE_WIDTH), size): - pydirectinput.moveTo(i + offset_left, f + offset_down) - pydirectinput.mouseDown() - w = random.randint(1, 50) - cv.waitKey(DIG_TIME + w) - pydirectinput.mouseUp() - if keyboard.is_pressed('p') == True or pause == True: - pause = True - break - - if PLOT_TO_USE == "main_plot": - screenshot = capture_window.get_screenshot() - rectangles = vision_stun.find(screenshot, cv.imread("dig/ok_button.jpg", cv.IMREAD_UNCHANGED), 0.5, - 1) - # draw the detection results onto the original image - output_image = vision_stun.draw_rectangles(screenshot, rectangles) - if len(rectangles) == 1: - pointis = vision_stun.get_click_points(rectangles) - for pointi in pointis: - pydirectinput.moveTo(pointi[0] + offset_left, pointi[1] + offset_down) - pydirectinput.mouseDown() - w = random.randint(1, 50) - cv.waitKey(DIG_TIME + w) - pydirectinput.mouseUp() - - if keyboard.is_pressed('p') == True or pause == True: - pause = True - 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 - 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 - print('FPS {}'.format(1 / (time() - loop_time))) - loop_time = time() - cv.waitKey(150) - - -if __name__ == "__main__": - run() diff --git a/equip/chest_1_32.jpg b/equip/chest_1_32.jpg new file mode 100644 index 0000000..d7493f5 Binary files /dev/null and b/equip/chest_1_32.jpg differ diff --git a/equip/chest_2_32.jpg b/equip/chest_2_32.jpg new file mode 100644 index 0000000..0759d06 Binary files /dev/null and b/equip/chest_2_32.jpg differ diff --git a/equip/chest_3_32.jpg b/equip/chest_3_32.jpg new file mode 100644 index 0000000..b5dba66 Binary files /dev/null and b/equip/chest_3_32.jpg differ diff --git a/equip/coin_1_32.jpg b/equip/coin_1_32.jpg new file mode 100644 index 0000000..c5db419 Binary files /dev/null and b/equip/coin_1_32.jpg differ diff --git a/equip/coin_2_32.jpg b/equip/coin_2_32.jpg new file mode 100644 index 0000000..609f477 Binary files /dev/null and b/equip/coin_2_32.jpg differ diff --git a/equip/key_1_32.jpg b/equip/key_1_32.jpg new file mode 100644 index 0000000..11947f0 Binary files /dev/null and b/equip/key_1_32.jpg differ diff --git a/equip/key_2_32.jpg b/equip/key_2_32.jpg new file mode 100644 index 0000000..95e476a Binary files /dev/null and b/equip/key_2_32.jpg differ diff --git a/equip/main_e1_32.jpg b/equip/main_e1_32.jpg new file mode 100644 index 0000000..44977c2 Binary files /dev/null and b/equip/main_e1_32.jpg differ diff --git a/equip/main_e2_32.jpg b/equip/main_e2_32.jpg new file mode 100644 index 0000000..c4301dc Binary files /dev/null and b/equip/main_e2_32.jpg differ diff --git a/equip/rune_1_32.jpg b/equip/rune_1_32.jpg new file mode 100644 index 0000000..db170c4 Binary files /dev/null and b/equip/rune_1_32.jpg differ diff --git a/equip/rune_2_32.jpg b/equip/rune_2_32.jpg new file mode 100644 index 0000000..3f21f1b Binary files /dev/null and b/equip/rune_2_32.jpg differ diff --git a/equip/sword_1_32.jpg b/equip/sword_1_32.jpg new file mode 100644 index 0000000..bd34131 Binary files /dev/null and b/equip/sword_1_32.jpg differ diff --git a/equip/sword_2_32.jpg b/equip/sword_2_32.jpg new file mode 100644 index 0000000..5dfee63 Binary files /dev/null and b/equip/sword_2_32.jpg differ diff --git a/equip/sword_3_32.jpg b/equip/sword_3_32.jpg new file mode 100644 index 0000000..8cbbdbd Binary files /dev/null and b/equip/sword_3_32.jpg differ diff --git a/equip/sword_4_32.jpg b/equip/sword_4_32.jpg new file mode 100644 index 0000000..3272333 Binary files /dev/null and b/equip/sword_4_32.jpg differ diff --git a/equip/sword_5_32.jpg b/equip/sword_5_32.jpg new file mode 100644 index 0000000..ccde5dd Binary files /dev/null and b/equip/sword_5_32.jpg differ diff --git a/equip/sword_e1_32.jpg b/equip/sword_e1_32.jpg new file mode 100644 index 0000000..9fd4813 Binary files /dev/null and b/equip/sword_e1_32.jpg differ diff --git a/equip/sword_e2_32.jpg b/equip/sword_e2_32.jpg new file mode 100644 index 0000000..04b58e0 Binary files /dev/null and b/equip/sword_e2_32.jpg differ diff --git a/equipment_main.py b/equipment_main.py index e245a25..c6ad78c 100644 --- a/equipment_main.py +++ b/equipment_main.py @@ -3,13 +3,10 @@ from time import time from window_capture import WindowCapture from vision import Vision import cv2 as cv -import pytesseract from hsvfilter import HsvFilter from config_file import UserConfigs -# import pyautogui import pydirectinput import keyboard -from tresh_util import super_tresh_main, super_tresh_needle EMITTER_MAIN = "main" EMITTER_MUSH = "mushroom" diff --git a/sharpening.py b/sharpening.py deleted file mode 100644 index 6ed6d3a..0000000 --- a/sharpening.py +++ /dev/null @@ -1,67 +0,0 @@ -import cv2 -import numpy as np - - - -image = cv2.imread("dig/digging.jpg") - -cv2.imshow("Image", image) - -gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) -cv2.imshow("gray", gray) - -blur = cv2.GaussianBlur(gray, (5,5), 0) -cv2.imshow("blur", blur) - -thresh = cv2.adaptiveThreshold(blur, 255, 1, 1, 11, 2) - -#thresh = cv2.bitwise_not(thresh) - -cv2.imshow("thresh", thresh) -#cv2.waitKey() -contours, _ = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) - -max_area = 0 -c = 0 -for i in contours: - area = cv2.contourArea(i) - if area > 1000: - if area > max_area: - max_area = area - best_cnt = i - image = cv2.drawContours(image, contours, c, (0, 255, 0), 1) - c+=1 - -mask = np.zeros((gray.shape),np.uint8) -cv2.drawContours(mask,[best_cnt],0,255,-1) -cv2.drawContours(mask,[best_cnt],0,0,1) -cv2.imshow("mask", mask) - -out = np.zeros_like(gray) -out[mask == 255] = gray[mask == 255] -cv2.imshow("New image", out) - -blur = cv2.GaussianBlur(out, (5,5), 0) -cv2.imshow("blur1", blur) - -thresh = cv2.adaptiveThreshold(blur, 255, 1, 1, 11, 2) -thresh = cv2.bitwise_not(thresh) -cv2.imshow("thresh1", thresh) - -contours, _ = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) - -squares = [] -c = 0 -for i in contours: - area = cv2.contourArea(i) - cnt_len = cv2.arcLength(i, True) - cnt = cv2.approxPolyDP(i, 0.01 * cnt_len, True) - if area > 1000/2: - squares.append(cnt) - #cv2.drawContours(image, contours, c, (0, 255, 0), 1) - c+=1 -cv2.drawContours(image, squares, -1, (0, 255, 0), 1) - -cv2.imshow("Final Image", image) -cv2.waitKey(0) -cv2.destroyAllWindows() \ No newline at end of file diff --git a/tresh_util.py b/tresh_util.py deleted file mode 100644 index 13b97e2..0000000 --- a/tresh_util.py +++ /dev/null @@ -1,94 +0,0 @@ -import cv2 -import numpy as np - - -def super_tresh_main(img): - image = img - - # cv2.imshow("Image", image) - - gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) - # cv2.imshow("gray", gray) - - blur = cv2.GaussianBlur(gray, (5, 5), 0) - # cv2.imshow("blur", blur) - - thresh = cv2.adaptiveThreshold(blur, 255, 1, 1, 11, 2) - - # thresh = cv2.bitwise_not(thresh) - - # cv2.imshow("thresh", thresh) - # cv2.waitKey() - contours, _ = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) - - max_area = 0 - c = 0 - for i in contours: - area = cv2.contourArea(i) - if area > 1000: - if area > max_area: - max_area = area - best_cnt = i - image = cv2.drawContours(image, contours, c, (0, 255, 0), 1) - c += 1 - - mask = np.zeros((gray.shape), np.uint8) - cv2.drawContours(mask, [best_cnt], 0, 255, -1) - cv2.drawContours(mask, [best_cnt], 0, 0, 1) - # cv2.imshow("mask", mask) - - out = np.zeros_like(gray) - out[mask == 255] = gray[mask == 255] - # cv2.imshow("New image", out) - - blur = cv2.GaussianBlur(out, (5, 5), 0) - # cv2.imshow("blur1", blur) - - thresh = cv2.adaptiveThreshold(blur, 255, 1, 1, 11, 2) - return cv2.bitwise_not(thresh) - -def super_tresh_needle(img): - image = img - - # cv2.imshow("Image", image) - - gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) - # cv2.imshow("gray", gray) - - blur = cv2.GaussianBlur(gray, (5, 5), 0) - # cv2.imshow("blur", blur) - - thresh = cv2.adaptiveThreshold(blur, 255, 1, 1, 11, 2) - - return cv2.bitwise_not(thresh) -''' - # cv2.imshow("thresh", thresh) - # cv2.waitKey() - contours, _ = cv2.findContours(thresh, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE) - - max_area = 0 - c = 0 - for i in contours: - area = cv2.contourArea(i) - if area > 1000: - if area > max_area: - max_area = area - best_cnt = i - image = cv2.drawContours(image, contours, c, (0, 255, 0), 1) - c += 1 - - mask = np.zeros((gray.shape), np.uint8) - cv2.drawContours(mask, [best_cnt], 0, 255, -1) - cv2.drawContours(mask, [best_cnt], 0, 0, 1) - # cv2.imshow("mask", mask) - - out = np.zeros_like(gray) - out[mask == 255] = gray[mask == 255] - # cv2.imshow("New image", out) - - blur = cv2.GaussianBlur(out, (5, 5), 0) - # cv2.imshow("blur1", blur) - - thresh = cv2.adaptiveThreshold(blur, 255, 1, 1, 11, 2) - return cv2.bitwise_not(thresh) -''' \ No newline at end of file diff --git a/utils.py b/utils.py index d933472..007ddb3 100644 --- a/utils.py +++ b/utils.py @@ -11,8 +11,6 @@ import cv2 as cv import pydirectinput import keyboard -from tresh_util import super_tresh_main, super_tresh_needle - def mse(imageA, imageB): # the 'Mean Squared Error' between the two images is the