LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple IMAQdx USB camera acquisitions simultaneously

Solved!
Go to solution

Hello,

I am trying to acquire from 2 or more USB-based webcams simultaneously, but one of the cameras always errors out. I replaced IMAQdx GRAB with IMAQdx SNAP and that seems to work for capturing frames. But I would really like to have live feed from both (or more) web cams if possible. The idea is to view the live feed from both cameras and then make necessary adjustments in the rest of the hardware in my system and then begin capturing frames at every 10 seconds or so (from both or more web cams).

Attached, multicamera_op_v1 = VI for getting live feed from two webcams.

multicamera_op_v2 = VI for getting live feed from two webcams and then captures frames from both cameras.

 

I would appreciate any suggestions.

Thanks

 

Download All
0 Kudos
Message 1 of 26
(7,336 Views)

In the first VI you don't close the camera sessions at all, and in the second VI open two sessions for each camera, that could have something to do with it.

0 Kudos
Message 2 of 26
(7,322 Views)

Thanks for pointing it out. I closed both cameras in the first VI but that did not make any difference. Also, the "camera close" happens only after the execution of the main chunk of the code (such as config and acquire images), it should not have caused the errors anyway.

In this first VI, when I replace the "GRAB" with SNAP" I get no errors. The front panel of the VI shows images or snaps from both VIs without error...albeit at very low fram rate (more like 1 fps)

 

As for the second VI, I close both the cameras the first time in order to end the "GRAB" process for the cameras. Then I reopen, reconfigure the cameras and use the SNAP process to acquire images. I wrote that code only to check if such sequence could work. 

 

0 Kudos
Message 3 of 26
(7,316 Views)

The first time you run the program it might not matter if you close them or not, but for any subsequent runs it could make the cameras seem not available. In the second program the close VIs are outside of the sequence diagram, and they only run once at the very end of the program. This means your you are doing open, open, close, close on each camera.

 

Can you get each camera to grab by itself?

 

Are the buffer numbers changing?

 

Are the cameras identical?

 

If you decrease the resolution does it make any difference?

0 Kudos
Message 4 of 26
(7,304 Views)

Thanks for the quick reply, I have answered your questions in BLUE.

 

Can you get each camera to grab by itself?

Yes.

 

Are the buffer numbers changing?

For the camera that works (one of them always times out), the buffer number changes but is increasing in the steps of 50 i.e. 44,94,etc..)

 

Are the cameras identical?

Yes

 

If you decrease the resolution does it make any difference?

No

 

 

0 Kudos
Message 5 of 26
(7,301 Views)

We've been able to record from 24 Axis TCP/IP cameras at 30 FPS simultaneously, but when we attempted to replace these cameras with USB WebCams, the number of simultaneous videos went way down.  Two, however, should be no problem.  You need to use Producer/Consumer loops -- the camera "Get Frame" needs to be in the Producer by itself, and the processing of the Image (what do you plan to do with the images, anyway?) need to be in separate Consumer loops.

 

Bob Schor

0 Kudos
Message 6 of 26
(7,276 Views)

Thanks for the reply, Bob. I plan to only save the images I acquire from the web cams and I plan to use the producer-consumer design to do that. In fact, that's what I did when I had only one camera. But when I expanded to 2 cams, that idea did not work, and I realized that one of the cameras always times out. That's when I downsized the code to see if they even just capture simultaneously, leaving the save part completely out of the picure. 

I may need to expand the system to 4 cameras in the near future. What other aspects can I test to see if even 2-camera system will work?

 

I read somewhere that if both cameras have the same manufacturer and model (hence the same name), LabVIEW is unable to distinguish between them and so it won't work. I do not know how to change the name - and I don't think it is possible.

0 Kudos
Message 7 of 26
(7,254 Views)

I read somewhere that if both cameras have the same manufacturer and model (hence the same name), LabVIEW is unable to distinguish between them and so it won't work. I do not know how to change the name - and I don't think it is possible.


 

 

That's not true, it distinguishes by the session in that you open up. You can however change this name from the default by going into NI MAX. Find the camera that you want (usually under IMAQdx devices), right click, and select rename. This name usually only sticks for the one computer though (at least with my GigE cameras).

 

Can you attach your producer/consumer code?

0 Kudos
Message 8 of 26
(7,245 Views)

Sure, I attached the code with producer-consumer loop for saving the files.

Thanks

Download All
0 Kudos
Message 9 of 26
(7,237 Views)

What happens if you set "Wait for next buffer?" to "False" on the image grabs? And just for good luck, when you open the session, can you set "control mode" to "controller"?

 

Also, unrelated to this discussion, that flat sequence in your producer/consumer does nothing. The while loops will wait to execute until they have the outputs from your obtain queue VIs.

0 Kudos
Message 10 of 26
(7,231 Views)