LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple IMAQdx USB camera acquisitions simultaneously

Solved!
Go to solution

The problem still persists despite setting "Wait for next buffer" to false and control mode to controller. One of the cameras will time out. Highlighting the execution shows that one camera will GRAB an image instantly while the other one attempts to do the same operation for a few seconds and then times out. It is random which one times out. I even tried to create a flat sequence so that both cameras do not attempt to GRAB at the same time (in case that is the problem), but that did not help.

 

And yes, you are right about the flat sequence being redundant. I realized it later, but haven't gotten around to removing it.

0 Kudos
Message 11 of 26
(4,111 Views)

I reposnded but the message does not show up in this thread so I am writing again...

 

Setting "Wait for next buffer?" to FALSE and "Controller Mode" to CONTROLLER does not help. One of the cameras will still continue to time out. Highlightling the execution shows that both cameras execute GRAB function almost at the same time. I thought that might be causing one of them to time out. Therefore, I put the GRAB operaztions in a flat sequence so that the two cameras will GRAB sequentially instead of simultaneously, but that did not change anything.

 

And yes, I realized that the flat sequence is redundant, but never got around to remove it. I figured that it can't be the one causing this error anyway.

0 Kudos
Message 12 of 26
(4,108 Views)

What if you put shift registers on the images and cameras? Try running this code:

 

acquire_two_cameras.png

 

 

0 Kudos
Message 13 of 26
(4,103 Views)

One of the cameras will still time out but the main difference the shift registers made is that for the camera that works, the buffer number increases steadily unlike before, when it would increase by 40 each time. 

0 Kudos
Message 14 of 26
(4,092 Views)

Sorry, I'm "out of town" at a meeting, so I didn't take a look at your code.  To record from multiple cameras simultaneously, you really need to run each camera "independently".  This means that (for two cameras) you should have two producer loops, each dedicated to having a single camera put frames, as they are acquired, on a Queue (one Queue per camera), and two Consumer loops, one per Queue, taking the data from the camera and saving it (or displaying it).

 

In our 24-camera scenario, we called each camera/video/image display/etc. a "station", and had a VI that ran the entire Station.  These VI's were run using the Start Asynchronous Call functions (so they all ran in parallel).  They were called with a "Station Number" parameter that was used to provide unique names for files and other data structures needed by the Station.

 

In your two-camera case, simply create independent While loops for each camera.  I do strongly recommend that you use a Producer/Consumer design, with the Camera putting "images" on the Queue, and a Consumer loop that takes the Images off and does whatever you need to have done with them (display, save to file, etc.).  Note that if there are one-time "time-consuming" code that needs to be done by the Consumer loop (such as opening a file for writing .avi images), you should do this before entering the Consumer loop, so all the loop has to do is the Write Image function (the Close File, of course, is done when the Consumer Loop exits).

 

Bob Schor

0 Kudos
Message 15 of 26
(4,073 Views)

Thanks for the reply, Bob. I created two producer-consumer loops for two cameras. Each producer loop only GRABs a frame and enques it, while each consumer loop only dequeues and displays the frame. But even then one of the cameras still times out. I should point out that any one of the cameras can time out. If the first one times out during the first run of the code, the second one may time out during the next. Thus, it is not that a specific camera has some flaw that causes it to time out. Also, this time, I even tried using entirely a different pair of cameras from two different manufacturers just to make sure that it is the original pair of cameras that are causing this error. Either way, the problem still exists.

The one interesting thing though, is that if I choose the laptop's built-in web cam to be one of the cameras, then the code runs just fine. No time outrs on either of the cameras. Also, this was true for my original codes, where I had only one producer-consumer loop controlling both cameras. In this configuration, do you think the USB controller of the lapop causing the problem? For external USB cameras, I am using a powered USB 3.0 hub. 

 

I have attached the latest code as well as the screenshot. Please let me know what other options I could try. In the code attached, you will see that I open the camera - close the camera - and open it again. I am doing this hoping that it will reset the camera, although I do not think that that is the right approach or even necessary. 

Please let me know your thoughts.

 

multicamera_v0b.PNG

0 Kudos
Message 16 of 26
(4,045 Views)

Hello everyone,

any other suggestions I could try? The cameras I used initially are 5V DC USB board cameras, and I thought the power requirements might be causing the issue. Therefore, I used generic web cams that operate at lower voltages (3.3 V, I think). But same problem there as well.  Could the USB hub be the problem? or the laptop?

Thanks

 

0 Kudos
Message 17 of 26
(4,015 Views)

@abhi_vt wrote:

Hello everyone,

any other suggestions I could try? The cameras I used initially are 5V DC USB board cameras, and I thought the power requirements might be causing the issue. Therefore, I used generic web cams that operate at lower voltages (3.3 V, I think). But same problem there as well.  Could the USB hub be the problem? or the laptop?

Thanks

 


An excellent question.  I can tell you that I can acquire images at 30fps from 24 Ethernet cameras simultaneously -- haven't tried doing this with USB WebCams.  What frame rate are you using?  What image format?  I can imagine that if you are doing Full Screen/Full Color, that could be a lot of bytes to shove down the USB bus.

 

BS

0 Kudos
Message 18 of 26
(4,006 Views)

Hi Bob,

Thank you for the reply. The frame rate is 15 fps per camera and I use "SAVE AS JPEG" block to save the images. The camera, by default transmits images in JPEG format, but I am not very sure about that. I do not think that 2 USB cameras would generate so much data that one USB hub is unable to handle. I bought another hub which will arrive tomorrow. I will post the results with the new hub. 

 

0 Kudos
Message 19 of 26
(3,996 Views)

I'm having some trouble with my IMAQdx functions, so I can't (right now) write code to test your methods, but in the Camera 2 Producer loop (the lower one), you are enqueuing the Camera Session, not the Image!  Got your wires mixed up.  See if making the Camera 1 and Camera 2 loops "look the same" fixes things.

 

Bob Schor

0 Kudos
Message 20 of 26
(3,981 Views)