Class Window
Wrapper of HighGUI window
Inherited Members
Namespace: OpenCvSharp
Assembly: OpenCvSharp.dll
Syntax
public class Window : DisposableObject
Constructors
| Improve this Doc View SourceWindow()
Creates a window with a random name
Declaration
public Window()
Window(String)
Creates a window
Declaration
public Window(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the window which is used as window identifier and appears in the window caption. |
Window(String, Mat)
Creates a window
Declaration
public Window(string name, Mat image)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the window which is used as window identifier and appears in the window caption. |
Mat | image | Image to be shown. |
Window(String, Mat, WindowFlags)
Creates a window
Declaration
public Window(string name, Mat image = null, WindowFlags flags = WindowFlags.AutoSize)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the window which is used as window identifier and appears in the window caption. |
Mat | image | Image to be shown. |
WindowFlags | flags | Flags of the window. Currently the only supported flag is WindowMode.AutoSize. If it is set, window size is automatically adjusted to fit the displayed image (see cvShowImage), while user can not change the window size manually. |
Window(String, WindowFlags)
Creates a window
Declaration
public Window(string name, WindowFlags flags = WindowFlags.AutoSize)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the window which is used as window identifier and appears in the window caption. |
WindowFlags | flags | Flags of the window. Currently the only supported flag is WindowMode.AutoSize. If it is set, window size is automatically adjusted to fit the displayed image (see cvShowImage), while user can not change the window size manually. |
Properties
| Improve this Doc View SourceImage
Gets or sets an image to be shown
Declaration
public Mat Image { get; set; }
Property Value
Type | Description |
---|---|
Mat |
Name
Gets window name
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
System.String |
Methods
| Improve this Doc View SourceClose()
Destroys this window.
Declaration
public void Close()
CreateTrackbar(String, TrackbarCallback)
Creates the trackbar and attaches it to this window
Declaration
public CvTrackbar CreateTrackbar(string trackbarName, TrackbarCallback callback)
Parameters
Type | Name | Description |
---|---|---|
System.String | trackbarName | Name of created trackbar. |
TrackbarCallback | callback | the function to be called every time the slider changes the position. This function should be prototyped as void Foo(int); |
Returns
Type | Description |
---|---|
CvTrackbar |
CreateTrackbar(String, Int32, Int32, TrackbarCallback)
Creates the trackbar and attaches it to this window
Declaration
public CvTrackbar CreateTrackbar(string trackbarName, int initialPos, int max, TrackbarCallback callback)
Parameters
Type | Name | Description |
---|---|---|
System.String | trackbarName | Name of created trackbar. |
System.Int32 | initialPos | The position of the slider |
System.Int32 | max | Maximal position of the slider. Minimal position is always 0. |
TrackbarCallback | callback | the function to be called every time the slider changes the position. This function should be prototyped as void Foo(int); |
Returns
Type | Description |
---|---|
CvTrackbar |
DestroyAllWindows()
Destroys all the opened HighGUI windows.
Declaration
public static void DestroyAllWindows()
DisplayOverlay(String, Int32)
Display text on the window's image as an overlay for delay milliseconds. This is not editing the image's data. The text is display on the top of the image.
Declaration
public void DisplayOverlay(string text, int delayMs)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Overlay text to write on the window’s image |
System.Int32 | delayMs | Delay to display the overlay text. If this function is called before the previous overlay text time out, the timer is restarted and the text updated. If this value is zero, the text never disappears. |
DisplayStatusBar(String, Int32)
Declaration
public void DisplayStatusBar(string text, int delayms)
Parameters
Type | Name | Description |
---|---|---|
System.String | text | Text to write on the window’s statusbar |
System.Int32 | delayms | Delay to display the text. If this function is called before the previous text time out, the timer is restarted and the text updated. If this value is zero, the text never disapers. |
DisposeManaged()
Releases managed resources
Declaration
protected override void DisposeManaged()
Overrides
| Improve this Doc View SourceGetHandle()
get native window handle (HWND in case of Win32 and Widget in case of X Window)
Declaration
public IntPtr GetHandle()
Returns
Type | Description |
---|---|
IntPtr |
GetProperty(WindowPropertyFlags)
Get Property of the window
Declaration
public double GetProperty(WindowPropertyFlags propId)
Parameters
Type | Name | Description |
---|---|---|
WindowPropertyFlags | propId | Property identifier |
Returns
Type | Description |
---|---|
System.Double | Value of the specified property |
GetWindowByName(String)
Retrieves a created window by name
Declaration
public static Window GetWindowByName(string name)
Parameters
Type | Name | Description |
---|---|---|
System.String | name |
Returns
Type | Description |
---|---|
Window |
Move(Int32, Int32)
Sets window position
Declaration
public void Move(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | x | New x coordinate of top-left corner |
System.Int32 | y | New y coordinate of top-left corner |
Resize(Int32, Int32)
Sets window size
Declaration
public void Resize(int width, int height)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | width | New width |
System.Int32 | height | New height |
SetMouseCallback(MouseCallback, IntPtr)
Sets the callback function for mouse events occuting within the specified window.
Declaration
public void SetMouseCallback(MouseCallback onMouse, IntPtr userData = null)
Parameters
Type | Name | Description |
---|---|---|
MouseCallback | onMouse | Reference to the function to be called every time mouse event occurs in the specified window. |
IntPtr | userData |
SetProperty(WindowPropertyFlags, Double)
Set Property of the window
Declaration
public void SetProperty(WindowPropertyFlags propId, double propValue)
Parameters
Type | Name | Description |
---|---|---|
WindowPropertyFlags | propId | Property identifier |
System.Double | propValue | New value of the specified property |
ShowImage(Mat)
Shows the image in this window
Declaration
public void ShowImage(Mat img)
Parameters
Type | Name | Description |
---|---|---|
Mat | img | Image to be shown. |
ShowImage(UMat)
Shows the image in this window
Declaration
public void ShowImage(UMat img)
Parameters
Type | Name | Description |
---|---|---|
UMat | img | Image to be shown. |
ShowImages(IEnumerable<Mat>, IEnumerable<String>)
Declaration
public static void ShowImages(IEnumerable<Mat> images, IEnumerable<string> names)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Mat> | images | |
IEnumerable<System.String> | names |
ShowImages(Mat[])
Declaration
public static void ShowImages(params Mat[] images)
Parameters
Type | Name | Description |
---|---|---|
Mat[] | images |
WaitKey(Int32)
Waits for a pressed key
Declaration
public static int WaitKey(int delay = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | delay | Delay in milliseconds. |
Returns
Type | Description |
---|---|
System.Int32 | Key code |
WaitKeyEx(Int32)
Waits for a pressed key. Similar to #waitKey, but returns full key code. Key code is implementation specific and depends on used backend: QT/GTK/Win32/etc
Declaration
public static int WaitKeyEx(int delay = 0)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | delay | Delay in milliseconds. 0 is the special value that means ”forever” |
Returns
Type | Description |
---|---|
System.Int32 | Returns the code of the pressed key or -1 if no key was pressed before the specified time had elapsed. |