Package org.hyperonline.hyperlib.vision
Class ClosestTargetProcessor
- java.lang.Object
-
- org.hyperonline.hyperlib.vision.AbstractTargetProcessor<VisionResult>
-
- org.hyperonline.hyperlib.vision.ClosestTargetProcessor
-
- All Implemented Interfaces:
TargetProcessor
public class ClosestTargetProcessor extends AbstractTargetProcessor<VisionResult>
Target processor class which picks out the closest target to the crosshairs.
-
-
Constructor Summary
Constructors Constructor Description ClosestTargetProcessor(BasicVisionConnector connector, int xCrosshairs, int yCrosshairs)
Construct a new target processor with the given fixed crosshairs position.ClosestTargetProcessor(BasicVisionConnector connector, java.util.function.IntSupplier xCrosshairs, java.util.function.IntSupplier yCrosshairs)
Construct a new target processor which reads crosshairs position from the given functions.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VisionResult
computeResult(java.util.List<org.opencv.core.Rect> targets)
void
writeOutput(org.opencv.core.Mat mat)
Draw overlays on the image.-
Methods inherited from class org.hyperonline.hyperlib.vision.AbstractTargetProcessor
getLastResult, process
-
-
-
-
Constructor Detail
-
ClosestTargetProcessor
public ClosestTargetProcessor(BasicVisionConnector connector, int xCrosshairs, int yCrosshairs)
Construct a new target processor with the given fixed crosshairs position.- Parameters:
connector
- VisionConnector for retreiving/publishing the resultxCrosshairs
- X coordinate for the crosshairsyCrosshairs
- Y coordinate for the crosshairs
-
ClosestTargetProcessor
public ClosestTargetProcessor(BasicVisionConnector connector, java.util.function.IntSupplier xCrosshairs, java.util.function.IntSupplier yCrosshairs)
Construct a new target processor which reads crosshairs position from the given functions. The most common use case would be to passIntPreference.get()
. Whatever you pass must be safe to call from the vision thread, so it should not reference the internals of commands, subsystems, or other robot code. Note that preferences are safe to access from any thread.- Parameters:
connector
- VisionConnector for retreiving/publishing the resultxCrosshairs
- X coordinate for the crosshairsyCrosshairs
- Y coordinate for the crosshairs
-
-
Method Detail
-
computeResult
public VisionResult computeResult(java.util.List<org.opencv.core.Rect> targets)
- Specified by:
computeResult
in classAbstractTargetProcessor<VisionResult>
- Parameters:
targets
- list of targets to compute- Returns:
- {T}
-
writeOutput
public void writeOutput(org.opencv.core.Mat mat)
Draw overlays on the image. This should give the user some indication of what the result ofTargetProcessor.process(List)
was.- Parameters:
mat
- The image to draw on.
-
-