Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

Reading image buffer

Hi,
I'm using NI-Imaq (without vision) and I need to read image buffer. I 'NI-IMAQ Images and IMAQ Vision Images in C' but I just can't get it right (addressing problems I guess). I can save images all right, but I also want to access buffer data (I need to parse raw data). Could somebody explain (with example) how can I do it? Thanks a lot in advance:)

I'm using functions like:
imgSessionExamineBuffer (Sid, BufNum, &currBufNum, &bufAddr);
imgSessionSaveBufferEx (Sid, (void *)bufAddr, name);
0 Kudos
Message 1 of 6
(3,910 Views)
You should be able to treat the image buffer just like a 2d array of pixels.

After you call imgSessionExamineBuffer (Sid, BufNum, &currBufNum, &bufAddr);
currBufNum[0][0] Should give you the upper left hand corner pixel value.

Hope This helps,
Amaury
ni Applications Engineer
0 Kudos
Message 2 of 6
(3,910 Views)
Thanks for your answer, but still help needed with pointers etc. If I try to read buffer values for example print currBufNum[0][0], CVI says 'Pointer expected'). So there's still something wrong with my code (see Attachement). Thanks again:)
0 Kudos
Message 3 of 6
(3,910 Views)
Sorry...the array you are working with is actually a 1d array so the upper left hand corner is currBuffNum[0] for any pixel you can use currBuffNum [x+width*y].

Hope this helps.
Regards,
Amaury
NI Applications Engineer
0 Kudos
Message 4 of 6
(3,910 Views)
Thanks again, but still no success. When I try to, for example, print pixel value to standard i/o -> printf("%l", currBuffNum[0]). CVI responses-> Type error: Pointer expected. Am I missing something (I know this is not so difficult) ?
0 Kudos
Message 5 of 6
(3,910 Views)
Solved the problem:
unsigned int bufAddr =0, currBufNum, BufNum;
unsigned int *user_buffer;

imgSessionExamineBuffer(Sid, BufNum, &currBufNum, &bufAddr);
user_buffer = (unsigned int *)bufAddr;

// Accessing to buffer values
printf ("Address is %d, value is %d, value +2 is %d\n",
BufAddr, *user_buffer, *(user_buffer+2));

imgSessionReliaseBuffer(Sid);
0 Kudos
Message 6 of 6
(3,910 Views)