Classes in the package are designed to simplify using OpenCV vision processing code from a robot program.

An example use case for grabbing a yellow tote from 2015 in autonomous:

 public class Robot extends TimedRobot
     implements VisionRunner.Listener<MyFindTotePipeline> {

      // A USB camera connected to the roboRIO.
      private VideoSource usbCamera;

      // A vision pipeline. This could be handwritten or generated by GRIP.
      // This has to implement VisionPipeline.
      // For this example, assume that it's perfect and will always see the tote.
      private MyFindTotePipeline findTotePipeline;
      private VisionThread findToteThread;

      // The object to synchronize on to make sure the vision thread doesn't
      // write to variables the main thread is using.
      private final Object visionLock = new Object();

      // The pipeline outputs we want
      private boolean pipelineRan = false; // lets us know when the pipeline has actually run
      private double angleToTote = 0;
      private double distanceToTote = 0;

      public void copyPipelineOutputs(MyFindTotePipeline pipeline) {
          synchronized (visionLock) {
              // Take a snapshot of the pipeline's output because
              // it may have changed the next time this method is called!
              this.pipelineRan = true;
              this.angleToTote = pipeline.getAngleToTote();
              this.distanceToTote = pipeline.getDistanceToTote();

      public void robotInit() {
          usbCamera = CameraServer.startAutomaticCapture(0);
          findTotePipeline = new MyFindTotePipeline();
          findToteThread = new VisionThread(usbCamera, findTotePipeline, this);

      public void autonomousInit() {

      public void autonomousPeriodic() {
          double angle;
          double distance;
          synchronized (visionLock) {
              if (!pipelineRan) {
                  // Wait until the pipeline has run
              // Copy the outputs to make sure they're all from the same run
              angle = this.angleToTote;
              distance = this.distanceToTote;
          if (!aimedAtTote()) {
          } else if (!droveToTote()) {
          } else if (!grabbedTote()) {
          } else {
              // Tote was grabbed and we're done!

  • Interface Summary 
    Interface Description
    A vision pipeline is responsible for running a group of OpenCV algorithms to extract data from an image.
    VisionRunner.Listener<P extends VisionPipeline>
    Listener interface for a callback that should run after a pipeline has processed its input.
  • Class Summary 
    Class Description
    VisionRunner<P extends VisionPipeline>
    A vision runner is a convenient wrapper object to make it easy to run vision pipelines from robot code.
    A vision thread is a special thread that runs a vision pipeline.