def main(): img = None main_win = Windows_handler.WinHandler(title='Nox',class_name='Qt5QWindowIcon') main_box = main_win.get_bbox() px_handler = Pixel_handler.PixelSearch(win_handler=main_win) mouse = Mouse_handler.MouseMovement(window_handler=main_win) main_win.init_window() cv2.namedWindow('image_name') cv2.namedWindow('config') while True: img = px_handler.grab_window(bbox=main_box) img = px_handler.img_to_numpy(img,compound=False) img = cv2.cvtColor(img,cv2.COLOR_RGB2BGR) orb = cv2.ORB_create() kp = orb.detect(img, None) kp, des = orb.compute(img, kp) img2 = cv2.drawKeypoints(img, kp) cv2.imshow('image_name',img2) cv2.setMouseCallback('image_name', mouse_event, param=img) k = cv2.waitKey(1) if k == ord('q'): # wait for ESC key to exit cv2.destroyAllWindows() quit(0)
def multi_screen(): wh = WindowHandlers.WinHandler("Netflix") print(wh.get_desktop_stats()) px = PixelSearch.PixelSearch(win_handler=wh) mat = px.pixel_search(0xA87161, 12) Helpers.show_matrix(mat)
def search_for_pixels(): wh = WindowHandlers.WinHandler() wh.set_target(title_name='Untitled - Notepad' ) #desktop is a special case that is the primary monitor wh.init_window() px = PixelSearch.PixelSearch(wh) mx = px.pixel_search(0xFFFFFF, shades=50) Helpers.show_matrix(mx)
def test_pixel_search(self): logging.debug("Running pixelsearch test") win_handler = wh.WinHandler('Kalkulator') pixel_search = ps.PixelSearch(win_handler) win_handler.init_window(pos=(0, 0, 320, 510)) sleep(1) im = Image.open('pixel_search_sample.png') array = np.array(im) print array
def test_basic_commands(self): win_handler = wh.WinHandler() pixel_handler = ps.PixelSearch(win_handler) mouse_handler = mm.MouseMovement(win_handler) com = CommandAndControl(win_handler, pixel_handler, mouse_handler) com.use_UAV((0.5, 0.5)) sleep(2) com.use_EMP((0.4, 0.4))
def test_window_grab(self): logging.debug("Running pixel search test") win_handler = wh.WinHandler('Kalkulator') pixel_search = ps.PixelSearch(win_handler) win_handler.init_window(pos=[0, 0, 320, 510]) sleep(1) pixel_search.grab_window('pixel_search.png') file = pixel_search.grab_window('pixel_search.png') im = Image.open('pixel_search_sample.png') im = Image.Image.crop(im, (20, 20, 200, 200)) im.load() im2 = Image.Image.crop(file, (20, 20, 200, 200)) im2.load() mat1 = im.tobytes() mat2 = im2.tobytes() assert (mat1 == mat2)
def main(self): window = self.find_window() bbox = window.get_bbox() pxs = PixelSearch.PixelSearch(window) while True: image = pxs.grab_window() img = pxs.img_to_numpy(image) img = cv2.cvtColor(img, cv2.COLOR_RGB2BGR) cv2.imshow('image_name', img) cv2.setMouseCallback('image_name', pxs.print_win_percentage_click, bbox) self.find_state(pxs, bbox, img) k = cv2.waitKey(1) if k == ord('q'): # wait for ESC key to exit cv2.destroyAllWindows() quit(0)
def test_basic_commander(self): logging.debug("Running a basic test of the commander functions") parser = SafeConfigParser() parser.read('config.ini') color = parser.get('PixelScan', 'redColor') color = int(color, 16) win_handler = wh.WinHandler() pixel_search = ps.PixelSearch(win_handler) mouse_handler = mm.MouseMovement(win_handler) bbox = win_handler.get_bbox() bbox_size = win_handler.get_bbox_size() win_handler.init_window(borderless=True) sleep(0.1) px = pixel_search.pixel_search(color, shades=2, debug='check.png') places = np.nonzero(px) for hit in range(len(places[0])): mouse_handler.click((places[1][hit], places[0][hit])) sleep(1)