LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Buffers output in IMAQdx

Solved!
Go to solution

Hi all,

 

Is it available to output all buffers of images as a 2D array at a time? I could only obtain one image though the number of buffer set in IMAQdx get image.vi and configure acquisition.vi is larger than one.

 

Ninghao

 

0 Kudos
Message 1 of 7
(5,052 Views)

Sorry, I'm not sure from your description what you are trying to do.  Also, please do not use a Stacked Sequence Structure -- simply put all of your functions on one (long) Error Line, or (much better) encapsulate related functions in a sub-VI, create a mnemonic icon for your sub-VI, and simplify your code.  Simple code makes it easier to guess what you are trying to do.

 

Bob Schor

0 Kudos
Message 2 of 7
(5,020 Views)

I am trying to output all the images in the buffer at a time. For example, if the buffer number is five, is it possible to output five images as a 2D array by IMAQdx vi? I have simplified my code, hope it's more readable. Thanks.

0 Kudos
Message 3 of 7
(5,002 Views)
Solution
Accepted by topic author NinghaoZ

Now that I can see your code more clearly, the answer to your "real" question, is it possible to acquire (and save) multiple images from a Camera, is "Yes", but not the way you are doing.

 

IMAQdx is, unfortunately, "under-documented", and it is not always clear how it works or what its parameters should be.  If you are doing a "Grab" (or continuous Video), you need to allocate space in the IMAQdx driver for multiple Images -- these driver spaces are called "buffers".  Say you allocate 6, and say that you are taking images at 30 frames/second.  The default IMAQdx Get Image2 will use buffers 0, 1, 2, 3, 4, 5, 0, 1, 2, 3, etc. in a sequential "circular" fashion, saving images in the "next available" buffer, and returning a pointer ("Image Out") to it for you to manipulate.  

 

The reason to have multiple Buffers for videos is as soon as one Image has been acquired by the Camera, it needs to start saving the pixels for the next Image.  If only one buffer was being used, the incoming Image would immediately start overwriting the storage area for the preceding Image.  If you are only doing a Snap (single Image) instead of a Continuous Grab, you'd have time to process the Image. 

 

Having multiple Buffers for Grab does no good at all if (as your code seems to do) you use the same Buffer for each Get Image.  Recall that the Buffer, and its associated Image wire, only point to areas in memory, and if they are the same, you will have over-writing of data.

 

I hope this is clear.  With reference to your code, I'd make the following suggestion(s):

  • Use the default Buffer Number Mode, Next, for Get Image2.  Do not wire Buffer Number In (it is "required" for the Buffer Number Mode you chose, but is optional, and should be left unwired, for the "Next" mode).
  • Pay attention to Buffer Number Out.  Note it will count "sequentially", i.e. with 3 Buffers, it will count 1, 2, 3, 4, 5, 6, 7, 8, ... (I'm not sure if it starts its count with 0 or 1 ...).
  • Try (really try) not to use Local Variables.  Wire "# of buffer" to an input Tunnel or Shift Register in your outer While Loop.
  • You can save yourself some valuable Block Diagram Space if you don't show Labels for IMAQdx functions (such as IMAQdx Configure Acquisition.vi).  A Compact Block Diagram is an "easier-to-comprehend" Block Diagram.
  • Note that while you are (potentially) processing multiple Images by using IMAQ Image to Array, you are only writing the final Image to the Spreadsheet (not Excel) File.

Bob Schor

 

Message 4 of 7
(4,999 Views)

Hi Bob,

 

Thanks for suggestions. I've tried the outer for loop before and it can work. But if my camera needs to be synchronized with a 500Hz external trigger, could the loop work at such a high speed without losing data?

 

Ninghao

0 Kudos
Message 5 of 7
(4,996 Views)

500 images per second is a very large amount of data.  Most of the cameras I'm using are not capable of such speeds.

 

Bob Schor

0 Kudos
Message 6 of 7
(4,990 Views)

I've solved this problem- For loop can follow the 500 frame rate. Thank you.

 

Ninghao

0 Kudos
Message 7 of 7
(4,986 Views)