Table of Contents

Class CvObject

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

DisposableObject + ICvPtrHolder

public abstract class CvObject : DisposableObject, IDisposable
Inheritance
CvObject
Implements
Derived
Inherited Members

Constructors

CvObject()

Default constructor

protected CvObject()

CvObject(OpenCvSafeHandle)

Constructor that accepts an OpenCvSafeHandle. The SafeHandle owns the native resource and will release it on disposal.

protected CvObject(OpenCvSafeHandle safeHandle)

Parameters

safeHandle OpenCvSafeHandle

The safe handle wrapping the native pointer.

CvObject(bool)

Constructor

protected CvObject(bool isEnabledDispose)

Parameters

isEnabledDispose bool

CvObject(nint)

Constructor (backward compatibility). Wraps the pointer in a non-owning SafeHandle. Derived classes that own the native resource should call SetSafeHandle(OpenCvSafeHandle) to replace it with an owning handle.

protected CvObject(nint ptr)

Parameters

ptr nint

CvObject(nint, bool)

Constructor (backward compatibility). Wraps the pointer in a non-owning SafeHandle so that the ptr property returns the correct value.

protected CvObject(nint ptr, bool isEnabledDispose)

Parameters

ptr nint
isEnabledDispose bool

Properties

CvPtr

Native pointer of OpenCV structure

public nint CvPtr { get; }

Property Value

nint

ptr

Native data pointer, derived from OpenCvSharp.CvObject.safeHandle. Returns Zero when no SafeHandle has been set.

protected nint ptr { get; }

Property Value

nint

Methods

DisposeManaged()

Releases managed resources, including the SafeHandle if present.

protected override void DisposeManaged()

DisposeUnmanaged()

Releases unmanaged resources. Nulls out the SafeHandle so that ptr returns Zero after disposal, matching the behaviour of the former ptr = IntPtr.Zero pattern and providing defence-in-depth against use-after-dispose.

protected override void DisposeUnmanaged()

SetSafeHandle(OpenCvSafeHandle)

Sets or replaces the internal SafeHandle. The ptr property will reflect the new handle's value.

protected void SetSafeHandle(OpenCvSafeHandle handle)

Parameters

handle OpenCvSafeHandle

The safe handle wrapping the native pointer.