added ui support to farm bot

This commit is contained in:
2022-10-11 17:22:46 +02:00
parent 3d408eb909
commit 8376dba417
5 changed files with 123 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ import cv2 as cv
import pydirectinput
import keyboard
def mse(imageA, imageB):
# the 'Mean Squared Error' between the two images is the
# sum of the squared difference between the two images;
@@ -173,3 +174,21 @@ def check_for_ok_button(cap_win, vis, conf):
for pointi in pointis:
dig_point(pointi[0] + offset_left, pointi[1] + offset_down, 150)
def check_for_craft_button(cap_win, vis, conf):
screenshot = cap_win.get_screenshot()
needle = cv.imread("play.jpg", cv.IMREAD_UNCHANGED)
rectangles = vis.find(screenshot, needle, 0.7, 1)
if len(rectangles) == 1:
pointis = vis.get_click_points(rectangles)
for pointi in pointis:
dig_point(pointi[0], pointi[1], 150)
def get_click_point(rectangle):
# Loop over all the rectangles
x, y, w, h = rectangle
# Determine the center position
center_x = x + int(w / 2)
center_y = y + int(h / 2)
# Save the points
return int(center_x), int(center_y)