Go to Post Gee, I wonder if AndyMark has a wedding gift registry? - KathieK [more]
Home
Go Back   Chief Delphi > Technical > Programming > NI LabVIEW
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 18-01-2016, 17:02
jmb888 jmb888 is offline
Registered User
AKA: Justin Beekman
FRC #0280 (TnT)
Team Role: Programmer
 
Join Date: Nov 2014
Rookie Year: 2015
Location: Taylor
Posts: 10
jmb888 is an unknown quantity at this point
Multiple USB Camera Help

Hi, second year programmer here. I'm having trouble trying to get two USB cameras to work simultaneously. Could someone help me by posting some example code or providing suggestions. Thank You
Reply With Quote
  #2   Spotlight this post!  
Unread 19-01-2016, 21:11
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
Re: Multiple USB Camera Help

1) Can you open one camera (which camera do you have?)
2) Do you want to feed them to the Dashboard or just read them on the roboRIO?

There may be some USB bandwidth limits and you'll have to run at lower resolutions/frame rates. To pipe both to the dashboard simultaneously, the easiest way is to go into the CameraBackgroundLoop.vi and modify it to allow you to use different ports. Then on the drivers station you duplicate the camera reading code for the 2nd port.

The code for sending USB imagery to the desktop is located in
CameraBackgroundLoop.vi -> WPI_CameraSend Images to PC Loop.vi and the default port it uses is 1180. On the dashboard, you'll need to modify Loop 2.
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
Reply With Quote
  #3   Spotlight this post!  
Unread 21-01-2016, 15:28
jmb888 jmb888 is offline
Registered User
AKA: Justin Beekman
FRC #0280 (TnT)
Team Role: Programmer
 
Join Date: Nov 2014
Rookie Year: 2015
Location: Taylor
Posts: 10
jmb888 is an unknown quantity at this point
Re: Multiple USB Camera Help

We are trying to have the two USB cameras plugged into the Roborio. Would that change your directions at all?
Reply With Quote
  #4   Spotlight this post!  
Unread 21-01-2016, 16:43
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
Re: Multiple USB Camera Help

No change in directions. I've attached the files necessary for this. (We'll see how much I regret this) I haven't had a chance to check the changes against a working roboRIO yet. I just patched everything quickly to what "should" work. You'll still need to modify vision code on the rio to add the 2nd camera ("usb 1").
Attached Files
File Type: zip Multiple Cameras.zip (801.1 KB, 165 views)
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
Reply With Quote
  #5   Spotlight this post!  
Unread 25-01-2016, 15:33
BitTwiddler's Avatar
BitTwiddler BitTwiddler is offline
electronics/programming mentor
AKA: Mr Tanguay
FRC #1726 (N.E.R.D.S.)
Team Role: Mentor
 
Join Date: Oct 2008
Rookie Year: 2006
Location: Sierra Vista, AZ
Posts: 251
BitTwiddler is on a distinguished road
Re: Multiple USB Camera Help

Quote:
Originally Posted by adciv View Post
No change in directions. I've attached the files necessary for this. (We'll see how much I regret this) I haven't had a chance to check the changes against a working roboRIO yet. I just patched everything quickly to what "should" work. You'll still need to modify vision code on the rio to add the 2nd camera ("usb 1").
I sure hope you don't regret providing this. It looks like good stuff so far.
It looks like we can use your code to route one camera (usb 0) to the vision processing for targeting. A second camera (usb 1) could then be routed to the dashboard for driving. Is this a fair assessment? We shouldn't need the targeting video on the dashboard just the driving view.
Reply With Quote
  #6   Spotlight this post!  
Unread 25-01-2016, 17:01
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
Re: Multiple USB Camera Help

There's a joke regarding programming and one mistake and supporting it for life.

Your approach is reasonable. At this point, I need to sit down and recode some VIs for long term support for multiple camera robots. I'm seeing it so much this year it's time we have some code properly written for the purpose.
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
Reply With Quote
  #7   Spotlight this post!  
Unread 26-01-2016, 12:24
BitTwiddler's Avatar
BitTwiddler BitTwiddler is offline
electronics/programming mentor
AKA: Mr Tanguay
FRC #1726 (N.E.R.D.S.)
Team Role: Mentor
 
Join Date: Oct 2008
Rookie Year: 2006
Location: Sierra Vista, AZ
Posts: 251
BitTwiddler is on a distinguished road
Re: Multiple USB Camera Help

Quote:
Originally Posted by adciv View Post
There's a joke regarding programming and one mistake and supporting it for life.
Heh! Don't I know that feeling.

Quote:
Originally Posted by adciv View Post
Your approach is reasonable. At this point, I need to sit down and recode some VIs for long term support for multiple camera robots. I'm seeing it so much this year it's time we have some code properly written for the purpose.
That would be much appreciated by many of us. In the meantime I am studying your BackgroundLoop code to learn how it works so I can pass this on to the programmers on the team.
Thanks again.
Reply With Quote
  #8   Spotlight this post!  
Unread 26-01-2016, 13:35
Mr. Lim Mr. Lim is offline
Registered User
AKA: Mr. Lim
no team
Team Role: Leadership
 
