Quantcast
Channel: All LabVIEW posts
Viewing all articles
Browse latest Browse all 202521

Use 2D array as input and output to dll

$
0
0

Hi, I have problem with 2D array used with call library funtion to get array from DLL.

 

uint16_t is defined as unsigned short, which is unsigned 16 bit in labwindows.

In both following codes origFrame.height is 1024, origFrame.width is 1280.

QCam_Err DLLEXPORT FrameGrab(void* handle, uint16_t frame2D[1024][1280]) {

uint16_t *p;
p = (uint16_t*)origFrame.pBuffer;
// Copy each pixel to the 2D array
for(int i=0; i<origFrame.height; i++){
for(int j=0; j<origFrame.width; j++){
frame2D[i][j] = *p++;
}
}
}

Because 2D array is passed to DLL as 1D array, I also tried 1D array below but get the same numerical results.

 

 

QCam_Err DLLEXPORT FrameGrab(void* handle, uint16_t *frame1D) {
uint16_t *p;
p = (uint16_t*)origFrame.pBuffer;
for(int i=0; i<(origFrame.height*origFrame.width); i++){
frame1D[i]=*p++;
}
}

 

 

These two methods gives me the same result numerically in terms of the numbers in the output array.  

 

Interesting things is that the output array does have the right dimension but the all the numbers in the array is about ~40, while my expected values in all the array is 60.  I know that because I'm using this to get pixel values from a camera and I know the pixel values.  Also I used the same code in LabwindowsCVI as a normal program built as exe.  Everything works fine and I get my expected values back.  So apparently I'm missing something here when I changed parameters to make it dll.

 

What did I do wrong?  Thank you very much for your help!

 

Best,

Charles

 

 

 

 

 

 

 

 

 


Viewing all articles
Browse latest Browse all 202521

Trending Articles