Package trclib.vision
Class TrcOpenCvDetector
java.lang.Object
trclib.vision.TrcOpenCvDetector
- All Implemented Interfaces:
TrcVideoSource<org.opencv.core.Mat>,TrcVisionProcessor<org.opencv.core.Mat,TrcOpenCvDetector.DetectedObject<?>>
- Direct Known Subclasses:
TrcOpenCvFaceDetector
public abstract class TrcOpenCvDetector
extends Object
implements TrcVisionProcessor<org.opencv.core.Mat,TrcOpenCvDetector.DetectedObject<?>>
This class implements a generic OpenCV detector. Typically, it is extended by a specific detector that provides
the pipeline to process an image for detecting objects using OpenCV APIs.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classThis class encapsulates info of the detected object.static interfaceThis interface provides a method for filtering false positive objects in the detected target list. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TrcHomographyMapperprotected final Stringprivate TrcOpenCvPipeline<TrcOpenCvDetector.DetectedObject<?>>final TrcDbgTraceprivate final TrcVisionTask<org.opencv.core.Mat,TrcOpenCvDetector.DetectedObject<?>> -
Constructor Summary
ConstructorsConstructorDescriptionTrcOpenCvDetector(String instanceName, int numImageBuffers, TrcHomographyMapper.Rectangle cameraRect, TrcHomographyMapper.Rectangle worldRect) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiongetDetectedTargetsInfo(TrcOpenCvDetector.FilterTarget filter, Comparator<? super TrcVisionTargetInfo<TrcOpenCvDetector.DetectedObject<?>>> comparator, double objGroundOffset, double cameraHeight) This method returns an array of detected targets from Grip vision.This method returns the current pipeline.longThis method returns the vision task processing interval.org.opencv.core.MatThis method returns the selected intermediate output Mat.processFrame(org.opencv.core.Mat input) This method is called to detect objects in the acquired image frame.voidsetPipeline(TrcOpenCvPipeline<TrcOpenCvDetector.DetectedObject<?>> pipeline) This method sets the OpenCV pipeline to be used for the detection and enables it.voidsetProcessingInterval(long interval) This method sets the vision task processing interval.toString()This method returns the instance name.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface trclib.vision.TrcVideoSource
getFrame, putFrame
-
Field Details
-
tracer
-
instanceName
-
homographyMapper
-
visionTask
-
openCvPipeline
-
-
Constructor Details
-
TrcOpenCvDetector
public TrcOpenCvDetector(String instanceName, int numImageBuffers, TrcHomographyMapper.Rectangle cameraRect, TrcHomographyMapper.Rectangle worldRect) Constructor: Create an instance of the object.- Parameters:
instanceName- specifies the instance name.numImageBuffers- specifies the number of image buffers to allocate.cameraRect- specifies the camera rectangle for Homography Mapper, can be null if not provided.worldRect- specifies the world rectangle for Homography Mapper, can be null if not provided.
-
-
Method Details
-
toString
This method returns the instance name. -
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.
-
setPipeline
This method sets the OpenCV pipeline to be used for the detection and enables it.- Parameters:
pipeline- specifies the pipeline to be used for detection, can be null to disable vision.
-
getPipeline
This method returns the current pipeline.- Returns:
- current pipeline, null if no set pipeline.
-
getDetectedTargetsInfo
public TrcVisionTargetInfo<TrcOpenCvDetector.DetectedObject<?>>[] getDetectedTargetsInfo(TrcOpenCvDetector.FilterTarget filter, Comparator<? super TrcVisionTargetInfo<TrcOpenCvDetector.DetectedObject<?>>> comparator, double objGroundOffset, double cameraHeight) This method returns an array of detected targets from Grip vision.- Parameters:
filter- specifies the filter to call to filter out false positive targets.comparator- specifies the comparator to sort the array if provided, can be null if not provided.objGroundOffset- specifies the object ground offset above the floor.cameraHeight- specifies the height of the camera above the floor.- Returns:
- array of detected target info.
-
processFrame
This method is called to detect objects in the acquired image frame.- Specified by:
processFramein interfaceTrcVisionProcessor<org.opencv.core.Mat,TrcOpenCvDetector.DetectedObject<?>> - Parameters:
input- specifies the image to be processed.- Returns:
- detected objects, null if none detected.
-
getSelectedOutput
public org.opencv.core.Mat getSelectedOutput()This method returns the selected intermediate output Mat.- Specified by:
getSelectedOutputin interfaceTrcVisionProcessor<org.opencv.core.Mat,TrcOpenCvDetector.DetectedObject<?>> - Returns:
- selected output mat.
-