03-12-2002 09:22 AM
03-13-2002 04:00 PM
03-25-2002 12:29 PM
03-25-2002 01:28 PM
01-04-2014 09:04 AM
Hi I have a similar problem. Im finding it impossible to get the array of image pixel data
Does anyone knwo how I can convert ImaqBuffer into a pixel array of short[]?
The source code examples have this kind of code;
ImaqBuffer = (Int8 *)malloc(320 * 256 * 2);
Int32 err = imgGrab (Sid, (void **)&ImaqBuffer, TRUE);
ImaqBuffer should contain the pixel data but it just seems to contain garbage.
Then the example code uses the function imgPlot2 to display the image.
imgPlot2 (ImaqSmplHwnd, ImaqBuffer, 0, 0, AcqWinWidth, AcqWinHeight,
CanvasLeft, CanvasTop, plotFlag);
But I dont want to use imgPlot2 i just want to read the pixel data and manipulate it. Ive spent hours trying to do this but with no success.
Note. I wanted to use the DotNet librarires but they throw an error because apparently I have an older version of the software somewhere in the bowels of my PC.
TIA
01-08-2014 08:00 AM
OK I tried looking at the example further up this thread but this hasnt helped. Its something similar to what I previously tried. Ive also tried searching the other boards but to no avail.
Our camera has a 320*256 pixel 14 bit image. I simply need to be able to access the data for each pixel. I honestly cannot believe how difficult this appears to be to do.Unfortunately the examples don't help at all. The ironic thing is there is a DOTNET sample that has an "ExtractedPixels" function that does what I want but it isn't supported for 64 bit Windows.
Any example C/C++ code anywhere that shows this?
HELP!!
01-09-2014 07:27 AM
Ive been looking at the llgrab.c (low level grab) example in the sample programs. This line copies the image from the camera into CopyBuffer which is a pointer to a pointer
errChk(imgSessionCopyBufferByNumber(Sid, currBufNum, CopyBuffer, IMG_OVERWRITE_GET_NEWEST, &actualCopiedBuffer, NULL));
Then the image is displayed using imgPlot2
errChk(imgPlot2 (ImaqSmplHwnd, CopyBuffer, 0, 0, AcqWinWidth, AcqWinHeight,
CanvasLeft, CanvasTop, plotFlag));
Does anyone know if &actualCopiedBuffer contains the actual pixel data of the image?
Ive tried the following to try and get access to the image data, however its throing an exception.
memcpy_s(myImage, sizeOfImage, actualCopiedBuffer, sizeOfImage);
where;
int sizeOfImage = 32- * 256 * 2;
WORD* myImage = (WORD*)malloc(sizeOfImage);
Is there anything obvious Im doing wrong here?
TIA
01-09-2014 07:30 AM
Sorry that should be;
Ive been looking at the llgrab.c (low level grab) example in the sample programs. This line copies the image from the camera into CopyBuffer which is a pointer to a pointer
errChk(imgSessionCopyBufferByNumber(Sid, currBufNum, CopyBuffer, IMG_OVERWRITE_GET_NEWEST, &actualCopiedBuffer, NULL));
Then the image is displayed using imgPlot2
errChk(imgPlot2 (ImaqSmplHwnd, CopyBuffer, 0, 0, AcqWinWidth, AcqWinHeight,
CanvasLeft, CanvasTop, plotFlag));
Does anyone know if &actualCopiedBuffer contains the actual pixel data of the image?
Ive tried the following to try and get access to the image data;
memcpy_s(myImage, sizeOfImage, actualCopiedBuffer, sizeOfImage);
where;
int sizeOfImage = 320 * 256 * 2;
WORD* myImage = (WORD*)malloc(sizeOfImage);
However the program is throwing an exception at my line "memcpy_s(myImage, sizeOfImage, actualCopiedBuffer, sizeOfImage);"
Is there anything obvious Im doing wrong here?
TIA
01-09-2014 08:24 AM
Im not sure whats happening in the above code. However Ive managed to find a solution. Ive set up a buffer ring and used the following to get an image
imgSessionExamineBuffer2 (gSessionID, gBufNum, &vCurrBufNum,(void**)&vBufAddr);
Now if I do this;
memcpy_s(myImage,sizeOfImage,vBufAddr,sizeOfimage);
I have all my pixel data in myImage!
01-11-2014 01:27 PM
None of your posts include the rest of your code, so it is hard to really understand what the problems you are encountering are from just the few lines posted. However, my best guess is that your code is interpreting your 14-bit data (strored by the framegrabber as 16-bit data) as 8-bit data, so that is why you are seeing garbage.
In your last snippet of code you posted, you are simply copying the data from the buffer in the IMAQ ring to a buffer you allocate. Since both buffers are the same size in bytes and you are copying one to the other, the only logical conclusion is that the difference in pointer type is why you see "good" data in one and "bad" data in the other. You could logically replace the memcpy with WORD* myImage = (WORD*)vBufAddr; and achieve the same result without copying the data. If you simply declared the pointer to be to 16-bit data in the first place you wouldn't need the cast even.
Eric