Package ftclib.vision
Class FtcRawEocvVision
java.lang.Object
ftclib.vision.FtcRawEocvVision
This class implements an EasyOpenCV detector. Typically, it is extended by a specific detector that provides the
pipeline to process an image for detecting objects using OpenCV APIs. This class does not extend TrcOpenCvDetector
because EOCV has its own thread and doesn't need a Vision Task to drive the pipeline.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private final TrcHomographyMapper
private final String
private final org.openftc.easyopencv.OpenCvCamera
private TrcOpenCvPipeline<TrcOpenCvDetector.DetectedObject<?>>
final TrcDbgTrace
-
Constructor Summary
ConstructorsConstructorDescriptionFtcRawEocvVision
(String instanceName, int imageWidth, int imageHeight, TrcHomographyMapper.Rectangle cameraRect, TrcHomographyMapper.Rectangle worldRect, org.openftc.easyopencv.OpenCvCamera openCvCamera, org.openftc.easyopencv.OpenCvCameraRotation cameraRotation) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptiongetBestDetectedTargetInfo
(TrcOpenCvDetector.FilterTarget filter, Comparator<? super TrcVisionTargetInfo<TrcOpenCvDetector.DetectedObject<?>>> comparator, double objGroundOffset, double cameraHeight) This method returns the target info of the best detected target.getDetectedTargetsInfo
(TrcOpenCvDetector.FilterTarget filter, Comparator<? super TrcVisionTargetInfo<TrcOpenCvDetector.DetectedObject<?>>> comparator, double objGroundOffset, double cameraHeight) This method returns an array list of detected targets from EasyOpenCV vision.org.openftc.easyopencv.OpenCvCamera
This method returns the OpenCvCamera object.This method returns the current active pipeline.boolean
This method checks if the camera is started successfully.void
setFpsMeterEnabled
(boolean enabled) This method enables/disables FPS meter on the viewport.void
setPipeline
(TrcOpenCvPipeline<TrcOpenCvDetector.DetectedObject<?>> pipeline) This method sets the EOCV pipeline to be used for the detection and enables it.
-
Field Details
-
tracer
-
instanceName
-
openCvCamera
private final org.openftc.easyopencv.OpenCvCamera openCvCamera -
homographyMapper
-
cameraStarted
private boolean cameraStarted -
openCvPipeline
-
-
Constructor Details
-
FtcRawEocvVision
public FtcRawEocvVision(String instanceName, int imageWidth, int imageHeight, TrcHomographyMapper.Rectangle cameraRect, TrcHomographyMapper.Rectangle worldRect, org.openftc.easyopencv.OpenCvCamera openCvCamera, org.openftc.easyopencv.OpenCvCameraRotation cameraRotation) Constructor: Create an instance of the object.- Parameters:
instanceName
- specifies the instance name.imageWidth
- specifies the width of the camera image.imageHeight
- specifies the height of the camera image.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.openCvCamera
- specifies the camera object.cameraRotation
- specifies the camera orientation.
-
-
Method Details
-
getOpenCvCamera
public org.openftc.easyopencv.OpenCvCamera getOpenCvCamera()This method returns the OpenCvCamera object.- Returns:
- OpenCvCamera object.
-
setFpsMeterEnabled
public void setFpsMeterEnabled(boolean enabled) This method enables/disables FPS meter on the viewport.- Parameters:
enabled
- specifies true to enable FPS meter, false to disable.
-
isCameraStarted
public boolean isCameraStarted()This method checks if the camera is started successfully. It is important to make sure the camera is started successfully before calling any camera APIs.- Returns:
- true if camera is started successfully, false otherwise.
-
setPipeline
This method sets the EOCV 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 active pipeline.- Returns:
- current active pipeline, null if no active pipeline.
-
getDetectedTargetsInfo
public ArrayList<TrcVisionTargetInfo<TrcOpenCvDetector.DetectedObject<?>>> getDetectedTargetsInfo(TrcOpenCvDetector.FilterTarget filter, Comparator<? super TrcVisionTargetInfo<TrcOpenCvDetector.DetectedObject<?>>> comparator, double objGroundOffset, double cameraHeight) This method returns an array list of detected targets from EasyOpenCV 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 list of detected target info.
-
getBestDetectedTargetInfo
public TrcVisionTargetInfo<TrcOpenCvDetector.DetectedObject<?>> getBestDetectedTargetInfo(TrcOpenCvDetector.FilterTarget filter, Comparator<? super TrcVisionTargetInfo<TrcOpenCvDetector.DetectedObject<?>>> comparator, double objGroundOffset, double cameraHeight) This method returns the target info of the best detected target.- 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:
- information about the best detected target.
-