Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Acquiring frames from two firewire cameras simultaneously

Hello, I am trying to set up a VI to capture video from two firewire AVT Stingray cameras simultaneously. Each one will be plugged into a separate PCI card. I want the framerates to be as high as possible, meaning as close to 60 fps as possible. I have already made a program that works with one camera, with about 60 fps, using IMAQdx functions. I am wondering what the optimal method would be for setting up the VI for two cameras. In my one camera program, frames are acquired in a loop. Should I just make a duplicate of the code and have both cameras save frames in the same loop, or should I use more complicated methods for synchonization such as using rendevous or semaphores?
0 Kudos
Message 1 of 12
(5,264 Views)

Hey nrfowl,

 

Are both cameras working properly? If you can acquire from both cameras using your code to capture a single camera at a time, you should not have any trouble acquiring from both of them at the same time. On the most basic level you can simply copy the code for grabbing from a single camera and paste paste it below the first. Then all you have to do is change the resource name to your second camera. If you would like you could put the grabs for both cameras in a single while loop and have all of your configuration steps separate.

 

If you are looking for synchronization, you could consider some sort of triggering to get both cameras on capturing at the exact same times. But if you are simply looking to acquire from two cameras at the same time, you should not HAVE to implement additional code control steps such as semaphores or rendezvous.

Hope this helps.
-Ben

WaterlooLabs
Message 2 of 12
(5,251 Views)
Bcho's explanation is so good.
0 Kudos
Message 3 of 12
(5,229 Views)

I have figured out how to aquire from both cameras simultaneously. However, their frame rates sometimes differ from one another. I would like them to be as close as possible. Also, the other problem that I am having now is that the frame rates of both cameras, or just one, will sometimes fall as low as 49 FPS for a few seconds. The frame rates of the two cameras usually oscillate together between 60 FPS and 59.94 FPS.

The variation between 60 and 59.94 is acceptable, but any variation greater than about 1 or 2 FPS is unacceptable.

 

I am trying to figure out how to have the two cameras nearly exactly synchronized at a constant frame rate. Can you give me an idea on how I can learn more about triggers? I haven't heard much about those. And I'm not sure if the semaphores and those other methods will work, because I am not sure what is causing these random drops in frame rate

 

It seems that when I lower the framerates there is less variation, but there are still occasional drops of frame rate.

0 Kudos
Message 4 of 12
(5,223 Views)
Talking to an AVT engineer, I have learned that I will probably need an external trigger because an NI driver is not precise enough. Any recommendations on how to set this up? Although a solution using only labview programming would be easier.
0 Kudos
Message 5 of 12
(5,221 Views)

Hi Nathan,

 

...I'm the AVT engineer you were speaking with...I lurk here in the NI space too.  😉

 

On synchronizing two cameras, from an AVT perspective:

 

http://goavt.mykb.com/Article_9244B.aspx

 

On triggering in general, from an AVT perspective:

 

http://goavt.mykb.com/Article_B68F8.aspx

 

 

I also attach a "Trigger2" Labview code segment prepared by a colleague, in case that helps you with your "via Labview"  preference.

 

Naturally others on this forum may offer additional insights.

 

Best regards,

 

Scott Smith

Allied Vision Technologies

 

 

0 Kudos
Message 6 of 12
(5,218 Views)

Without external triggers we're talking a software timed situation - meaning you cannot be precise because there will always be significant 'jitter' in how your computer assigns processes/threads. They'll never be truly synchronized.

 

In the shipping examples you should be able to find Triggered Grab.vi under Hardware Input and Output»IMAQdx»Signal Input and Output»Triggered Grab.vi.

Jeff | LabVIEW Software Engineer
0 Kudos
Message 7 of 12
(5,201 Views)

I am guessing you are not using a large buffer when acquiring the images.  If you are just using grab, you will lose some images due to Windows lags.

 

If you acquire both cameras into a circular buffer, you should not lose any frames and they should stay synchronized as long as they are both setup exactly the same (frame rate, shutter speed, etc.)

 

Synchronizing the start would be the only issue.  You should probably use a hardware trigger if you need them to start at exactly the same time.

 

Post your code so we can figure out why you are getting drops in the frame rate.  This should not happen in normal circumstances.

 

Bruce

Bruce Ammons
Ammons Engineering
0 Kudos
Message 8 of 12
(5,170 Views)

Bruce, do you mean increasing the number of buffers? I think I tried that with no success.

 

Here is my code:

 

 

0 Kudos
Message 9 of 12
(5,166 Views)

nrfowl,

 

You can't get synchronized acquisitions when using the "next" buffer mode. This is designed for cases where you don't care about processing every image, just the latest one. If your time processing one image ever takes slightly longer than a frame interval you will skip frames rather than catch up on the next loop iteration.  Instead, switch the buffer number mode to "buffer number" and wire the requested buffer number into a shared shift register that increases by one each time. You can check if you are getting behind by ensuring that the buffer number returned matches the one you asked for on both cameras.

 

The other item you likely want to do is have them share the same trigger so that you don't get slightly out of sync over a period of time. This will happen if you have both cameras in free-running mode because although they are set for 60fps they each have their own internal clock that will drift. Over enough time one camera will have acquired more images than the other. Scott gave a link that explained how to do this without any extra hardware.  "Connect the Output1 (IntEna) from the master-camera with Input1 (Trigger)". This will still let you have your free-running 60fps without an external trigger but will guarantee the second camera acquires images at the exact same rate.

 

Eric 

0 Kudos
Message 10 of 12
(5,163 Views)