My mechanical team was thinking of using the two USB ports in the roboRIO to connect to two cameras and I was wondering if that’s possible and how?
Yes, it’s possible using the CameraServer class (assuming you’re using Java or C++). If you want two separate feeds, code like the following in RobotInit() will start both cameras (this is C++, but Java is very similar).
There’s even an article in screensteps specifically about using multiple cameras and switching between them programmatically. This article is a bit dated in some of the details (I’ll work on getting it updated) but still works.
I’m using Java but what if I want both cameras streaming at the same time? Like I don’t want to switch from camera one to camera two and the same with the opposite.
Is there enough bandwidth to do that? The limit is lower this year.
Just add those two lines to robotInit(). For Java they should read
We were planning on using 2, but bandwidth restrictions are potentially an issue.
Damn, I forgot about bandwidth… yeah, I’ll have to talk to my captain.
With appropriately low resolution, quality settings, and FPS, two streams at the same time can fit in the bandwidth. So there’s a tradeoff you need to make.
See the following thread for my tips for 2 cameras
Multiple USB cameras into a single computer can be problematic even if they don’t overrun the theoretical bandwidth of the USB interface (which they can also do). You may find the first device gets resources generously allocated, preventing the second from getting what it needs. Test carefully, it may work, or it may not.
I know in previous years the Bandwidth allowed was higher, and I know from my own experience that two typical cameras running at the same time could take up too much bandwidth.
Hope this helps
I remember we our programmers had difficulty with this a few years ago with the 7M limit, especially if both cameras were on the same USB interface. When they did get it working, the drivers found that lower resolution and decent frame rate (30 fps?) was much more amenable to driving than a slower frame rate and better resolution with the same total bandwidth.
Our prototype has two HD lifecams connected via an wpilibsuite/FRCVision_pi_gen OS image (RPi) streaming to the driver station. We’ve tuned them down to 160x120 @ 20 FPS each, and are able to stay at ~2.5 Mbps network bandwidth usage. It’s a little grainy, but responsive. So it’s possible.
Team 1778 Chill Out!
I dont know if this would work but what about a button the the joystick that changed the camera, This was only one feed would be streaming at a time.
We’re opting for that setup instead.
Absolutley. Last year we attatched 4 or 5 USB cameras to the bot using a USB hub. Just copy and paste the one line and you’re good to go.
You should really look at the FRC-vision-rpi-gen image for RPi. You can add multiple cameras with little or no fuss, and they are available in Shuffleboard. You can also tune them in real time to ensure you are under the bandwidth limit of 4 Mbps. Here is our implementation of two HD lifecams in test.
We did the same thing. Using the Microsoft Lifecam + a 170 FishEye and a Raspberry Pi. There is nothing to program, the cameras show up in the Drivers Station Dashboard and you just select the one you want in each window.
What type of fisheye camera are you using? We want to get one for our team, but want to make sure they will work.