Extract IMAQ Image from Camera Memory Using .NET

Updated Apr 8, 2019

Reported In

Driver

  • NI-IMAQ

Issue Details

I have a Thorlabs DCx UC480 camera. With the supplied .dll libraries, I am able to control the camera in LabVIEW using .NET. I would like to process the camera images using IMAQ API, thus I need to convert the camera images to IMAQ images. How can I do so?

Solution

With a .NET reference to your camera, you are able to access its properties and methods using property nodes and invoke nodes. The camera class uc480.camera has a Memory property that provides a reference to the camera memory. We can use this memory reference to extract the image data.
  1. Add a Property Node in the block diagram. Wire the uc480.camera .NET reference to the property node and select the property Memory.
  2. Add an Invoke Node and select the GetActive method of the Memory class.
  3. Add a second Invoke Node, reference the Memory class. Select the ToBitmap method.
  4. Wire the s32MemId output from the GetActive Invoke Node to the s32MemId input of the ToBitmap Invoke Node. This will convert the memory data specified by the s32MemId to a bitmap format.
  5. With the bitmap reference we can invoke the Save method, and stream it to a System.IO.MemoryStream, from which we can extract the image data.
On details on how to create a System.IO.MemoryStream, extract the image data, and convert it to an IMAQ image, follow the instructions in Convert a .NET PictureBox to an IMAQ Image starting from step 3.

 

Additional Information