Join Date: Jan 2004
Rookie Year: 1998
Location: Toronto, Ontario
Posts: 1,125
Mr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond reputeMr. Lim has a reputation beyond repute
Re: Multiple USB Camera Help

Has anyone in this thread actually gotten both cameras to simultaneously stream to the Dashboard?

We worked on this for a solid day in Java, and ran into issues starting a capture on the second camera without first stopping the capture from the first camera.

When we tried to start two captures at the same time, we received an exception from the underlying NI Vision libraries.

We've gone to using a dedicated Raspberry Pi to stream both USB cameras instead.

One of our students detailed his findings here:
http://www.chiefdelphi.com/forums/sh...d.php?t=142411
__________________
In life, what you give, you keep. What you fail to give, you lose forever...
Reply With Quote
  #9   Spotlight this post!  
Unread 26-01-2016, 13:48
aeastet aeastet is offline
Programming Mentor
AKA: Tim Easterling
FRC #6043 (Allegan Tigers Robotics)
Team Role: Coach
 
Join Date: Jan 2015
Rookie Year: 2011
Location: Holland, MI
Posts: 123
aeastet is an unknown quantity at this point
Re: Multiple USB Camera Help

Using a rasberry PI is a better way to go anyway. This way you do not have to worry about network traffic and bandwidth limitations. If you figured this out then you are doing it the best way in my opinion.
Reply With Quote
  #10   Spotlight this post!  
Unread 26-01-2016, 15:04
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
Re: Multiple USB Camera Help

We did it last year in LabView but had issues which are related to IMAQdx. We're working on developing code this year to support dual streaming again.
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
Reply With Quote
  #11   Spotlight this post!  
Unread 26-01-2016, 15:08
Greg McKaskle Greg McKaskle is offline
Registered User
FRC #2468 (Team NI & Appreciate)
 
Join Date: Apr 2008
Rookie Year: 2008
Location: Austin, TX
Posts: 4,752
Greg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond reputeGreg McKaskle has a reputation beyond repute
Re: Multiple USB Camera Help

The rPI doesn't remove any bandwidth limits. It will move buffer copying and possibly compression to another CPU, but whether that is worth the extra complexity is up to the team.

I read the other thread about NI Vision throwing an exception and didn't see much to work off of. It would not surprise me to see NIVision return an error code when asked to do something that doesn't make sense, and the Java and C++ libs have a habit of throwing exceptions instead of handling errors. If you have more details, please send them. In the meantime, I may find time to get multiple USB streams going. I'm pretty confident it will work, but will require changes within the lower level code to select a different port for transmission.

Greg McKaskle
Reply With Quote
  #12   Spotlight this post!  
Unread 28-01-2016, 19:42
MasterEric's Avatar
MasterEric MasterEric is offline
Bacon. 'nuff said.
AKA: Eric Myllyoja (E2)
FRC #2137 (Oxford Robocats)
Team Role: Programmer
 
Join Date: Dec 2012
Rookie Year: 2013
Location: Oxford High School
Posts: 64
MasterEric is an unknown quantity at this point
Re: Multiple USB Camera Help

This is exactly the solution we needed.

The Camera Background Loop VI (located in the Vision Processing VI) does two things; it handles some required processes for the IP camera to reduce lag, and it also runs the Send Images to PC VI, which, as it sounds, sends the camera to the dashboard.

In our case, we have two cameras on our robot; one functions for vision processing and one functions for driver vision. We were only getting the former on our dashboard, even though both were connected.

Our final solution was to, in Vision Processing, define both cameras, (we spent a while on this part) and run the Camera Background Loop VI on each. To reduce bandwidth consumption, we created an alternative version of the Camera Background Loop with the Send Images to PC VI removed.

Now we can see on the robot with one camera and perform vision processing with the other! Thanks so much, we wouldn't have figured this out without this post!
Reply With Quote
  #13   Spotlight this post!  
Unread 28-01-2016, 20:54
BitTwiddler's Avatar
BitTwiddler BitTwiddler is offline
electronics/programming mentor
AKA: Mr Tanguay
FRC #1726 (N.E.R.D.S.)
Team Role: Mentor
 
Join Date: Oct 2008
Rookie Year: 2006
Location: Sierra Vista, AZ
Posts: 251
BitTwiddler is on a distinguished road
Re: Multiple USB Camera Help

Surely there must be some way of specifying which camera feed goes to the dashboard without having to resort to creating more work for the RoboRio to do.

I've looked at Adciv's code for the Background Loop but I am at a loss to figure out how to specify which video feed is sent to the PC.

Anybody have an answer to this?
Reply With Quote
  #14   Spotlight this post!  
Unread 29-01-2016, 22:21
adciv adciv is offline
One Eyed Man
FRC #0836 (RoboBees)
Team Role: Mentor
 
Join Date: Jan 2012
Rookie Year: 2010
Location: Southern Maryland
Posts: 478
adciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to alladciv is a name known to all
Re: Multiple USB Camera Help

The short version is it doesn't select which of the cameras goes to the dashboard. Instead it sends both of the cameras to the dashboard simultaneously. It modifies the existing code to allow a 2nd camera to be sent in parallel (just on a different port).
__________________
Quote:
Originally Posted by texarkana View Post
I would not want the task of devising a system that 50,000 very smart people try to outwit.
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 20:26.

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