Go to Post Hard work is a necessary prerequisite for luck. - Ian Curtis [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 12-02-2016, 10:13
aweso_meme aweso_meme is offline
Registered User
FRC #4687
 
Join Date: Feb 2014
Location: Minnesota
Posts: 20
aweso_meme is an unknown quantity at this point
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
Reply With Quote
  #2   Spotlight this post!  
Unread 12-02-2016, 11:52
ghead ghead is offline
Registered User
FRC #3103
 
Join Date: Aug 2013
Location: US
Posts: 14
ghead is an unknown quantity at this point
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
Reply With Quote
  #3   Spotlight this post!  
Unread 14-02-2016, 09:45
Andy Sheu Andy Sheu is offline
Registered User
FRC #0972 (Iron Claw)
Team Role: Programmer
 
Join Date: Sep 2015
Rookie Year: 2014
Location: San Jose
Posts: 6
Andy Sheu is an unknown quantity at this point
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)
Reply With Quote
  #4   Spotlight this post!  
Unread 14-02-2016, 19:52
BenBernard BenBernard is offline
Registered User
FRC #5687 (The Outliers)
Team Role: Mentor
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Portland, ME
Posts: 45
BenBernard is on a distinguished road
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.
Reply With Quote
  #5   Spotlight this post!  
Unread 09-01-2017, 22:38
etashthebomb etashthebomb is offline
Registered User
FRC #1758
 
Join Date: Jan 2017
Location: Florence
Posts: 1
etashthebomb is an unknown quantity at this point
Re: 2 Cameras Setup (Lifecam HD 3000)

How would you code the stopCamera() function without using NIVision?
Reply With Quote
  #6   Spotlight this post!  
Unread 10-01-2017, 10:14
BenBernard BenBernard is offline
Registered User
FRC #5687 (The Outliers)
Team Role: Mentor
 
Join Date: Jan 2016
Rookie Year: 2015
Location: Portland, ME
Posts: 45
BenBernard is on a distinguished road
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.
Reply With Quote
  #7   Spotlight this post!  
Unread 10-01-2017, 11:51
Peter Johnson Peter Johnson is online now
WPILib Developer
FRC #0294 (Beach Cities Robotics)
Team Role: Mentor
 
Join Date: Jan 2010
Rookie Year: 2008
Location: Redondo Beach, CA
Posts: 264
Peter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud ofPeter Johnson has much to be proud of
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);
Note the no-arguments variant of startAutomaticCapture always starts camera 0. Thinking about this, it may be a good idea for us to make this auto-increment in the future to make this a bit easier to use.

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.
__________________
Author of cscore - WPILib CameraServer for 2017+
Author of ntcore - WPILib NetworkTables for 2016+
Creator of RobotPy - Python for FRC

2010 FRC World Champions (294, 67, 177)
2007 FTC World Champions (30, 74, 23)
2001 FRC National Champions (71, 294, 125, 365, 279)
Reply With Quote
  #8   Spotlight this post!  
Unread 10-01-2017, 15:22
blucoat blucoat is offline
Registered User
FRC #0069
 
Join Date: Dec 2015
Location: Quincy, MA
Posts: 3
blucoat is an unknown quantity at this point
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);
And switching between them using server.setSource()? We switched between two streams last year by modifying the CameraServer class, which worked fine. However, looking at the CSCore library, this seems like the "obvious" way to do it. I'm about to test this in a few hours, am I going to run into problems?
Reply With Quote
  #9   Spotlight this post!  
Unread Today, 12:48
KB1200 KB1200 is offline
Registered User
FRC #5099
 
Join Date: Feb 2017
Location: Northport, NY
Posts: 1
KB1200 is an unknown quantity at this point
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.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 18:12.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi