You've already forked MineEVECraft
mirror of
https://github.com/Llloooggg/MineEVECraft.git
synced 2026-03-06 03:36:24 +03:00
Возврат с easyocr к tessaract
This commit is contained in:
61
main.py
61
main.py
@@ -7,13 +7,15 @@ import cv2
|
|||||||
import pygetwindow as gw
|
import pygetwindow as gw
|
||||||
import pyautogui as pg
|
import pyautogui as pg
|
||||||
from pyclick import HumanClicker
|
from pyclick import HumanClicker
|
||||||
import easyocr
|
from pytesseract import pytesseract as pt
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
|
|
||||||
debug = True
|
debug = True
|
||||||
|
|
||||||
win_name = "EVE - Nostrom Stone"
|
win_name = "EVE - Nostrom Stone"
|
||||||
|
|
||||||
|
pt.tesseract_cmd = "C:\\Program Files\\Tesseract-OCR\\tesseract.exe"
|
||||||
|
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
level=logging.DEBUG,
|
level=logging.DEBUG,
|
||||||
format="%(asctime)s - %(message)s",
|
format="%(asctime)s - %(message)s",
|
||||||
@@ -23,9 +25,6 @@ logging.basicConfig(
|
|||||||
|
|
||||||
logging.info("Бот: запущен")
|
logging.info("Бот: запущен")
|
||||||
|
|
||||||
reader = easyocr.Reader(["en"], gpu=True)
|
|
||||||
logging.info("Бот: модели загружены")
|
|
||||||
|
|
||||||
hc = HumanClicker()
|
hc = HumanClicker()
|
||||||
|
|
||||||
|
|
||||||
@@ -107,29 +106,35 @@ def highlite_boxes(boxes, module_name, file_name):
|
|||||||
|
|
||||||
|
|
||||||
def get_boxes(screenshot):
|
def get_boxes(screenshot):
|
||||||
results = reader.readtext(
|
results = pt.image_to_data(
|
||||||
cv2.bitwise_not(cv2.cvtColor(screenshot, cv2.COLOR_BGR2GRAY)),
|
cv2.bitwise_not(cv2.cvtColor(screenshot, cv2.COLOR_BGR2GRAY)),
|
||||||
low_text=0.4,
|
lang="eng",
|
||||||
width_ths=1.5,
|
output_type=pt.Output.DATAFRAME,
|
||||||
|
config="--psm 3",
|
||||||
)
|
)
|
||||||
logging.debug("Боксы: получены")
|
logging.debug("Боксы: получены")
|
||||||
|
results = results.loc[
|
||||||
|
(results["conf"] > 30)
|
||||||
|
& (results["text"].notnull())
|
||||||
|
& (len(results["text"].str.strip()) > 0)
|
||||||
|
]
|
||||||
|
|
||||||
results_frame = pd.DataFrame(
|
results_frame = pd.DataFrame(
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
int(result[0][0][0]), # tl_x
|
result.left, # tl_x
|
||||||
int(result[0][0][1]), # tl_y
|
result.top, # tl_y
|
||||||
int(result[0][1][0]), # tr_x
|
result.left + result.width, # tr_x
|
||||||
int(result[0][1][1]), # tr_y
|
result.top, # tr_y
|
||||||
int(result[0][2][0]), # br_x
|
result.left + result.width, # br_x
|
||||||
int(result[0][2][1]), # br_y
|
result.top + result.height, # br_y
|
||||||
int(result[0][3][0]), # bl_x
|
result.left, # bl_x
|
||||||
int(result[0][3][1]), # bl_y
|
result.top + result.height, # bl_y
|
||||||
int((result[0][0][0] + result[0][1][0]) / 2), # cent_x
|
int(result.left + result.width / 2), # cent_x
|
||||||
int((result[0][0][1] + result[0][3][1]) / 2), # cent_y
|
int(result.top + result.height / 2), # cent_y
|
||||||
result[1].lower(), # text
|
result.text.lower(), # text
|
||||||
]
|
]
|
||||||
for result in results
|
for result in results.itertuples(index=False)
|
||||||
],
|
],
|
||||||
columns=[
|
columns=[
|
||||||
"tl_x",
|
"tl_x",
|
||||||
@@ -147,7 +152,7 @@ def get_boxes(screenshot):
|
|||||||
)
|
)
|
||||||
|
|
||||||
results_frame = results_frame.loc[results_frame["text"].str.len() > 2]
|
results_frame = results_frame.loc[results_frame["text"].str.len() > 2]
|
||||||
logging.debug("Боксы: переведены во фрейм")
|
logging.debug("Боксы: переведены в удобный фрейм")
|
||||||
logging.info("Боксы: готовы")
|
logging.info("Боксы: готовы")
|
||||||
|
|
||||||
if debug:
|
if debug:
|
||||||
@@ -164,7 +169,7 @@ def get_targets(boxes_frame, text=False):
|
|||||||
boxes_frame["text"] == "name", ["cent_x", "cent_y"]
|
boxes_frame["text"] == "name", ["cent_x", "cent_y"]
|
||||||
].values[0]
|
].values[0]
|
||||||
anchor_bot_y = boxes_frame.loc[
|
anchor_bot_y = boxes_frame.loc[
|
||||||
boxes_frame["text"] == "drones in", "cent_y"
|
boxes_frame["text"] == "hobgoblin", "cent_y"
|
||||||
].values[0]
|
].values[0]
|
||||||
|
|
||||||
targets = boxes_frame.loc[
|
targets = boxes_frame.loc[
|
||||||
@@ -203,7 +208,7 @@ def go_to_minefield():
|
|||||||
global screenshot
|
global screenshot
|
||||||
screenshot = get_screenshot()
|
screenshot = get_screenshot()
|
||||||
boxes_frame = get_boxes(screenshot)
|
boxes_frame = get_boxes(screenshot)
|
||||||
targets = get_targets(boxes_frame, "asteroid belt")
|
targets = get_targets(boxes_frame, "belt")
|
||||||
|
|
||||||
click_mouse(targets.iloc[0].cent_x, targets.iloc[0].cent_y, True)
|
click_mouse(targets.iloc[0].cent_x, targets.iloc[0].cent_y, True)
|
||||||
|
|
||||||
@@ -228,11 +233,12 @@ def start_mine():
|
|||||||
screenshot = get_screenshot()
|
screenshot = get_screenshot()
|
||||||
boxes_frame = get_boxes(screenshot)
|
boxes_frame = get_boxes(screenshot)
|
||||||
|
|
||||||
target_lock_cor = get_cors_by_unique_name(boxes_frame, "lock target")
|
target_lock_cor = get_cors_by_unique_name(boxes_frame, "lock")
|
||||||
if target_lock_cor:
|
if target_lock_cor:
|
||||||
click_mouse(target_lock_cor[0], target_lock_cor[1])
|
click_mouse(target_lock_cor[0], target_lock_cor[1])
|
||||||
time.sleep(random.uniform(4.4, 5.8))
|
time.sleep(random.uniform(4.4, 5.8))
|
||||||
pg.press("f1")
|
pg.press("f1")
|
||||||
|
time.sleep(random.uniform(0.1, 1))
|
||||||
pg.press("f2")
|
pg.press("f2")
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@@ -244,12 +250,7 @@ def start_mine():
|
|||||||
while True:
|
while True:
|
||||||
screenshot = get_screenshot()
|
screenshot = get_screenshot()
|
||||||
boxes_frame = get_boxes(screenshot)
|
boxes_frame = get_boxes(screenshot)
|
||||||
targets = get_targets(boxes_frame, "\\(veldspar\\)")
|
targets = get_targets(boxes_frame, "(veldspar)")
|
||||||
|
|
||||||
# move_mouse(targets.iloc[0].cent_x, targets.iloc[0].cent_y)
|
|
||||||
# pg.click()
|
|
||||||
# pg.click(button="right")
|
|
||||||
# move_mouse(30, 30)
|
|
||||||
|
|
||||||
input("Следущий скриншот - enter")
|
input("Следущий скриншот - enter")
|
||||||
"""
|
"""
|
||||||
@@ -265,4 +266,4 @@ def main(current_state="EMPTY"):
|
|||||||
current_state = "MINING"
|
current_state = "MINING"
|
||||||
|
|
||||||
|
|
||||||
main("UNDOCKED")
|
main("ON_MINEFILD")
|
||||||
|
|||||||
@@ -1,13 +1,5 @@
|
|||||||
certifi==2022.12.7
|
|
||||||
charset-normalizer==3.1.0
|
|
||||||
easyocr==1.6.2
|
|
||||||
et-xmlfile==1.1.0
|
et-xmlfile==1.1.0
|
||||||
idna==3.4
|
|
||||||
imageio==2.26.0
|
|
||||||
lazy_loader==0.1
|
|
||||||
MouseInfo==0.1.3
|
MouseInfo==0.1.3
|
||||||
networkx==3.0
|
|
||||||
ninja==1.11.1
|
|
||||||
numpy==1.24.2
|
numpy==1.24.2
|
||||||
opencv-python==4.7.0.72
|
opencv-python==4.7.0.72
|
||||||
openpyxl==3.1.1
|
openpyxl==3.1.1
|
||||||
@@ -16,27 +8,15 @@ pandas==1.5.3
|
|||||||
Pillow==9.4.0
|
Pillow==9.4.0
|
||||||
PyAutoGUI==0.9.53
|
PyAutoGUI==0.9.53
|
||||||
pyclick==0.0.2
|
pyclick==0.0.2
|
||||||
pyclipper==1.3.0.post4
|
|
||||||
PyGetWindow==0.0.9
|
PyGetWindow==0.0.9
|
||||||
PyMsgBox==1.0.9
|
PyMsgBox==1.0.9
|
||||||
pyperclip==1.8.2
|
pyperclip==1.8.2
|
||||||
PyRect==0.2.0
|
PyRect==0.2.0
|
||||||
PyScreeze==0.1.28
|
PyScreeze==0.1.28
|
||||||
python-bidi==0.4.2
|
pytesseract==0.3.10
|
||||||
python-dateutil==2.8.2
|
python-dateutil==2.8.2
|
||||||
python3-xlib==0.15
|
python3-xlib==0.15
|
||||||
pytweening==1.0.4
|
pytweening==1.0.4
|
||||||
pytz==2022.7.1
|
pytz==2022.7.1
|
||||||
PyWavelets==1.4.1
|
|
||||||
PyYAML==6.0
|
|
||||||
requests==2.28.2
|
|
||||||
scikit-image==0.20.0
|
|
||||||
scipy==1.10.1
|
|
||||||
shapely==2.0.1
|
|
||||||
six==1.16.0
|
six==1.16.0
|
||||||
tifffile==2023.2.28
|
|
||||||
torch==1.13.1+cu116
|
|
||||||
torchvision==0.14.1+cu116
|
|
||||||
typing_extensions==4.5.0
|
|
||||||
urllib3==1.26.14
|
|
||||||
xlib==0.21
|
xlib==0.21
|
||||||
|
|||||||
Reference in New Issue
Block a user