Camera Feed Display

Cameras are crucial to competitions since many parts of the field are not directly visible to the driver. You can read about how to use the CameraServer class on ScreenStepsLive.

  1. Open FRC VSCode
  2. Create a new FRC project.
  3. Type the following into
import edu.wpi.first.cameraserver.CameraServer;
  1. Inside robotInit(), configure the camera with:

You can see the complete code here

  1. You can view the camera video in the smart dashboard or on the shuffleboard.
    1. To view the camera feed on the smart dashboard, use the pull-down chooser in the lower left corner to select USB Camera 0.
    2. To display the camera feed using shuffleboard, read about it here

Smartdashboard and shuffleboard can be used interchangeably, however,shuffleboard is far more user friendly and visually appealing.

  1. To display the camera open up Shuffleboard and read this

Multiple Cameras It's often desirable for a robot to have more than one camera; the camera server supports this and you can select cameras using a game controller button or even automatically when the robot changes direction. You can read about multiple camera selection here. For competition robots, it's important to place the camera processing code in its own thread (advanced topic) because if the camera is disconnected, the thread it is running in will take an exception and it's critical that the main robot thread continue operating.

Vision processing (OpenCV) It's possible to process the video stream in software to identify game pieces and targets. This requires use of vision processing libraries such as OpenCV; you can read about it on screenstepslive here. Team 2537 generally doesn't process video on the !RoboRIO because it lack sufficient memory and CPU power; instead we use a Raspberry Pi which has several times more memory and processing power.

Drawing Overlays Another way to make driving by camera easier is to create overlays on the video feed such as cross-hairs to show where a shooter is aimed. Doing this requires using the NIVision libraries and software provided with FRC Update Suite. Note: ask a mentor for the team's serial number. You may also need the acquisition software and import the*

Last modified 18 months ago Last modified on Nov 15, 2019, 11:15:03 PM