GetImagePointer
Top  Previous  Next

Description

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


Syntax


[VB]
Value=objActiveDcam.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 contating 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 CActiveDcam is used to access the ActiveDcam control:

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

BYTE* ptr=ActiveDcam1.GetImagePointer(0,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
 axActiveDcam1_FrameAcquired(object
 sender, AxACTIVEDCAMLib._IActiveDcamEvents_FrameAcquiredEvent e)
{
int
 sx=axActiveDcam1.SizeX;
object
 obj=axActiveDcam1.GetImagePointer(0, iHeight-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:

Format
Line width in bytes

8-bit monochrome
SizeX
16-bit monochrome
SizeX * 2
24-bit RGB
SizeX * 3
48-bit RGB
SizeX * 6


Note that ActiveDcam automatically converts YUV video outputed by a camera to 24-bit RGB.

Images in ActiveDcam 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.