I set up my Microsoft Lifecam using the CameraServer class, but it’s only a singleton class. Is it possible to get more than one usb camera running and streaming at once?
Here’s a start for you:
I saw that, it’s not really helpful. The problem is that the CameraServer class only allows one instance of the UsbCamera, and I would like two.
It absolutely allows multiple instances of UsbCamera’s. If you call StartAutomaticCapture a second time, you’ll get a second UsbCamera connected and able to be used.
Can confirm, we used multiple USB cameras last year and the year before. In addition, you may be interested in Switch between two cameras using joystick button (java) for reducing bandwidth usage.
I’m not following what you mean. The lines:
camera1 = frc::CameraServer::GetInstance()->StartAutomaticCapture(0); camera2 = frc::CameraServer::GetInstance()->StartAutomaticCapture(1);
Is doing exactly that. “USB Camera 0” and “USB Camera 1” would both be cameras that were instantiated and setup to run.
If you take a look at the CameraServer source you can even provide custom names in one of the overloaded methods to startAutomaticCapture() to make it more semantically clear which camera you are talking about.
I had those lines of code originally. I realized my problem wasn’t a code problem and was a problem with selecting the right camera to use on the SmartDashboard. At the time I didn’t know that it was a SmartDashboard problem, which is why your linked webpage didn’t help too much. And of course, I wrongly assumed it was because the class just “couldn’t” handle more than one camera.
Does this work if the cameraserver is on a Pi (using WPI visionimage) and not the roborio?
Yes, it’s the same approach. If you use the built in default program or base your program from the included template, starting multiple cameras is built in. See the vision settings tab of the FRCVision webdash.