import cv2 as cv import numpy as np import os from time import time # from PIL import ImageGrab from windowcapture import WindowCapture # from vision import findClickPositions from vision import Vision # Change the working directory to the folder this script is in. os.chdir(os.path.dirname(os.path.abspath(__file__))) wincap = WindowCapture('Toontown Rewritten') # Previously, we had to use the object to call this function. # Now that it is static, we can call the class directly. # wincap.list_window_names() WindowCapture.list_window_names() # Initialize the Vision clas vision_speedchat = Vision('speedchat_bubble.png') loop_time = time() points = [] firstRun = True while (True): # screenshot = None # screenshot = pyautogui.screenshot() # cv.imshow is not compatable with pyautogui ss format. # so we use numpy. # screenshot = ImageGrab.grab()
import cv2 as cv import numpy as np import os from time import time # from PIL import ImageGrab from windowcapture import WindowCapture # Change the working directory to the folder this script is in. os.chdir(os.path.dirname(os.path.abspath(__file__))) wincap = WindowCapture('Toontown Rewritten') wincap.list_window_names() loop_time = time() while(True): # screenshot = None # screenshot = pyautogui.screenshot() # cv.imshow is not compatable with pyautogui ss format. # so we use numpy. # screenshot = ImageGrab.grab() # screenshot = np.array(screenshot) # Reversing the RGB values # screenshot = screenshot[:, :, ::-1].copy() # More self-documenting version below: # screenshot = cv.cvtColor(screenshot, cv.COLOR_RGB2BGR) # screenshot = window_capture() screenshot = wincap.get_screenshot() cv.imshow('Computer Vision', screenshot) # debug the loop rate - bad atm