I’ve been following these screen steps for using GRIP for vision tracking and have come across a problem which I’m not too sure how to fix. When I go to type,
visionThread = new VisionThread(camera, new MyGripPipeline(), pipeline -> {
if (!pipeline.filterContoursOutput().isEmpty()) {
Rect r = Imgproc.boundingRect(pipeline.filterContoursOutput().get(0));
synchronized (imgLock) {
centerX = r.x + (r.width / 2);
}
}
});
visionThread.start();
drive = new RobotDrive(1, 2);
This portion,
new VisionThread(camera, new MyGripPipeline(), pipeline → {
if (!pipeline.filterContoursOutput().isEmpty()) {
Rect r = Imgproc.boundingRect(pipeline.filterContoursOutput().get(0));
synchronized (imgLock) {
centerX = r.x + (r.width / 2);
}
}
});
becomes underlined and tells me that the constructor VisionThread is undefined.
I’m not sure what I’m doing wrong.
Could it possibly be you have an older version of Java installed? Lambda expressions came in Java 8 so anything before that won’t support them.
If that’s not the issue, double check the parameters from the VisionThread constructor and make sure you’re at least passing the correct types (Don’t believe this should throw an undefined error but always good to check).
Lastly, you may need to import vision libraries. I haven’t used GRIP but I believe it should add the required imports to the top of the code export. If not, read up as to what libraries GRIP makes use of and import the appropriate ones.
The code is copied almost directly from wpilib, so I should be using the correct parameters for the constructor as far as I can tell, and I believe I have all the required vision libraries. Here is my code: