GetImageData
Top  Previous  Next

Description

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


Syntax


[VB]
Value=objActiveDcam.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()

ActiveDcam1.Display =
 False

ActiveDcam1.Acquire =
 True
End Sub


Private Sub ActiveDcam1_FrameAcquired()
a = ActiveDcam1.GetImageData

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

Next
Next

ActiveDcam1.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 ActiveDcam's image frame in VB.NET and C# use GetImagePointer.

Image in ActiveDcam 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, RGB24, Raw8 (Bayer on)
24-bit RGB
Byte
0 to SizeX * 3 - 1, 0 to Lines - 1
RGB48, Raw16 (Bayer on)
48-bit RGB
Integer (word)
0 to SizeX * 3 - 1, 0 to Lines - 1


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

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, subract them from 65535.

GetImageData may not work in some development environments such as Delphi or Matlab. In such a case use GetImageWindow instead.