Show / Hide Table of Contents

Class Window

Wrapper of HighGUI window

Inheritance
System.Object
DisposableObject
Window
Inherited Members
DisposableObject.DataHandle
DisposableObject.IsDisposed
DisposableObject.IsEnabledDispose
DisposableObject.AllocatedMemory
DisposableObject.AllocatedMemorySize
DisposableObject.Dispose()
DisposableObject.Dispose(Boolean)
DisposableObject.DisposeUnmanaged()
DisposableObject.AllocGCHandle(Object)
DisposableObject.AllocMemory(Int32)
DisposableObject.NotifyMemoryPressure(Int64)
DisposableObject.ThrowIfDisposed()
Namespace: OpenCvSharp
Assembly: OpenCvSharp.dll
Syntax
public class Window : DisposableObject

Constructors

| Improve this Doc View Source

Window()

Creates a window with a random name

Declaration
public Window()
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

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 Source

Image

Gets or sets an image to be shown

Declaration
public Mat Image { get; set; }
Property Value
Type Description
Mat
| Improve this Doc View Source

Name

Gets window name

Declaration
public string Name { get; }
Property Value
Type Description
System.String

Methods

| Improve this Doc View Source

Close()

Destroys this window.

Declaration
public void Close()
| Improve this Doc View Source

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
| Improve this Doc View Source

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
| Improve this Doc View Source

DestroyAllWindows()

Destroys all the opened HighGUI windows.

Declaration
public static void DestroyAllWindows()
| Improve this Doc View Source

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.

| Improve this Doc View Source

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.

| Improve this Doc View Source

DisposeManaged()

Releases managed resources

Declaration
protected override void DisposeManaged()
Overrides
DisposableObject.DisposeManaged()
| Improve this Doc View Source

GetHandle()

get native window handle (HWND in case of Win32 and Widget in case of X Window)

Declaration
public IntPtr GetHandle()
Returns
Type Description
IntPtr
| Improve this Doc View Source

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

| Improve this Doc View Source

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
| Improve this Doc View Source

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

| Improve this Doc View Source

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

| Improve this Doc View Source

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
| Improve this Doc View Source

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

| Improve this Doc View Source

ShowImage(Mat)

Shows the image in this window

Declaration
public void ShowImage(Mat img)
Parameters
Type Name Description
Mat img

Image to be shown.

| Improve this Doc View Source

ShowImage(UMat)

Shows the image in this window

Declaration
public void ShowImage(UMat img)
Parameters
Type Name Description
UMat img

Image to be shown.

| Improve this Doc View Source

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
| Improve this Doc View Source

ShowImages(Mat[])

Declaration
public static void ShowImages(params Mat[] images)
Parameters
Type Name Description
Mat[] images
| Improve this Doc View Source

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

| Improve this Doc View Source

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.

  • Improve this Doc
  • View Source
In This Article
Back to top Generated by DocFX