mirror of
https://github.com/fishyboteso/fishyboteso.git
synced 2024-08-30 18:32:13 +00:00
fullauto rect detection done, and...
- window.show now also shows ready images, - removed debug condition to print "Running with admin"
This commit is contained in:
@ -29,7 +29,7 @@ def initialize(c: Config, window_to_hide):
|
|||||||
except AttributeError:
|
except AttributeError:
|
||||||
is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0
|
is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0
|
||||||
|
|
||||||
if is_admin and c.get("debug"):
|
if is_admin:
|
||||||
logging.info("Running with admin privileges")
|
logging.info("Running with admin privileges")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -12,7 +12,7 @@ class IEngine(ABC):
|
|||||||
def __init__(self, config, gui_ref: 'Callable[[], GUI]'):
|
def __init__(self, config, gui_ref: 'Callable[[], GUI]'):
|
||||||
self.get_gui = gui_ref
|
self.get_gui = gui_ref
|
||||||
self.start = False
|
self.start = False
|
||||||
self.fishPixWindow = None
|
self.window = None
|
||||||
self.thread = None
|
self.thread = None
|
||||||
self.config = config
|
self.config = config
|
||||||
|
|
||||||
|
@ -1,13 +1,55 @@
|
|||||||
|
import cv2
|
||||||
import logging
|
import logging
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
import numpy as np
|
||||||
|
import pywintypes
|
||||||
|
|
||||||
from fishy.engine.IEngine import IEngine
|
from fishy.engine.IEngine import IEngine
|
||||||
|
from fishy.engine.window import Window
|
||||||
|
|
||||||
|
|
||||||
class FullAuto(IEngine):
|
class FullAuto(IEngine):
|
||||||
def run(self):
|
def run(self):
|
||||||
self.gui.bot_started(True)
|
|
||||||
|
try:
|
||||||
|
Window.init(False)
|
||||||
|
except pywintypes.error:
|
||||||
|
logging.info("Game window not found")
|
||||||
|
self.start = False
|
||||||
|
return
|
||||||
|
|
||||||
|
self.window = Window(color=cv2.COLOR_RGB2GRAY)
|
||||||
|
|
||||||
|
if self.get_gui is not None:
|
||||||
|
self.gui.bot_started(True)
|
||||||
while self.start:
|
while self.start:
|
||||||
logging.debug("running full auto")
|
Window.loop()
|
||||||
time.sleep(0.5)
|
|
||||||
|
img = self.window.get_capture()
|
||||||
|
img = cv2.inRange(img, 0, 1)
|
||||||
|
cnt, h = cv2.findContours(img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
||||||
|
|
||||||
|
"""
|
||||||
|
code from https://stackoverflow.com/a/45770227/4512396
|
||||||
|
"""
|
||||||
|
crop = self.window.get_capture()
|
||||||
|
for i in range(len(cnt)):
|
||||||
|
area = cv2.contourArea(cnt[i])
|
||||||
|
if 5000 < area < 100000:
|
||||||
|
mask = np.zeros_like(img)
|
||||||
|
cv2.drawContours(mask, cnt, i, 255, -1)
|
||||||
|
x, y, w, h = cv2.boundingRect(cnt[i])
|
||||||
|
crop = self.window.get_capture()[y:h + y, x:w + x]
|
||||||
|
|
||||||
|
# cnt, h = cv2.findContours(img, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
|
||||||
|
# print(cnt)
|
||||||
|
|
||||||
|
self.window.show("test", ready_img=crop)
|
||||||
|
Window.loop_end()
|
||||||
self.gui.bot_started(False)
|
self.gui.bot_started(False)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
bot = FullAuto(None, None)
|
||||||
|
bot.toggle_start()
|
||||||
|
@ -108,18 +108,20 @@ class Window:
|
|||||||
else:
|
else:
|
||||||
return func(self.get_capture())
|
return func(self.get_capture())
|
||||||
|
|
||||||
def show(self, name, resize=None, func=None):
|
def show(self, name, resize=None, func=None, ready_img=None):
|
||||||
"""
|
"""
|
||||||
Displays the processed image for debugging purposes
|
Displays the processed image for debugging purposes
|
||||||
:param name: unique name for the image, used to create a new window
|
:param name: unique name for the image, used to create a new window
|
||||||
:param resize: scale the image to make small images more visible
|
:param resize: scale the image to make small images more visible
|
||||||
:param func: function to process the image
|
:param func: function to process the image
|
||||||
"""
|
"""
|
||||||
img = self.processed_image(func)
|
if ready_img is None:
|
||||||
|
img = self.processed_image(func)
|
||||||
if resize is not None:
|
|
||||||
img = imutils.resize(img, width=resize)
|
|
||||||
|
|
||||||
|
if resize is not None:
|
||||||
|
img = imutils.resize(img, width=resize)
|
||||||
|
else:
|
||||||
|
img = ready_img
|
||||||
cv2.imshow(name, img)
|
cv2.imshow(name, img)
|
||||||
|
|
||||||
Window.showing = True
|
Window.showing = True
|
||||||
|
Reference in New Issue
Block a user