GetImageData
Top  Previous  Next

Description

Returns the two-dimensional array of pixel values in the currently acquired frame.


Syntax


[VB]
Value=objActiveGeni.GetImageData


[C/C++]
HRESULT GetImageData( VARIANT* pArray );


Data Types
[VB]

Return value: Variant (SAFEARRAY)


Parameters
[C/C++]

pArray [out,retval]  
Pointer to the SAFEARRAY containing the pixel values in the frame  


Return Values


S_OK  
Success  
E_FAIL  
Failure.  


Example


This VB example uses the FrameAcquired event to invert pixel value in the bottom left corner of the current frame and display the processed frame in real time.

Private Sub
 Form_Load()

ActiveGeni1.Display =
 False

ActiveGeni1.Acquire =
 True
End Sub


Private Sub ActiveGeni1_FrameAcquired()
a = ActiveGeni1.GetImageData

For
 x = 0 To 200
For
 y = 0 To 200
a(x, y) = 255 - a(x, y)

Next
Next

ActiveGeni1.Draw

End Sub

 

Remarks


GetImageData does not copy the image data, so the array returned contains the actual image buffer of the currently acquired frame. Modifying elements of the array will change actual pixel values in the image buffer. This can be used to perform custom image processing and display a processed image in real time. Note that this feature cannot be used in .NET as its framework creates a copy of the array returned. For direct access to ActiveGeni's image frame in VB.NET and C# use GetImagePointer.

Images in ActiveGeni are stored bottom up, therefore the first element of the array is first pixel of the bottom line of the image. The type of data and dimensions of the array returned by GetImageData depends on the output format of the video, its horizontal width SizeX and the number of lines acquired, as specified in the following table:



Camera Pixel Format
Output Format
Data type
Dimensions

Mono8
8-bit monochrome
Byte
0 to SizeX -1, 0 to Lines - 1
Mono10, Mono12, Mono16
16-bit gray monochrome
Integer (word)
0 to SizeX -1, 0 to Lines - 1
YUV411, YUV422, YUV444, RGB8, BGR8, Bayer8
24-bit RGB
Byte
0 to SizeX * 3 - 1, 0 to Lines - 1
RGB10, RGB12, RGB16, BGR10, BGR12, Bayer10, Bayer12, Bayer16
48-bit RGB
Integer (word)
0 to SizeX * 3 - 1, 0 to Lines - 1


For integer (word) type of data you can receive negative numbers if pixel values exceed 32767. In C and C# you can convert signed integers to unsigned ones by using data casting. To get rid of negative values in VB and Delphi, subtract them from 65535.