LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Cluster to Call Library Function Node

Hi Everyone,

 

I'm attempting to retrieve data from a C DLL by passing a cluster consisting of 5 numeric's and 2 arrays into a Call Library Function Node.

I can stream an image but cannot seen to retrieve the Timestamp, Bitmap,Frame rate per second, Height, Width or Bytes per Pixel.

As you can see by the image enclosed I have tried a few different ways. i do not have drivers for the camera.

Any help with this would be greatly appreciated.

 

I am using Labview 2015 on a windows 10 Pc

 

 

Download All
0 Kudos
Message 1 of 7
(2,469 Views)

@Shea1 wrote:

 

I'm attempting to retrieve data from a C DLL by passing a cluster consisting of 5 numeric's and 2 arrays into a Call Library Function Node.  


 

You are not passing a cluster to any dll, just a flat U8 array the size of the data cluster, and that's what you get back.

 

We cannot see what any of the subVIs are doing. Why doesn't the subVI on the left return all elements?

0 Kudos
Message 2 of 7
(2,435 Views)

Flatten to string is not doing what you would like here. From the help: "prepend array or string size? only controls the top-level data size information. Arrays and strings in hierarchical data types such as clusters always include size information. " So, you are still embedding length information because the arrays are not at the top level, and that's inserting unexpected data into your array.

 

How is the struct defined in the C header? The right way to do this is to make a cluster in LabVIEW that corresponds to the C struct. If the arrays inside the struct are fixed size, then in LabVIEW they need to be replaced with a cluster of the same element type, containing that number of elements. If the arrays inside the struct are actually pointers to arrays of variable size, then it's more complicated.

0 Kudos
Message 3 of 7
(2,423 Views)

The Structure manages the data of a frame, it is returned when the users have requested one frame and receives a pair of images, the FPS, resolution and the timestamp. The ua16Bitmap0 and ua16Bitmap1 are a 2D array with a size of 240 by 340.

As you can tell, I'm pretty new to Labview, any examples or help would be greatly appreciated.

0 Kudos
Message 4 of 7
(2,413 Views)

To make sure I'm understanding the data structure correctly and don't accidentally provide bad advice, can you upload the .h (C header) file for the library, which should provide the structure definition and the prototype for the function you want to call? If that's not available, then the equivalent from the library documentation. How do you know the bitmap array size - is it fixed in the documentation, or the size you have is correct for your particular implementation?

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

The resolution of each bitmap in the pair is assumed to be that of the sensor: 320x240 in 16-bits pixels.

 

Admin note - removed attachment per user's request

0 Kudos
Message 6 of 7
(2,404 Views)

The two bitmaps embedded in the struct are pointers, which makes things more complicated. They're probably pointers to 1D arrays containing 320x240 (76800) elements. So, in order for this to work, you need to allocate memory for those two bitmaps, using DSNewPtr, then store the pointer to those locations in a cluster. As RolfK likes to point out for these types of questions, in LabVIEW there is no good way to do this if you need to support both 32- and 64-bit systems. If you know you will only ever run this on one type of system, then you can create a struct with the appropriate format. You need a cluster containing a 64-bit element for the timestamp, two 32-bit integers (for a 32-bit system) or two 64-bit integers (for a 64-bit system) to store pointers to the bitmaps, then 4 32-bit integers for FPS, width, height, and bytesPerPixel. Fortunately you shouldn't need any padding bytes to assure proper alignment.

 

Initialize the bitmap pointers with the memory addresses returned by two calls to DSNewPtr; search this forum for help with that function. You'll need to use MoveBlock (again, search this forum) or the pointer dereference tools to retrieve the data from the bitmap pointers.

0 Kudos
Message 7 of 7
(2,384 Views)