Class NamedWindow
Represents a window which can be used as placeholder for images and trackbars.
Namespace: OpenCV.Net
Assembly: OpenCV.Net.dll
Syntax
public sealed class NamedWindow : IDisposable
Constructors
| Improve this Doc View SourceNamedWindow(IntPtr)
Initializes a new instance of the NamedWindow class from the specified native window handle.
Declaration
public NamedWindow(IntPtr handle)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | handle | The platform specific native window handle used to retrieve the window name. |
NamedWindow(String, WindowFlags)
Initializes a new instance of the NamedWindow class with the specified name.
Declaration
public NamedWindow(string name, WindowFlags flags = default(WindowFlags))
Parameters
Type | Name | Description |
---|---|---|
String | name | The name of the window in the window caption. |
WindowFlags | flags | The flags of the window. |
Properties
| Improve this Doc View SourceHandle
Gets the platform specific native window handle.
Declaration
public IntPtr Handle { get; }
Property Value
Type | Description |
---|---|
IntPtr |
Name
Gets the name of the window.
Declaration
public string Name { get; }
Property Value
Type | Description |
---|---|
String |
Methods
| Improve this Doc View SourceCreateTrackbar(String, ref Int32, Int32, TrackbarCallback)
Creates a trackbar and attaches it to the window.
Declaration
public void CreateTrackbar(string trackbarName, ref int value, int count, TrackbarCallback onChanged = null)
Parameters
Type | Name | Description |
---|---|---|
String | trackbarName | Name of the created trackbar. |
Int32 | value | A reference to an integer value that specifies the position of the slider. |
Int32 | count | Maximal position of the slider. Minimal position is always 0. |
TrackbarCallback | onChanged | The callback method that will be called every time the slider changes position. |
DestroyAllWindows()
Destroys all of the HighGUI windows.
Declaration
public static void DestroyAllWindows()
DisplayOverlay(String, Int32)
Displays text on the window’s image as an overlay for delayMs
milliseconds.
This is not editing the image’s data. The text is displayed on the top of the image.
Declaration
public void DisplayOverlay(string text, int delayMs = 0)
Parameters
Type | Name | Description |
---|---|---|
String | text | Overlay text to write on the window’s image. |
Int32 | delayMs | Delay to display the overlay text. If this method is called before the previous overlay text times out, the timer is restarted and the text updated. If this value is zero, the text never disappears. |
DisplayStatusBar(String, Int32)
Displays text on the window’s status bar for delayMs
milliseconds.
Declaration
public void DisplayStatusBar(string text, int delayMs = 0)
Parameters
Type | Name | Description |
---|---|---|
String | text | Text to write on the window’s status bar. |
Int32 | delayMs | Delay to display the text. If this method is called before the previous text times out, the timer is restarted and the text updated. If this value is zero, the text never disappears. |
Dispose()
Releases all resources used by the NamedWindow.
Declaration
public void Dispose()
Finalize()
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
Declaration
protected void Finalize()
GetProperty(WindowProperty)
Gets the parameters of the window.
Declaration
public WindowFlags GetProperty(WindowProperty propId)
Parameters
Type | Name | Description |
---|---|---|
WindowProperty | propId | The identifier of the property to retrieve. |
Returns
Type | Description |
---|---|
WindowFlags | The value of the window property. |
GetTrackbarPos(String)
Returns the trackbar position.
Declaration
public int GetTrackbarPos(string trackbarName)
Parameters
Type | Name | Description |
---|---|---|
String | trackbarName | The name of the trackbar. |
Returns
Type | Description |
---|---|
Int32 | The current position of the specified trackbar. |
LoadWindowParameters()
Loads parameters of the window such as size, location, flags, etc.
Declaration
public void LoadWindowParameters()
Move(Int32, Int32)
Sets the position of the window.
Declaration
public void Move(int x, int y)
Parameters
Type | Name | Description |
---|---|---|
Int32 | x | The new x-coordinate of the top-left corner. |
Int32 | y | The new y-coordinate of the top-left corner. |
Resize(Int32, Int32)
Sets the window size.
Declaration
public void Resize(int width, int height)
Parameters
Type | Name | Description |
---|---|---|
Int32 | width | The new width. |
Int32 | height | The new height. |
SaveWindowParameters()
Saves parameters of the window such as size, location, flags, etc.
Declaration
public void SaveWindowParameters()
SetMouseCallback(MouseCallback)
Assigns a callback for mouse events.
Declaration
public void SetMouseCallback(MouseCallback onMouse)
Parameters
Type | Name | Description |
---|---|---|
MouseCallback | onMouse | The callback method that will handle mouse events of this named window. |
SetOpenGLContext()
Makes the GL context current. Used only for windows with OpenGL support.
Declaration
public void SetOpenGLContext()
SetOpenGLDrawCallback(OpenGLDrawCallback)
Assigns a callback to draw OpenGL on top of the image display. Used only for windows with OpenGL support.
Declaration
public void SetOpenGLDrawCallback(OpenGLDrawCallback callback)
Parameters
Type | Name | Description |
---|---|---|
OpenGLDrawCallback | callback | The callback method that will be called every frame. |
SetProperty(WindowProperty, WindowFlags)
Change the parameters of the window dynamically.
Declaration
public void SetProperty(WindowProperty propId, WindowFlags propValue)
Parameters
Type | Name | Description |
---|---|---|
WindowProperty | propId | The identifier of the property to edit. |
WindowFlags | propValue | The new value of the window property. |
SetTrackbarPos(String, Int32)
Sets the trackbar position.
Declaration
public void SetTrackbarPos(string trackbarName, int pos)
Parameters
Type | Name | Description |
---|---|---|
String | trackbarName | The name of the trackbar. |
Int32 | pos | The new trackbar position. |
ShowImage(Arr)
Displays the image in the specified window.
Declaration
public void ShowImage(Arr image)
Parameters
Type | Name | Description |
---|---|---|
Arr | image | The image to be shown. |
Update()
Updates the window. Used only for windows with OpenGL support.
Declaration
public void Update()