Notice: This website has undergone a refactor to allow for more pages in the future.
Specifically, the limit-switch, gyro, and potentiometer pages were moved under the Sensors header and then dashboard or roboRIO based on where the edited code would run.
The old locations were set with permanent redirects, but please update bookmarks/favorites.

FRC LabVIEW Tutorials - Switching Cameras

Table of Contents

Note

This tutorial was written in the 2015-16 FRC season Stronghold.
The shipping vision code has changed so much since then that this method is obsolete.

Background

A common desire among FRC teams has been to have multiple cameras on a robot that can easily be switched between, however coding a solution has not been trivial. As a result, my teammate James and I (Dillon), from FRC team 3061, Huskie Robotics, came up with this relatively simple solution.

OverView

The basic concept is that we are modifying two WPI camera VIs that handle sending a camera image to the PC. The modification involves changing the VIs to accept multiple camera Device Refs and then iterating the necessary code over the camera Device Reference whose image is needed at that time.

Initialize

Begin by making a personal and renamed copy of two WPI libraries, which can be found by searching in the LabVIEW project window.

Make a copy of WPI_CameraBackground Loop.vi and call it WPI_DualCameraBackground Loop.vi. Also, make a copy of WPI_CameraSend Images To PC Loop.vi and call it WPI_DualCameraSend Images To PC Loop.vi

Save these somewhere convenient and accessible.

Vision Processing.vi

Here is the original Vision Processing.vi for reference:

original Vision Processing.vi

And now the modified version:

modified Vision Processing.vi

As you can see, several changes were made:

WPI_DualCameraBackground Loop.vi

Very little needs to be modified in this VI, as the cameras are always USB and therefore no modification of the case structure is required. Simply add a second Device Reference for your new camera and pass both these Device References to WPI_DualCamerSend Images To PC Loop.vi. Note that creating the second camera Device Reference input for this VI is part of the next step.

Relevant part of original VI:

original WPI_CameraBackgroundLoop.vi

Modified Portion:

new WPI_DualCameraBackgroundLoop.vi

WPI_DualCameraSend Images To PC Loop.vi

This VI is the most change-heavy, although it is still not very complex. Simply follow the instructions and utilize the snippets to prevent bugs:

First for reference, the original VI:

original WPI_CameraSend Images To PC Loop.vi

And the modified version we will achieve:

original WPI_CameraSend Images To PC Loop.vi

The list of changes should be easy to follow, but if you are unsure, you can always refer to the snippets above for visual comparisons.

Some important notes:

And that is all, you can now easily switch between two camera inputs. In addition, this method should be extendable to even more cameras, and with more effort possibly IP Cameras as well.

Download WPI_DualCameraBackground Loop.vi
Download WPI_DualCameraSend Images To PC Loop.vi

-- Dillon and James, Huskie Robotics, Team 3061

If this tutorial inadvertently leaves some details out, please tell us about it and we will update it.

Google Form to request details