LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Using 2 cameras to capture frames using a subvi

Hello everyone,

 

i wrote a dll using c++ that is able to control my cameras (using winusb and setup api). In labview i made a subvi that lets me use my dll in an easier manner, without always having to initialize arrays where the frame will be written. If i put the subvi that is responsible for capturing frames in a while loop i get an approximate 50 frames per second capturing speed, which is good. Before adding my second camera i went and enabled "Preallocated clone reentrant execution" in VI properties and "run in any thread" in call library function node. After doing so i added the second camera capturing subvi in a separate while loop. Both loops ran at 50hz.

 

Now the problem is that i want the second camera to take pictures when the first camera is half way into capturing its frame. So while the first camera is taking a picture, the second camera goes midway and also starts to capture a frame. When the second camera is half way into taking a picture, the first camera is taking a frame, and so on. I tried to put a wait vi with half a period but that is very rough, and not precise.

 

Attached image shows one of the ideas i had, however it did not work. It just made images come at 50hz, so capturing wasnt done in parallel. The start asynchronous call grabs the image, and then its retrieved in wait for asynchronous call.   

 

Thank you for your help. I dont use labview often, im sorry in advance for my lack of knowledge. 

 

 

 

0 Kudos
Message 1 of 4
(1,424 Views)

OK, so you are using Asynchronous Calls, two cameras, are not using IMAQdx (but a third-party DLL), and you attach a picture of part of your code.  I won't even bother to look, but can give you some tips (having written a routine that has up to 24 cameras running asynchronously and simultaneously):

  • Write a "Clone VI" (my name for a sub-VI that you run using Start Asynchronous Call) designed to be run completely independently from the Top-Level (calling) VI..The Clone should be passed information on the Camera it will be using.
  • The Clone should run as a State Machine, initializing the Camera, waiting for a Trigger, then acquiring Images until "told to stop".  The Clone is responsible for saving its own Images, so you may want to configure a Producer/Consumer loop for Image-saving in the Clone.  When the Clone is told to stop, it should close the files, close the Camera, and simply Exit.
  • Start and Stop signals can be brought in as Notifiers or Queue elements from the Top-Level VI.
  • The Clone should be coded as a Pre-allocated Reentrant VI.
  • You should be using LabVIEW Project, and have your VIs and TypeDefs arranged in a sensible Folder Structure unique to this Project.
  • The Top-Level VI should instantiate the two Clones, including creating the Communication path to send Start and Stop signals.  
  • Once both clones are running, you can send Clone 1 a Start signal, wait 10 msec (half a frame), then send Clone 2 its Start signal.  If all goes well, your cameras will go 1, 2, 1, 2, 1, 2, ...
  • Don't forget to send both Clones the Stop signal.

Bob Schor

Message 2 of 4
(1,357 Views)

Thank you, it worked. Sorry completely forgot to respond!

 

However my cameras only grab one frame per command. So i just send one command to one camera then wait for half a period and then send command to another camera.  

 

Then i send stop command once i got enough frames.

 

Thanks again!

0 Kudos
Message 3 of 4
(1,299 Views)

So you almost have the solution.  You are not the only one who might want to synchronize two cameras.  We helped you, now it is time for you to help the Community.  Attach the routine that "almost works" (so others can see what you've done), and maybe we can help you to finish the "last piece of the puzzle".

 

Bob Schor

0 Kudos
Message 4 of 4
(1,283 Views)