Log in

View Full Version : 2 Cameras Setup (Lifecam HD 3000)


aweso_meme
12-02-2016, 10:13
Hello all,

With the game this year being hard to navigate through, I would like to set up two cameras on our robot (in Java of course). However, I was only able to figure out how to get one set up. When both are plugged into the roborio, we do get 2 different camera anmes ("cam0" and "cam1"), so I attempted to set up the second camera using a similar method as the first, however this did not work. We are attempting to use the SmartDashboard for Java, and only one of the cameras showed up (with a second USB camera module on the dashboard, the first camera was duplicated). As was mentioned in the title, we are using two Microsoft Lifecam HD 3000s, and we do not have an axis camera.

Does anyone know how to get this working? I'm open to all suggestions -- I'll update this information if you guys request it.

Thank you all,
--aweso_meme, Team 4687 programmer

ghead
12-02-2016, 11:52
The following post has some sample c++ code that handles 2 USB cameras. It might point you the right direction.

http://www.chiefdelphi.com/forums/showpost.php?p=1537225&postcount=6

Andy Sheu
14-02-2016, 09:45
My team is using two USB Cameras and Java. However, we are swapping between them, rather than steaming both at the same time.

Our code can be found here: https://github.com/iron-claw-972/FRC2016/blob/master/src/org/usfirst/frc/team972/robot/Robot.java

Look at lines 182-194 and 409-480 (may change in later commits)

BenBernard
14-02-2016, 19:52
We are also streaming only one camera at a time. There are a couple of tricks to this:

1) In Robot.init, instantiate a USBCamera instance for each camera. Then when you call CameraServer.startAutomaticCapture, pass in the default camera.

2) You'll need a Command, probably triggered by a button, to switch cameras. The natural thing to want to do is to simply call startAutomaticCapture again, passing in the other USBCamera instance. That won't work, because of the way startAutomaticCapture is implemented. To solve this, you'll have to create your OWN version of CameraServer (copy, paste, rename), and change the startAutomaticCapture to stopCapture on the camera already in use, if any (m_camera), set the new camera, then startCapture on the new camera.

If you need more details, let me know.