Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   NI LabVIEW (http://www.chiefdelphi.com/forums/forumdisplay.php?f=182)
-   -   Multiple USB Camera Help (http://www.chiefdelphi.com/forums/showthread.php?t=142071)

jmb888 18-01-2016 17:02

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

adciv 19-01-2016 21:11

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.

jmb888 21-01-2016 15:28

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?

adciv 21-01-2016 16:43

Re: Multiple USB Camera Help
 
1 Attachment(s)
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").

BitTwiddler 25-01-2016 15:33

Re: Multiple USB Camera Help
 
Quote:

Originally Posted by adciv (Post 1527953)
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.

adciv 25-01-2016 17:01

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.

BitTwiddler 26-01-2016 12:24

Re: Multiple USB Camera Help
 
Quote:

Originally Posted by adciv (Post 1529934)
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 (Post 1529934)
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.

Mr. Lim 26-01-2016 13:35

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

aeastet 26-01-2016 13:48

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.

adciv 26-01-2016 15:04

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.

Greg McKaskle 26-01-2016 15:08

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

MasterEric 28-01-2016 19:42

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! :D :D :D

BitTwiddler 28-01-2016 20:54

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?

adciv 29-01-2016 22:21

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).


All times are GMT -5. The time now is 03:53.

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