# initialize the Vision class vision_limestone = Vision('albion_limestone_processed.jpg') # initialize the trackbar window vision_limestone.init_control_gui() # limestone HSV filter hsv_filter = HsvFilter(0, 180, 129, 15, 229, 243, 143, 0, 67, 0) loop_time = time() while (True): # get an updated image of the game screenshot = wincap.get_screenshot() # pre-process the image processed_image = vision_limestone.apply_hsv_filter(screenshot, hsv_filter) # do object detection rectangles = vision_limestone.find(processed_image, 0.46) # draw the detection results onto the original image output_image = vision_limestone.draw_rectangles(screenshot, rectangles) # display the processed image cv.imshow('Processed', processed_image) cv.imshow('Matches', output_image) # debug the loop rate print('FPS {}'.format(1 / (time() - loop_time))) loop_time = time()
mario_training_filter = HsvFilter(0, 5, 0, 179, 255, 255, 0, 17, 0, 0) # initialize vision class vision = Vision('') while (True): # get an updated image of the game # USE THIS IF YOU ARE USING SCREENCAPTURE # smash_screenshot = wincap.get_screenshot() # USE THIS IF YOU ARE READING A VIDEO FILE ret, smash_screenshot = cap.read() # apply filter to img. output_image = vision.apply_hsv_filter(smash_screenshot, mario_training_filter) move_locs[labels.neutral_b] = neutral_b.detectMultiScale(output_image) move_locs[labels.jab] = jab.detectMultiScale(output_image) move_locs[labels.shield] = sheild.detectMultiScale(output_image) # select object to track. tracker.track(output_image) weights = 1 detection_image = vision.draw_rectangles(output_image, move_locs) # JAB recenter tracker every time a jab is detected if (len(move_locs[labels.jab]) > 0 and time() - t.last_jab > 1): tracker.reset_tracker(output_image, move_locs[labels.jab]) count.jab += 1