GetImagePointer
Top  Previous  Next

Description

Returns the pointer to the pixel at the specified coordinates of the current frame.


Syntax


[VB]
Value=objActiveGige.GetImagePointer( X, Y )


[C/C++]
HRESULT GetImagePointer( short X, short Y, VARIANT* pValue );


Data Types
[VB]

X: Integer
Y: Integer
Return value: Variant (pointer)


Parameters
[C/C++]

X [in]  
The x-coordinate of the pixel  
Y [in]  
The y-coordinate of the pixel  
pValue [out,retval]  
Pointer to the variant containing the pointer to the specified memory location  


Return Values


S_OK  
Success  
E_FAIL  
Failure.  
E_INVALIDARG  
Invalid input arguments.  


Example


This C++ example grabs a frame, retrieves a pointer to the 32th line in the frame memory and copies the pixels values into a byte array . A wrapper class CActiveGige is used to access the ActiveGige control:

BYTE line[4096];
int iWidth=m_ActiveGige.GetSizeX();
int iHeight=m_ActiveGige.GetSizeY();
m_ActiveGige.Grab()
VARIANT v=m_ActiveGige.Get
Image
Pointer(0,
iHeight-1-32
);

memcpy(
&line
,v.pcVal,iWidth);

 
This C# example uses the FrameAcquired event to retrieve a pointer to the 32th line in the frame memory and change pixel values in the line to zeros:

private
 void
 axActiveGige1_FrameAcquired(object
 sender, AxACTIVEGIGELib._IActiveGigeEvents_FrameAcquiredEvent e)
{
int
 sx=axActiveGige1.SizeX;
int
 sy=axActiveGige1.SizeY;
object
 obj=axActiveGige1.GetImagePointer(0, sy-1-32);
int
 a = (int)obj;
byte
* ptr= (byte*)a;
for (int x=0; x<sx; x++, ptr++)
 *ptr=0;
}
 

Remarks


The GetImagePointer method provides the most efficient way to quickly access the internal image buffer in pointer-aware programming languages. Unlike GetImageData, this method doesn't modify original pixel values of high-bit depth images. The number of bytes in each line of the image buffer depends on the format and horizontal size of the video as specified in the following table:

Camera Pixel Format
Output Format
Line width in bytes

Mono8
8-bit monochrome
SizeX
Mono10, Mono12, Mono16
16-bit monochrome
SizeX * 2
YUV411, YUV422, YUV444, RGB8, BGR8, Bayer8
24-bit RGB
SizeX * 3
RGB10, RGB12, RGB16, BGR10, BGR12, Bayer10, Bayer12, Bayer16
48-bit RGB
SizeX * 6


Images in ActiveGige are stored bottom up, therefore the zero vertical coordinate corresponds to the bottom line of the image.

The values of the x and y coordinates must not exceed the width and height of the video frame, or the error will occur.

Note that if images are transmitted by a linescan camera, the number of lines in each image can vary and be less than the vertical size of the image frame defined by the SizeY property. See GetHeight for more details.