09-27-2005 06:45 AM
// get the frame
imgGrab (Sid, &ImaqBuffer, TRUE);
// display it using imgPlot
imgPlot ((GUIHNDL)ImaqSmplHwnd, ImaqBuffer, 0, 0, AcqWinWidth, AcqWinHeight,
CanvasLeft, CanvasTop, plotFlag);imaqBuffer ist the buffer for storing image data, which was declared as follows:
static
char *ImaqBuffer=NULL; // acquisiton bufferHow can i get the image data from "ImaqBuffer"? (how to get the buffer size?)
thx a lot!
scott
09-29-2005 04:58 AM
Hi Scott, wit installing NI-IMAQ you will get examples. You can find them in C:\Programme\National Instruments\NI-IMAQ\Sample\MSVC\Grab I think they will answer your question.
Thanks, Rebecca
NI, Germany Applications Engineer
09-29-2005 09:22 AM
hi rebecca,
thanks for the reply. i've already installed ni-imaq, and the code i posted was actually from their grab examples.
after finding out the size of the buffer (width x height x bytes per pixel), i can get the raw data from the buffer and write them into a file through:
FILE* f = fopen("ImaqBuffer.txt", "a+");
for (i=0; i<bufSize; i++)fprintf(f, "%u ", ImaqBuffer[i]); # %u for unsigned char
09-30-2005 07:57 AM
hi,
i just found out, if i change the declaration of ImaqBuffer into:
static
unsigned char *ImaqBuffer = NULL;ImaqBuffer = (
unsigned char *) malloc(bufSize * sizeof (unsigned char));then i can get the reasonable pixel values with fprintf.
anyone from NI could explain this?
scott
10-05-2005 06:31 AM
hi all,
why do the pixel values in the image buffer, which is set by imgGrab(), use the BGRA model instead of RGBA ('A' stands for alpha) model ?
e.g. i get (23, 35, 55, 0) for a certain pixel, whose color is actually (55, 35, 23, 0) in RGBA. it's not that annoying if only a few pixels should be processed, but one can imagine for a large amount of pixels... to convert BGR to RGB is not hard, but quite inefficient for some online image processing.
10-06-2005 02:24 AM
Hi Scott,
I think now I´m understanding your question...you have got an image and want to extract the several color palets and then convert them into their raw data. T do this you should take first IMAQExtractColorPlans and then IMAQImageToArray. this functions are from CVI but they should be in Visual Studio C++ too. I hope this is answering your questions.
Rebecca Fox
National Isntruments, Germany
10-06-2005 03:12 AM
hi Rebecca,
thanks for your reply! actually i get raw data stored in a buffer through imgGrab() (defined in niimaq.h), and what i don't understand is that the raw data in the buffer, which are already color values of four channels, use BGRA format instead of the "more popular" RGBA.
btw, i don't find IMAQExtractColorPlans and IMAQImageToArray. I am developing applications based on the NI-IMAQ User Manual, and the only library i am using is imaq.lib (and the header file niimaq.h, which gives me all the functions i can use).
10-06-2005 03:53 AM