CameraServer and Lifecam HD 3000 not starting up

I am trying to stream the output of the Lifecam from the RoboRIO to Shuffleboard using CameraServer. This is the code I have written, however I am experiencing odd behavior.

cs::UsbCamera camera = CameraServer::GetInstance()->StartAutomaticCapture(0);
camera.SetResolution(320, 240);

When I start the robot program, I see this output. It seems it’s a random number each time it reboots. I ssh’ed into the RoboRio and only /dev/video0 exists.

CS: USB Camera 9: Connecting to USB camera on /dev/video9

The camera light turns on and off and then just stays off when the robot program starts.

Any ideas?

That is very odd. The StartAutomaticCapture(0) explicitly sets it to look at device 0. Was that code directly copy and pasted, no chance of a typo? You could try removing the parameter (just say StartAutomaticCapture()).

I have a couple of updates. I tried using the explicit path name “/dev/video0” and I can see the camera information and name. However, the camera light still doesn’t turn on.

By default, the camera isn’t connected (and thus the light won’t turn on) unless you actually have something streaming. You can change this behavior by using setConnectionStrategy() on the returned camera object (kKeepOpen will force the camera to always be connected).

We are having the same problem running similar code in Java, but we are not seeing the camera stream in the dashboard and the light is staying on. We are getting this error: “CS: ERROR: serve_USB Camera 0: Too many simultaneous client streams (MjpegServerImpl.cpp:628).” Any ideas on what may be wrong? We have tried connecting to the RoboRIO over WiFi and USB.

There’s a limit of 10 simultaneous streams, but you really shouldn’t be running into that limit in normal use. What all do you have running that might be connecting to the stream (web browser, dashboards)?

Hi Peter, thanks for the quick reply! The only apps open are VS Code, Drive Station, and the Dashboard. If we close dashboard, the messages stop - they start back up when we launch dashboard again.

The laptop is the most vanilla setup we could create: Clean installation of Windows 10 with just the necessary FRC installations and the CTRE Phoenix software. The roboRIO is also freshly imaged with this year’s tools.

It sounds like something is interacting poorly with the dashboard, and I can’t reproduce that behavior locally. Instead of using the dashboard, try opening a webbrowser to frcvision.local:1181.

OK, we’ll give that a try first thing at our next meeting

All attempts to browse the webcam have all failed with “this site can’t be reached” errors. We’ve used Chrome and MS Edge, and we’ve tried with nothing else running on the laptop as well as with combinations of the Drive Station and Dashboard running. We’ve also tried both over USB and Wifi with the same results. It just can’t resolve frcvision.local:1181. Anything else we can try?

Is this a robot program or something running on the Raspberry Pi? Re-reading the first post, it sounds like it’s a robot program. In that case try to connect to http://roborio-TEAM-frc.local:1181/ (where TEAM is your team number). Sorry for the confusion if you’re talking about robot code running on the RoboRIO this whole time, I’ve been answering a lot of FRCVision questions recently.

Ok, much better! We get the camera server webpage, which shows our camera being detected, and lists a ton of supported modes. Our camera seems to be published as /dev/video0. Nothing seems obviously wrong, but I’m not well versed in all the various settings.

Are you getting a stream view on that page?

We are not - now that you mention it, there is a tiny broken image icon in the top right of the page, which I suppose is where the stream viewer should go

What’s the code you’re using to start the camera? If you’re setting the resolution, are you using one of the modes listed on that webpage?

UPDATE: We refreshed, and we are now getting a stream preview!
(On the http://roborio-TEAM-frc.local:1181/ page)

Still no joy on the Dashboard

1 Like

Which dashboard are you using? The default LabView one? Can you try using Shuffleboard?

We’ve been trying them all to get something to work, but mostly testing with Default. Here is the camera startup code:

UsbCamera camera = CameraServer.getInstance().startAutomaticCapture();

To help me debug this, please add the following to your code. You’ll get a ton more output on the console.

CameraServerJNI.setLogger((level, file, line, msg) -> {
    System.out.println("CS: " + msg);
  }, 9);

I’m mainly interested in anything that reads “CS: request for stream” and “CS: leaving HTTP client thread”.

We added that line to our code. The server repeats blocks like this several times a second:

CS: serve_USB Camera 0: command parameters: “name=USB%20Camera%200&fps=15&compression=43&resolution=640x480”
CS: serve_USB Camera 0: request for stream USB Camera 0
CS: serve_USB Camera 0: Too many simultaneous client streams
CS: serve_USB Camera 0: leaving HTTP client thread
CS: serve_USB Camera 0: client connection from
CS: serve_USB Camera 0: HTTP request: 'GET /?action=stream&name=USB%20Camera%200&fps=15&compression=43&resolution=640x480 HTTP/1.1