C++ USB Camera Errors

Hello!
My team is attempting to use the Microsoft LifeCam HD-3000 USB camera on our robot; however, we are encountering error messages in the driver station. We have tried to use the Simple Vision example code (unaltered), but it isn’t working.
We have verified that we can see the camera on the web based configuration page and that we are using the correct name in the code (we are). The code builds fine, but as soon as we upload to the robot, we are receiving the error message:

“Error on line 188 of CameraServer.cpp: Incompatible State: The operation cannot be completed: Choose “USB Camera HW” on the dashboard at CameraServer::Serve()”

We program in C++ and use the C++ SmartDashboard. We did add a USB Webcam Viewer object to SmartDashboard, but it only shows the standard gray background with an "ERROR" pink strip at the bottom in its area.

Any fixes/ ideas?

We got this to work by exiting the driver station and dashboard, reseting the roborio
and restarting the driver station. After selecting usb camera hw, it started working.

The exact line in the c++ code is complaining about the camera client making a request not in hardware compression mode (req.compression != kHardwareCompression).

We are having this same problem. We are coding in C++ and using the SmartDashboard.

We added the following to our code:

void TalonXVI::RobotInit()
{
    printf("CameraServer being started
");
    CameraServer::GetInstance()->SetQuality(50);
    //the camera name (ex "cam0") was verified through the roborio web interface
    CameraServer::GetInstance()->StartAutomaticCapture("cam0");
}

We are getting the following error message (repeatedly):

Error on line 188 of CameraServer.cpp: Incompatible State: The operation cannot be completed: Choose “USB Camera HW” on the dashboard
at CameraServer::Serve()
at /home/lvuser/FRCUserProgram() [0x29284]
at /home/lvuser/FRCUserProgram() [0x29110]
at /home/lvuser/FRCUserProgram() [0x28ea8]
at /home/lvuser/FRCUserProgram() [0x28d1c]
at /lib/libstdc++.so.6.0.20(+0xa2954) [0x411a3954]

And no image displayed. We tried restarting the driverstation, dashboard, and roboRIO but still get the error message. However the Error line on the dashboard USB WebCam control now says: “ERROR: roboRIO-230.local”.

Any suggestions would be much appreciated. Thanks.

We are using C++ and the USB camera as well. There are a couple of things we have done to get video in the C++ dashboard.

  1. Make sure you have the patched widget located here: http://www.chiefdelphi.com/forums/showthread.php?t=134404

  2. When you start the driver station, start the default dashboard and then make sure you have USB Camera HW selected. You should see video in that dashboard. After you have video working there, switch to the C++ dashboard and add the patched widget to the dashboard.

I believe that will work - that’s from memory. Let us know if that works.

Really appreciate that info. We followed your procedure and it WORKED! Thanks. :smiley:

So we had it working and now it does not work again after running without it on the robot for other testing (it was not securely mounted so we didn’t want to damage it). Any advice? Do we have to go through the whole process (with the Labview dashboard and then changing over to the C++ SmartDashboard) each new time we bring up the robot with the camera? Do we need to reboot the driverstation after the camera is added?

Thanks

Did you plug it back into the same port it was in before? Check the roboRIO web page to see whether its name is now cam1 instead of cam0.

It’s just flakey. Many of the underlying classes don’t return errors (mostly declared void). If anything goes wrong, it just keeps spewing errors to the message window on the dashboard.

This is much harder than it should be.