![]() |
2 Cameras in Java
Hello World,
As my team has been working this off season we were wondering if we would be able to use two USB cameras on our robot. We know that it is legal but we were wondering on the coding side what it would take. We are not able to test the code on the actual robot so, we only have theory to go on. Anyway, in theory this is all that should be needed to run two usb cameras at the same time on the Java SmartDashboard. Code:
public class Robot extends IterativeRobot { |
Re: 2 Cameras in Java
CameraServer.getInstance(), as the name implies, returns a singleton instance of CameraServer. That means server1 and server2 are the same in your code.
Here's how you might get both camera feeds into a single frame Code:
// init |
Re: 2 Cameras in Java
I was not involved with programming this year, but from my conversations with the programming mentors and students, I understand that we had difficulty using two cameras on the same USB bus. This problem appeared not to be java-specific, but a USB camera issue. It seems that most USB cameras (and all of the ones we had on hand at that time, including some KoP cameras) grab something like 60% of the USB bandwidth when they start up. Running two cameras without taking pains to limit these allocations, you are certain to have trouble. If you can't find any detail on how to do this online, PM me and I'll contact the mentors to find out how we resolved/mitigated the issue.
|
Re: 2 Cameras in Java
We ran with 3 cameras on our robot this year (front high view, front ball intake, and the reverse-cam). What we did was to extend the CameraServer class to allow us to switch feeds from one cam to another. We found that getting 2 simultaneous feeds put us a bit too close to the bandwidth cap, even at low-ish resolution (mjpeg isn't that efficient).
On our DS we had two buttons that would set the direction of travel forward and pick one of the two forward cams, and a third button that would invert the direction of travel of the robot and bring up the "reverse" cam. It was fairly efficient, and good for intaking a boulder against the rail or in the corners. Our USB problem wasn't bandwidth (we stopped image capture as we switched cams), but that we had 3 identical cams on the USB bus -- which cam was "usb0" tended to change with each cold start of the RoboRIO. Part of our pre-match on-field setup was defining which "usbX" camera was which. |
Re: 2 Cameras in Java
Quote:
|
Re: 2 Cameras in Java
Quote:
Is there a chance the cameras and hub are drawing too much voltage? (And I presume the trouble you are talking about means not all the cameras were being listed on the RoboRio web interface.) |
Re: 2 Cameras in Java
Thanks for that info. What we will most likely end up doing is having two cameras but only streaming one at a time to the dashboard. This is the latest version of code that we have for it.(FYI this was in a command format but was changed for simplicity of this site)
Code:
Cameras cameras; |
Re: 2 Cameras in Java
Quote:
|
Re: 2 Cameras in Java
Quote:
https://github.com/FRC5881/2016Robot...eraServer.java Quote:
You should also be able to plug those cameras into a PC and check the USB device info (lsusb on linux, for example) to see what the current required for each is. After that, some simple math would tell you if you're over committing. One other question -- are both of these cameras identical? |
Re: 2 Cameras in Java
Quote:
Two of the cameras were identical, one was a different model with a wider field of view. They were all Logitech webcams |
Re: 2 Cameras in Java
Quote:
If each camera works independant of the other two, then it's not compatibility. That leaves the hub (or it's cable), and power as the likely culprits. Aside from testing with another hub (powered and/or unpowered) I'm not sure what else to suggest.... |
You guys can look at our code we had 2 cameras working but you have to manually switch over the stream as it is impossible to stream both cameras at the same time here is our code: https://github.com/Team2895/Team2895...bot/Robot.java
Sent from my iPhone using Tapatalk |
Re: 2 Cameras in Java
Quote:
|
| All times are GMT -5. The time now is 08:23 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi