Hello! I’m trying to use the new switchedcamera feature with the built in camera streaming in the pi vision software but I’m not sure how to actually use it in the roborio java code. Is there any example code? Has any team got it to work?
I have tried that but it doesn’t show anything (gray screen with no message) in the DriverStation.
Here is the main code in Robot.java:
cameraSelect1 = NetworkTableInstance.getDefault().getEntry("/PairZero");
cameraSelect2 = NetworkTableInstance.getDefault().getEntry("/PairOne");
cameraSelect1.setValue("/dev/video0");
cameraSelect2.setValue("/dev/video1");
Here is when I try to switch the cameras in a command:
Robot.cameraSelect1.setValue("/dev/video2");
Robot.cameraSelect2.setValue("/dev/video3");
And still nothing happens. I’m pretty sure I’m using it wrong…
If you’re using strings, don’t use the path, use the name of the camera in the webdash (eg “Pi Camera 1” etc). Or use indexes (0, 1, etc). I also recommend using setDouble() or setString() instead of setValue().
A working python example can be found at https://github.com/robotpy/robotpy-cscore/blob/master/examples/switched_cameraserver.py … just translate it to Java (or use python).
Thanks, this worked!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.