This commit is contained in:
2022-05-05 21:31:55 +02:00
parent 2e97ee07b8
commit bcaa608cd3
42 changed files with 0 additions and 348 deletions

BIN
dig/1.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

BIN
dig/2.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

BIN
dig/3.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

BIN
dig/4.jpg

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View File

@@ -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()

BIN
equip/chest_1_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
equip/chest_2_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
equip/chest_3_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
equip/coin_1_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

BIN
equip/coin_2_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

BIN
equip/key_1_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
equip/key_2_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
equip/main_e1_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
equip/main_e2_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
equip/rune_1_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
equip/rune_2_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

BIN
equip/sword_1_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
equip/sword_2_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
equip/sword_3_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

BIN
equip/sword_4_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

BIN
equip/sword_5_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
equip/sword_e1_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

BIN
equip/sword_e2_32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

View File

@@ -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"

View File

@@ -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()

View File

@@ -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)
'''

View File

@@ -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