NOTE: this example code uses NetworkTablesConnection which is used specifically for, the FIRST Robotics Competition in order to connect to the RoboRIO controller You can easily replace it with a different connections """ import ovl # for other ways to connect to your RoboRIO run the following python code: help(NetworkTablesConnection) TEAM_NUMBER = "1937" threshold = ovl.RED_HSV contour_filters = [ ovl.area_filter(min_area_ratio=150), ovl.straight_rectangle_filter(min_area_ratio=0.7), ovl.area_sort() ] director = ovl.Director(directing_function=ovl.x_center_directions, failed_detection=9999, target_amount=1) camera = ovl.Camera(0, image_width=640, image_height=480) roborio = ovl.NetworkTablesConnection(roborio=TEAM_NUMBER, table_name="SmartDashboard", table_key="vision_directions") image_filters = [ovl.gaussian_blur((5, 5))] red_square = ovl.Vision(threshold=threshold,
import asyncio import copy from logging import getLogger import ovl from ovl import display_contours logger = getLogger("multi_vision_example") target_filters = [ovl.percent_area_filter(minimal_percent=2), ovl.area_sort()] camera = ovl.Camera(0) red_circle = ovl.Vision(target_filters=target_filters, threshold=ovl.HSV.red, camera=camera) green_circle = copy.copy(red_circle) green_circle.detector = ovl.ThresholdDetector(threshold=ovl.HSV.green) yellow_circle = copy.copy(red_circle) yellow_circle.detector = ovl.ThresholdDetector(threshold=ovl.HSV.yellow) # connection = NetworkTablesConnection("1937") circles = {"green": green_circle, "red": red_circle, "yellow": yellow_circle} controller = ovl.MultiVision(visions=circles) switcher = {"green": "red", "red": "yellow", "yellow": "green"} current_color = "green"