Table of Contents

Class OpenCvSafeHandle

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

Base class for SafeHandle instances wrapping native OpenCV pointers. Provides a common SafeHandle implementation where IntPtr.Zero is the invalid handle value.

public abstract class OpenCvSafeHandle : SafeHandle, IDisposable
Inheritance
OpenCvSafeHandle
Implements
Derived
Inherited Members

Constructors

OpenCvSafeHandle()

Initializes a new instance of the OpenCvSafeHandle class that owns the handle.

protected OpenCvSafeHandle()

OpenCvSafeHandle(bool)

Initializes a new instance of the OpenCvSafeHandle class.

protected OpenCvSafeHandle(bool ownsHandle)

Parameters

ownsHandle bool

true if this instance owns the handle and should release it on disposal; false for a borrowed (non-owning) wrapper around an existing pointer.

OpenCvSafeHandle(nint, bool)

Initializes a new instance of the OpenCvSafeHandle class with an existing handle.

protected OpenCvSafeHandle(nint existingHandle, bool ownsHandle)

Parameters

existingHandle nint

The pre-existing native pointer to wrap.

ownsHandle bool

true if this instance owns the handle and should release it on disposal; false for a borrowed (non-owning) wrapper.

Properties

IsInvalid

When overridden in a derived class, gets a value indicating whether the handle value is invalid.

public override bool IsInvalid { get; }

Property Value

bool

true if the handle value is invalid; otherwise, false.

Null

A non-owning handle wrapping a null native pointer. Pass this for an optional SafeHandle-typed P/Invoke argument (e.g. a mask) when the caller has none, instead of overloading the parameter type with a plain nint.

public static OpenCvSafeHandle Null { get; }

Property Value

OpenCvSafeHandle