|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
| Thread Tools | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
2 Cameras Setup (Lifecam HD 3000)
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 |
|
#2
|
|||
|
|||
|
Re: 2 Cameras Setup (Lifecam HD 3000)
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/sh...25&postcount=6 |
|
#3
|
|||
|
|||
|
Re: 2 Cameras Setup (Lifecam HD 3000)
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/FRC...bot/Robot.java Look at lines 182-194 and 409-480 (may change in later commits) |
|
#4
|
|||
|
|||
|
Re: 2 Cameras Setup (Lifecam HD 3000)
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. |
|
#5
|
|||
|
|||
|
Re: 2 Cameras Setup (Lifecam HD 3000)
How would you code the stopCamera() function without using NIVision?
|
|
#6
|
|||
|
|||
|
Re: 2 Cameras Setup (Lifecam HD 3000)
Sadly I can't really answer that yet, as we haven't dug into the new OpenCV-based library. However, you could start by looking at the UsbCamera and CameraServer classes' source code to see if you can find where the streaming thread attaches to the camera. I'll be working in this area in a couple of days, so if I find anything I'll reply again.
|
|
#7
|
|||
|
|||
|
Re: 2 Cameras Setup (Lifecam HD 3000)
CameraServer has changed substantially for 2017, so the discussion/suggestions from 2016 no longer apply (I'm the author of the 2017 rewrite). To start two cameras, simply do (Java):
Code:
UsbCamera cam0 = CameraServer.getInstance().startAutomaticCapture(0); UsbCamera cam1 = CameraServer.getInstance().startAutomaticCapture(1); There is no stopCamera() in 2017; the camera automatically starts and stops depending on what's connected to it. You may run into USB bandwidth limits running two cameras simultaneously. Keeping the resolution low is a good way to avoid this. Streaming one camera at a time and switching between them to conserve USB bandwidth isn't well-supported at present (there's nothing to prevent one camera starting before the other stops and thus hitting the bandwidth limit); that's something we will be addressing in a future update. |
|
#8
|
|||
|
|||
|
Re: 2 Cameras Setup (Lifecam HD 3000)
Why is switching difficult? What's wrong with having two cameras and one mjpeg stream output:
Code:
VideoCamera cam0 = UsbCamera("Camera 0", 0);
VideoCamera cam1 = UsbCamera("Camera 1", 1);
MjpegServer server = new MjpegServer("Output to dashboard", 5800);
|
|
#9
|
|||
|
|||
|
Re: 2 Cameras Setup (Lifecam HD 3000)
How did your testing work out. Last year we had three USB cameras and were able to nicely switch among them. I would prefer that to consuming bandwidth by running two camera streams simultaneously.
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|