Hi, I am from team 4776 and I am programming the cameras. We are struggling to get the code for the cameras on our robot. We have tried using the code from WPILib but that did not work. If you have any solution just commit below.
Thanks,
4776-Scots Bots
Which code from WPIlib did you use?
Have you tried putting this or something like it in your robotInit() method in the Robot.java/Robot.cpp?
UsbCamera cam0 = CameraServer.getInstance().startAutomaticCapture(0);
cam0.setVideoMode(PixelFormat.kMJPEG, 320, 240, 15); //PixelFormat, height, width, fps
It should be fine to leave the PixelFormat as the kMJPEG.
If all you want to do is stream a camera to the smartdashboard, assuming you are programming in Java, use
cameraServer.getInstance().startAutomaticCapture();
Make sure you add a CameraServer stream viewer on the smart dashboard.
I was using the code that was in the forum “Using the camera server on the roborio” in the WPIlib website and it was the one for java. Also I have not tried that yet. Do you have any examples of a fully working code for the USB camera(s)?
I finally got it to work from your code. Thank you Flamming Spork.