Package trclib.vision
Class TrcVisionTask<I,O>
java.lang.Object
trclib.vision.TrcVisionTask<I,O>
- Type Parameters:
I
- specifies the type of the input image.O
- specifies the type of the detected objects.
This class implements a platform independent vision task. When enabled, it grabs a frame from the video source,
calls the provided vision processor to process the frame and overlays rectangles on the detected objects in the
image. This class is to be extended by a platform dependent vision processor.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final AtomicReference<O[]>
private final I[]
private int
private final String
private boolean
private double
private long
private double
final TrcDbgTrace
private final TrcVisionProcessor<I,
O> private final TrcTaskMgr.TaskObject
-
Constructor Summary
ConstructorsConstructorDescriptionTrcVisionTask
(String instanceName, TrcVisionProcessor<I, O> visionProcessor, I[] imageBuffers) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionO[]
This method returns the last detected objects.long
This method returns the vision task processing interval.boolean
This method returns the state of the vision task.void
setProcessingInterval
(long interval) This method sets the vision task processing interval.void
setTaskEnabled
(boolean enabled) This method enables/disables the vision task.toString()
This method returns the instance name.private void
visionTask
(TrcTaskMgr.TaskType taskType, TrcRobot.RunMode runMode, boolean slowPeriodicLoop) This method runs periodically to do vision processing.
-
Field Details
-
tracer
-
instanceName
-
visionProcessor
-
imageBuffers
-
visionTaskObj
-
detectedObjects
-
taskEnabled
private volatile boolean taskEnabled -
imageIndex
private int imageIndex -
totalTime
private double totalTime -
totalFrames
private long totalFrames -
taskStartTime
private double taskStartTime
-
-
Constructor Details
-
TrcVisionTask
public TrcVisionTask(String instanceName, TrcVisionProcessor<I, O> visionProcessor, I[] imageBuffers) Constructor: Create an instance of the object.- Parameters:
instanceName
- specifies the instance name.visionProcessor
- specifies the vision processor object.imageBuffers
- specifies an array of image buffers.
-
-
Method Details
-
toString
This method returns the instance name. -
setTaskEnabled
public void setTaskEnabled(boolean enabled) This method enables/disables the vision task. As long as the task is enabled, it will continue to acquire/process images.- Parameters:
enabled
- specifies true to enable vision task, false to disable.
-
isTaskEnabled
public boolean isTaskEnabled()This method returns the state of the vision task.- Returns:
- true if the vision task is enabled, false otherwise.
-
setProcessingInterval
public void setProcessingInterval(long interval) This method sets the vision task processing interval.- Parameters:
interval
- specifies the processing interval in msec. If 0, process as fast as the CPU can run.
-
getProcessingInterval
public long getProcessingInterval()This method returns the vision task processing interval.- Returns:
- vision task processing interval in msec.
-
getDetectedObjects
This method returns the last detected objects. Note that this call consumes the objects, meaning if this method is called again before the next frame is finished processing, it will return a null.- Returns:
- the last detected objects.
-
visionTask
private void visionTask(TrcTaskMgr.TaskType taskType, TrcRobot.RunMode runMode, boolean slowPeriodicLoop) This method runs periodically to do vision processing.- Parameters:
taskType
- specifies the type of task being run.runMode
- specifies the current robot run mode.slowPeriodicLoop
- specifies true if it is running the slow periodic loop on the main robot thread, false otherwise.
-