Class Window
- Namespace
- OpenCvSharp
- Assembly
- OpenCvSharp.dll
Wrapper of HighGUI window
public class Window : DisposableObject, IDisposable
- Inheritance
-
Window
- Implements
- Inherited Members
Constructors
Window()
Creates a window with a random name
public Window()
Window(string)
Creates a window
public Window(string name)
Parameters
namestringName of the window which is used as window identifier and appears in the window caption.
Window(string, Mat)
Creates a window
public Window(string name, Mat image)
Parameters
namestringName of the window which is used as window identifier and appears in the window caption.
imageMatImage to be shown.
Window(string, Mat?, WindowFlags)
Creates a window
public Window(string name, Mat? image = null, WindowFlags flags = WindowFlags.AutoSize)
Parameters
namestringName of the window which is used as window identifier and appears in the window caption.
imageMatImage to be shown.
flagsWindowFlagsFlags 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
public Window(string name, WindowFlags flags = WindowFlags.AutoSize)
Parameters
namestringName of the window which is used as window identifier and appears in the window caption.
flagsWindowFlagsFlags 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
Image
Gets or sets an image to be shown
public Mat? Image { get; set; }
Property Value
Name
Gets window name
public string Name { get; }
Property Value
Methods
Close()
Destroys this window.
public void Close()
CreateTrackbar(string, TrackbarCallback)
Creates the trackbar and attaches it to this window
public CvTrackbar CreateTrackbar(string trackbarName, TrackbarCallback callback)
Parameters
trackbarNamestringName of created trackbar.
callbackTrackbarCallbackthe function to be called every time the slider changes the position. This function should be prototyped as void Foo(int);
Returns
CreateTrackbar(string, int, int, TrackbarCallback)
Creates the trackbar and attaches it to this window
public CvTrackbar CreateTrackbar(string trackbarName, int initialPos, int max, TrackbarCallback callback)
Parameters
trackbarNamestringName of created trackbar.
initialPosintThe position of the slider
maxintMaximal position of the slider. Minimal position is always 0.
callbackTrackbarCallbackthe function to be called every time the slider changes the position. This function should be prototyped as void Foo(int);
Returns
DestroyAllWindows()
Destroys all the opened HighGUI windows.
public static void DestroyAllWindows()
DisplayOverlay(string, int)
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.
public void DisplayOverlay(string text, int delayMs)
Parameters
textstringOverlay text to write on the window’s image
delayMsintDelay 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, int)
public void DisplayStatusBar(string text, int delayms)
Parameters
textstringText to write on the window’s statusbar
delaymsintDelay 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
protected override void DisposeManaged()
GetHandle()
get native window handle (HWND in case of Win32 and Widget in case of X Window)
public nint GetHandle()
Returns
GetProperty(WindowPropertyFlags)
Get Property of the window
public double GetProperty(WindowPropertyFlags propId)
Parameters
propIdWindowPropertyFlagsProperty identifier
Returns
- double
Value of the specified property
GetWindowByName(string)
Retrieves a created window by name
public static Window? GetWindowByName(string name)
Parameters
namestring
Returns
Move(int, int)
Sets window position
public void Move(int x, int y)
Parameters
Resize(int, int)
Sets window size
public void Resize(int width, int height)
Parameters
SetMouseCallback(MouseCallback, nint)
Sets the callback function for mouse events occuting within the specified window.
public void SetMouseCallback(MouseCallback onMouse, nint userData = 0)
Parameters
onMouseMouseCallbackReference to the function to be called every time mouse event occurs in the specified window.
userDatanint
SetProperty(WindowPropertyFlags, double)
Set Property of the window
public void SetProperty(WindowPropertyFlags propId, double propValue)
Parameters
propIdWindowPropertyFlagsProperty identifier
propValuedoubleNew value of the specified property
ShowImage(Mat?)
Shows the image in this window
public void ShowImage(Mat? img)
Parameters
imgMatImage to be shown.
ShowImage(UMat?)
Shows the image in this window
public void ShowImage(UMat? img)
Parameters
imgUMatImage to be shown.
ShowImages(params Mat[])
public static void ShowImages(params Mat[] images)
Parameters
imagesMat[]
ShowImages(IEnumerable<Mat>, IEnumerable<string>)
public static void ShowImages(IEnumerable<Mat> images, IEnumerable<string> names)
Parameters
imagesIEnumerable<Mat>namesIEnumerable<string>
WaitKey(int)
Waits for a pressed key
public static int WaitKey(int delay = 0)
Parameters
delayintDelay in milliseconds.
Returns
- int
Key code
WaitKeyEx(int)
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
public static int WaitKeyEx(int delay = 0)
Parameters
delayintDelay in milliseconds. 0 is the special value that means ”forever”
Returns
- int
Returns the code of the pressed key or -1 if no key was pressed before the specified time had elapsed.