Need help with Vision on Java

I’m not sure what goes into the contructor for VisionThread(). In the official frc project here they used the same code for the third parameter of VisionThread(), but I’m getting errors. Help!

1 Like

Do you have a GripPipeline class defined? The third parameter here is actually a function that accepts pipeline as a parameter. The code inside that function is calling back into the GripPipeline class (e.g. pipeline.filterContoursOutput()) so the GripPipeline class would need to have those functions defined.

yes, I just put a random letter in front of “pipeline” and it seemed to recognize it, do you know what I am supposed to put in front of the 3rd parameter? It wants me to claim the pipeline’s “type”

The Java syntax there is correct. If you don’t have a GripPipeline class, the new GripPipeline() part of the code won’t work, so it can’t figure out the type of the third parameter (which depends on the type of the second parameter).

oh I looked through my GripPipeline class that grip made for me and there is no filtercontours subclass so maybe I just need to make my own code and not use the frc’s example.

Nope, still doesn’t work. It says “the constructor VisionThread(Camera, GripPipeline, ( pipeline) → {}) is undefinedJava(134217858)”

Oh. Just looking higher in your code… what is Camera in your code? If you look at the WPILib example, it does UsbCamera camera = CameraServer.startAutomaticCapture();

When I do
“import edu.wpi.cscore.UsbCamera;” java cant find it

It was renamed in 2022. It’s now edu.wpi.first.cscore.UsbCamera.

however i have a Camera.java file that sets the resolution and starts automatic capture with its constructor

The VisionThread constructor first parameter must be based on edu.wpi.first.cscore.VideoSource.

I just changed the camera instantiation to that, but still have the same error. I cant send you my grippipeline program because im a new user. Ill try to do it through google drive.

https://drive.google.com/drive/folders/1B3hejSC51i_drFjKrjkW85kCH4hY7M1I?usp=sharing

you shouldn’t have the “P”, it should just be:
visionThread = new VisionThread(camera, new GripPipeline(), pipeline -> {});

Even when I do that, I get the same error with the constructor.

Oh, your GripPipeline needs to implement the VisionPipeline interface (e.g. public class GripPipeline implements VisionPipeline).

WOw thats like white on rice we almost threw in the towel, now slap me silly annd call me sally, it worked! Really appreciate it man!

I figured this out, but I’m still having issues with that section of the code above. My code looks identical to yours, however I’m getting an error with the ‘filterContoursOutput()’ part. I’m getting an error called ‘The method filterContoursOutput() is undefined for the type GripPipelineJava(67108964)’. Any Ideas on how to fix this issue would be much appreciated.

That error would be due to your GripPipeline not having that processing stage or function. You should customize that part to match what image processing steps you’re actually doing.

Ah, ok. How do you think would be the best way do go about doing that?