Table of Contents

Class ImageCollection

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

Reads multi-page images on demand. Decodes pages lazily as they are accessed. Performance of page decoding is O(1) when the collection is accessed sequentially; accessing a page out of order is O(n) because the underlying reader has to restart from the beginning. Decoded pages are cached; call ReleaseCache(int) to free a decoded page's memory.

public class ImageCollection : CvObject, IDisposable, IEnumerable<Mat>, IEnumerable
Inheritance
ImageCollection
Implements
Inherited Members

Constructors

ImageCollection()

Creates an empty ImageCollection. Call Init(string, ImreadModes) before use.

public ImageCollection()

ImageCollection(string, ImreadModes)

Creates an ImageCollection over the multi-page image file at the given path.

public ImageCollection(string filename, ImreadModes flags = ImreadModes.Color)

Parameters

filename string

Name of file to be loaded.

flags ImreadModes

Flag that can take values of @ref cv::ImreadModes.

Properties

this[int]

Decodes and returns the page at the given index. Each call returns a freshly-copied Mat header that the caller owns and is responsible for disposing.

public Mat this[int index] { get; }

Parameters

index int

Zero-based page index.

Property Value

Mat

Size

Number of pages in the collection.

public long Size { get; }

Property Value

long

Methods

At(int)

Decodes and returns the page at the given index. Each call returns a freshly-copied Mat header that the caller owns and is responsible for disposing.

public Mat At(int index)

Parameters

index int

Zero-based page index.

Returns

Mat

GetEnumerator()

Enumerates the pages of the collection in order (index 0, 1, 2, ...). Each yielded Mat is owned by the caller, which is responsible for disposing it (e.g. wrap the loop body in a using statement).

public IEnumerator<Mat> GetEnumerator()

Returns

IEnumerator<Mat>

Init(string, ImreadModes)

(Re-)initializes this collection over the multi-page image file at the given path.

public void Init(string filename, ImreadModes flags = ImreadModes.Color)

Parameters

filename string

Name of file to be loaded.

flags ImreadModes

Flag that can take values of @ref cv::ImreadModes.

ReleaseCache(int)

Releases the cached decoded page at the given index.

public void ReleaseCache(int index)

Parameters

index int

Zero-based page index.