A basic example of how to use the new USB webcams can be found in the “Simple Vision” and “Intermediate Vision” example robot Java projects provided with the WPILib API.

If you’re thinking about using multiple cameras on your robot, there are a few things to take into consideration:

  • Bandwidth limitations imposed by the FCS
  • The fact that you can only access the stream from one USB webcam

The second problem can be circumvented by using a networked camera for the second camera. For our 2015 robot, we used that solution, and we did not run into any problems with overusing our bandwidth.

Bandwidth limiting WILL be problematic if it occurs, because it could cause lag on the robot—and not just lag in the video, but lag in the controls!

There is a solution to both problems, however: a better camera server that switches between the camera streams. The code for this better camera server can be found here, with example usage in the same GitHub project. In the example, it switches the streams based on a timed delay, but that could be easily adapted to use user input, for example from a joystick button.