The listener in the example is a
lambda expression, or an "anonymous function". Basically, a method that's defined where it's used. It's similar to an anonymous class, but is more succinct.
Code:
visionThread = new VisionThread(camera, new GripPipeline(), pipeline -> {
if (!gripPipeline.filterContoursOutput().isEmpty()) {
Rect r = Imgproc.boundingRect(gripPipeline.filterContoursOutput().get(0));
synchronized (imgLock){
centerX = r.x + (r.width / 2);
}
}
});
can also be written as
Code:
visionThread = new VisionThread(camera, new GripPipeline(), new VisionRunner.Listener<GripPipeline>() {
@Override
public void copyPipelineOutputs(GripPipeline pipeline) {
// same as the contents of the lambda above
}
});