empstar
-
Posts
3 -
Joined
-
Last visited
Never
Content Type
Profiles
Forums
Downloads
Gallery
Posts posted by empstar
-
-
QUOTE (rolfk @ Jun 8 2009, 03:07 PM)
This is a crosspost from http://forums.ni.com/ni/board/message?board.id=170&message.id=414839&jump=true#M414839' target="_blank">here. It is considered polite to mention crossposts.You should learn a bit about C datatypes and how the C compiler allocates them. The two arrays in your structure are fixed size and therefore are not added as pointers to the structure but instead inlined. This means the structure is as long as the two arrays put together into memory. Also a LabVIEW cluster with two arrays in it is not the same as a C structure with two array pointers in it since LabVIEW arrays are not C pointers but special LabVIEW data types. But this does not apply here anyhow. What you will want to do is create an array of bytes with the length of 1000 (width) * 1000 (height) * 2 (sizeof(UINT16)) + VIVAGRAB_FRAME_METADAT which according to my calculations would be all together 0x2000000. Then pass that as C array pointer to the function.
And now comes the intersting part to extract the info from the array. This will be an interesting exercise for you to do. :-)
Rolf Kalbermatter
Dear Rolf,
Thank you for your reply. I created an array of byte with 0x200000 and passed it as C array pointer to the function. There is no clash, and the array seems to be initialized. You can check the labview code I upload.
As you mentioned, the extraction of data from the array is an issue. I tried to use MoveBlock of Labview, but it didn't work correctly because there is no output pointer to control although I can extract the data with the following C code.
pVIVAGRAB_VIDEO_FRAME_ARRAY FrameBuffers; //FrameBuffers will point to an array of type VIVAGRAB_VIDEO_FRAME and is filled in by VivaGrabInit().
UINT16 *ImagePtr;
retval = VivaGrabInit(10,&FrameBuffers);
ImagePtr=(UINT16*)FrameBuffers;
Would you guide me how to extract data information in Labview? Thank you in advance.
-
I wrote a VI for a function called VivaGrabInit for DLL, but it always is clashed when I run with a memory error. Can anybody help where I'm wrong in the code?
Function frome a head file
#define VIVAGRAB_FRAME_BUFFER_SIZE 0x200000 //2Mb
#define VIVAGRAB_FRAME_WIDTH 1000
#define VIVAGRAB_FRAME_HEIGHT 1000
#define VIVAGRAB_FRAME_SIZE (VIVAGRAB_FRAME_WIDTH*VIVAGRAB_FRAME_HEIGHT*sizeof(UINT16))
#define VIVAGRAB_FRAME_METADATA (VIVAGRAB_FRAME_BUFFER_SIZE-VIVAGRAB_FRAME_SIZE)
typedef struct
{
UINT16 FrameData[VIVAGRAB_FRAME_HEIGHT][VIVAGRAB_FRAME_WIDTH];
UINT8 Metadata[VIVAGRAB_FRAME_METADATA];
} VIVAGRAB_VIDEO_FRAME, *pVIVAGRAB_VIDEO_FRAME, **pVIVAGRAB_VIDEO_FRAME_ARRAY;
extern "C" __declspec(dllexport) UINT32 VivaGrabInit(UINT32 NumFrameBuffers, pVIVAGRAB_VIDEO_FRAME_ARRAY *FrameBuffers);
DLL connection for pointer structure
in Calling External Code
Posted
QUOTE (rolfk @ Jun 9 2009, 12:13 PM)
Dear Rolf,
As you suggested, I created an byte array with 0x200000 long by Initialize Array Function (All Elements are 0), and passed it to Call library function node with following configuration parameters
Name: FrameBuffers
Type: Array
Data type: unsigned 8-bit Integer
Dimensions: 1
Array format: Array Data Pointer
When I checked the FrameBuffers as an unsigned 8-bit array, only first four elements have non-zero values and the rest are all zeros although I expected all elements have non-zero values.
Why the only first four elements have non-zero values? Would you suggest any way to correctly extract data in the byte array? Thank you for your comments.