Often it's desirable to have more than one camera on a robot, for example to provide front and back views. As always, camera code should run in its own thread to prevent a camera exception (e.g. if a camera fails or gets unplugged) from taking down the main robot thread. The example below shows how to create a new thread class called Cameras that creates two cameras and lets you switch between them using an Xbox controller. WPILib provides a great helper class called [https://first.wpi.edu/FRC/roborio/release/docs/java/edu/wpi/first/cameraserver/CameraServer.html CameraServer] that does most of the heavy lifting. You can read about it [https://docs.wpilib.org/en/latest/docs/software/vision-processing/introduction/cameraserver-class.html here] and [https://s3.amazonaws.com/screensteps_live/exported/Wpilib/2078/6264/Read_and_process_video_CameraServer_class.pdf?1483739157 here] For more info about using multiple cameras, see [https://docs.wpilib.org/en/latest/docs/software/vision-processing/introduction/using-multiple-cameras.html here] == Robot.java == {{{ package frc.robot; import edu.wpi.first.wpilibj.TimedRobot; public class Robot extends TimedRobot { Cameras cameras; @Override public void robotInit() { cameras = new Cameras(); // create the Cameras thread cameras.start(); // start thread and launch its run() method } } }}} == Cameras.java == Create a new file named Cameras.java under src/main/java/frc/robot (same folder as Robot.java): {{{ package frc.robot; import edu.wpi.first.cameraserver.CameraServer; import edu.wpi.cscore.UsbCamera; import edu.wpi.first.wpilibj.XboxController; class Cameras extends Thread { CameraServer camServer; UsbCamera frontCam, rearCam; XboxController xbox; public Cameras() { // Camera server manages all cameras and streams camServer = CameraServer.getInstance(); // Create and start front and rear cameras frontCam = camServer.startAutomaticCapture("front", 0); rearCam = camServer.startAutomaticCapture("rear", 1); // Use Xbox controller to select camera stream xbox = new XboxController(0); } public void run() { while (true) { if (xbox.getAButton()) { // A button selects front camera camServer.getServer().setSource(frontCam); } if (xbox.getBButton()) { // B button selects rear camera camServer.getServer().setSource(rearCam); } } } } }}}