public class VisionRunner<P extends VisionPipeline> extends java.lang.Object
VisionThread
and use the listener to take snapshots of the pipeline's outputs.VisionPipeline
,
VisionThread
,
edu.wpi.first.wpilibj.vision
Modifier and Type | Class and Description |
---|---|
static interface |
VisionRunner.Listener<P extends VisionPipeline>
Listener interface for a callback that should run after a pipeline has processed its input.
|
Constructor and Description |
---|
VisionRunner(VideoSource videoSource,
P pipeline,
VisionRunner.Listener<? super P> listener)
Creates a new vision runner.
|
Modifier and Type | Method and Description |
---|---|
void |
runForever()
A convenience method that calls
runOnce() in an infinite loop. |
void |
runOnce()
Runs the pipeline one time, giving it the next image from the video source specified
in the constructor.
|
public VisionRunner(VideoSource videoSource, P pipeline, VisionRunner.Listener<? super P> listener)
videoSource
, send them to
the pipeline
, and call the listener
when 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 pipelinepipeline
- the vision pipeline to runlistener
- a function to call after the pipeline has finished runningpublic void runOnce()
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 VisionThread
.
public void runForever()
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.
java.lang.IllegalStateException
- if this is called from the main robot threadVisionThread