GetImageWindow
Top  Previous  Next

Description

Returns the two-dimensional array of pixel values corresponding to the selected window in the currently acquired frame.


Syntax


[VB]
Value=objActiveUSB.GetImageWindow (X, Y, Width, Height)


[C/C++]
HRESULT GetImageWindow( short X, short Y, short Width, short Height, VARIANT* pArray );


Data Types
[VB]

X,Y, Width, Height: Integer
Return value
: Variant (SAFEARRAY)


Parameters
[C/C++]
 
X [in], Y[in]  
The x- and y-coordinates of the top left pixel of the window in the entire frame  
Width [in], Height [in]  
The horizontal and vertical size of the window in pixels.  
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 increase the brightness in the central area of the live image:

Private Sub
 Form_Load()

ActiveUSB1.Display = 
False

ActiveUSB1.Acquire = 
True

End Sub

 
Private Sub
 ActiveUSB1_FrameAcquired()

xc = ActiveUSB1.SizeX / 2
yc = ActiveUSB1.SizeY / 2
w = ActiveUSB1.GetImageWindow(xc - 70, yc - 50, 140, 100)

For
 y = 0 To UBound(w, 2)
For
 x = 0 To UBound(w, 1)
pix = w(x, y) + 50

If
 pix > 255 Then
pix = 255

End If

w(x, y) = pix

Next
Next

ActiveUSB1.SetImageWindow xc - 70, yc - 50, w
ActiveUSB1.Draw

End Sub

 

Remarks


The image data in the array are stored in the standard order from top to bottom, therefore the first element of the array is the top left pixel of the window. This is opposite to the order of rows in the arrays returned by GetImageData. The type of data and dimensions of the array returned by GetImageWindow depends on the output format of the video, the width and height of the window 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


If the dimensions of the window are too large to accommodate the frame size, they will be clipped to the frame boundaries.

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.

Note that modifying elements of the array will not change actual pixel values in the frame buffer. Use SetImageWindow to transfer pixel values into ActiveUSB.

Note that in C/C++ applications it is required to call SafeArrayDestroy() to delete the SAFEARRAY returned by GetImageWindow.