Trouble with Microsoft LifeCam and FMS

So, I have posted the code for our USB camera below. This works fine for us when we tether into the Rio with USB or with ethernet, but every time we played a match hooked up to the FMS our camera never showed up. Is there something wrong with the code, or is there another configuration setting we have failed to do? Thanks for any insight.

static void VisionThread() {
// This function executes as a separate thread, to take 640x480 pixel
// video frames from the USB video camera, change to grayscale, and
// send to the DriverStation. It is documented here:
// https://wpilib.screenstepslive.com/s/currentCS/m/vision/l/
// 669166-using-the-cameraserver-on-the-roborio
cs::UsbCamera camera =
frc::CameraServer::GetInstance()->StartAutomaticCapture();
// camera.SetResolution(640, 480);
camera.SetResolution(160, 120);
cs::CvSink cvSink = frc::CameraServer::GetInstance()->GetVideo();
cs::CvSource outputStreamStd =
frc::CameraServer::GetInstance()->PutVideo(“Gray”, 640, 480);
cv::Mat source;
cv::Mat output;
while(true) {
usleep(1000);
if ( cvSink.GrabFrame(source) )
{
cvtColor(source, output, cv::COLOR_BGR2GRAY);
outputStreamStd.PutFrame(output);
}
}
}

That code should definitely work. There’s really not much difference when running with FMS. What dashboard are you using?

I believe we are just using the default drive station, we have never really branched out beyond that.

Our team had the same problem. The issue with ours was that the bandwidth drawn from running a camera at relatively high resolution was too much for the FMS. We fixed this by reducing the camera resolution/ frame rate.
Good luck!

Our team was having some issues with the cameras but got two of them to work simultaneously by adjusting the bandwidth used in Shuffleboard and making sure to press the “restart robot code” button once they connected to the field. Both cams always came up after they did that.

@CAP1Sup thanks to both suggestions, we’ll try and see if the bandwidth is an issue. I hadn’t even thought of restarting the code on the field, I’ll be sure to pass that on to the drive team

No problem!