GetImagePointer
Top  Previous  Next

Description

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


Syntax


[VB]
Value=objActiveUSB.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 CActiveUSB is used to access the ActiveUSB control:

BYTE line[4096];
int iWidth=m_ActiveUSB.GetSizeX;
int iHeight=m_ActiveUSB.GetSizeY;
m_ActiveUSB.Grab()
VARIANT v=m_ActiveUSB.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
 axActiveUSB1_FrameAcquired(object
 sender, AxActiveUSBLib._IActiveUSBEvents_FrameAcquiredEvent e)
{
int
 sx=axActiveUSB1.SizeX;
int
 sy=axActiveUSB1.SizeY;
object
 obj=axActiveUSB1.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 ActiveUSB 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.