public class VisionRunner<P extends VisionPipeline> extends Object
VisionThreadand use the listener to take snapshots of the pipeline's outputs.
public VisionRunner(VideoSource videoSource, P pipeline, VisionRunner.Listener<? super P> listener)Creates a new vision runner. It will take images from the
videoSource, send them to the
pipeline, and call the
listenerwhen the pipeline has finished to alert user code when it is safe to access the pipeline's outputs.
videoSource- the video source to use to supply images for the pipeline
pipeline- the vision pipeline to run
listener- a function to call after the pipeline has finished running
public void runOnce()Runs the pipeline one time, giving it the next image from the video source specified in the constructor. This will block until the source either has an image or throws an error. If the source successfully supplied a frame, the pipeline's image input will be set, the pipeline will run, and the listener specified in the constructor will be called to notify it that the pipeline ran.
This method is exposed to allow teams to add additional functionality or have their own ways to run the pipeline. Most teams, however, should just use
runForever()in its own thread using a
public void runForever()A convenience method that calls
runOnce()in an infinite loop. This must be run in a dedicated thread, and cannot be used in the main robot thread because it will freeze the robot program.
Do not call this method directly from the main thread.
public void stop()Stop a RunForever() loop.