# ******************************************************* # ******************** LOCAL FUNCTIONS ****************** def wait(): time.sleep(WAIT_INTERVALS) # ***************************************************** # ******************* PROGRAM ************************* # Instantiate Buggy buggy = Buggy() # If connected if buggy.isConnected: # Stream the feed buggy.streamFeed() # Wait for feed to start... wait() # Loop try: if DISPLAY: cv2.namedWindow('normal', cv2.WINDOW_NORMAL)
# ******************************************************* # ******************** LOCAL FUNCTIONS ****************** def wait(): time.sleep(0.01) # ***************************************************** # ******************* PROGRAM ************************* # Instantiate Buggy buggy = Buggy() # If connected if buggy.isConnected: # Stream the feed buggy.streamFeed() # Wait for feed to start... wait() # Loop try: if DISPLAY: cv2.namedWindow('display_image', cv2.WINDOW_NORMAL)
WAIT_INTERVALS = 0.5 # Interval to wait (in seconds) between each picture taken # ******************************************************* # ******************** LOCAL FUNCTIONS ****************** def wait(): time.sleep(WAIT_INTERVALS) # ***************************************************** # ******************* PROGRAM ************************* # Instantiate Buggy buggy = Buggy() # If connected if buggy.isConnected: # Stream the feed buggy.streamFeed() # Wait for feed to start... wait() # Loop try: if DISPLAY: cv2.namedWindow('normal',cv2.WINDOW_NORMAL)
DISPLAY = True # Whether you want to display what the Buggy sees # ******************************************************* # ******************** LOCAL FUNCTIONS ****************** def wait(): time.sleep(0.01) # ***************************************************** # ******************* PROGRAM ************************* # Instantiate Buggy buggy = Buggy() # If connected if buggy.isConnected: # Stream the feed buggy.streamFeed() # Wait for feed to start... wait() # Loop try: if DISPLAY: cv2.namedWindow('display_image',cv2.WINDOW_NORMAL)
if wheel_direction is not "neutral": wheel_direction = "neutral" buggy.straightenWheels() confident_match = True if best_result > 0.2 else False # Will only move forward fast if confident moving_forward = True del arrow_buffer[:] return moving_forward, wheel_direction, confident_match, arrow_buffer # ***************************************************** # ******************* PROGRAM ************************* # Instantiate Buggy buggy = Buggy() # If connected if buggy.isConnected: # Set up signs for template matching sign_cross = cv2.imread(PATH_CROSS, 0) # Get image resolution from this IMAGE_RESOLUTION_w, IMAGE_RESOLUTION_h = sign_cross.shape[::-1] # Arrows arrow_list = list() ARROW_DEGREE_DIFF = 180//(NUMBER_OF_ARROWS-1) for i in range(NUMBER_OF_ARROWS): index_string = str(i) if len(index_string) == 1: index_string = '0' + index_string
GOAL_THRESHOLD = 0.7 # The threshold to use when matching the goal image - lower it is, the easier to find, but easier to make mistakes # ******************************************************* # ******************** LOCAL FUNCTIONS ****************** def wait(): time.sleep(0.01) # ***************************************************** # ******************* PROGRAM ************************* # Instantiate Buggy buggy = Buggy() # If connected if buggy.isConnected: # Stream the feed buggy.streamFeed() # Wait for feed to start... wait() # Loop try: if DISPLAY: cv2.namedWindow('normal',cv2.WINDOW_NORMAL)