Table of Contents

Class FileStorage

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

XML/YAML File Storage Class.

public class FileStorage : DisposableCvObject, IDisposable, ICvPtrHolder
Inheritance
FileStorage
Implements
Inherited Members

Constructors

FileStorage()

Default constructor. You should call FileStorage::open() after initialization.

public FileStorage()

FileStorage(string, Modes, string?)

The full constructor

public FileStorage(string source, FileStorage.Modes flags, string? encoding = null)

Parameters

source string

Name of the file to open or the text string to read the data from. Extension of the file (.xml or .yml/.yaml) determines its format (XML or YAML respectively). Also you can append .gz to work with compressed files, for example myHugeMatrix.xml.gz. If both FileStorage::WRITE and FileStorage::MEMORY flags are specified, source is used just to specify the output file format (e.g. mydata.xml, .yml etc.).

flags FileStorage.Modes
encoding string

Encoding of the file. Note that UTF-16 XML encoding is not supported currently and you should use 8-bit encoding instead of it.

Properties

ElName

the currently written element

public string ElName { get; }

Property Value

string

this[string]

Returns the specified element of the top-level mapping

public FileNode? this[string nodeName] { get; }

Parameters

nodeName string

Property Value

FileNode

State

the writer state

public FileStorage.States State { get; }

Property Value

FileStorage.States

Methods

Add(DMatch)

Writes data to a file storage.

public FileStorage Add(DMatch val)

Parameters

val DMatch

Returns

FileStorage

Add(KeyPoint)

Writes data to a file storage.

public FileStorage Add(KeyPoint val)

Parameters

val KeyPoint

Returns

FileStorage

Add(Mat)

Writes data to a file storage.

public FileStorage Add(Mat val)

Parameters

val Mat

Returns

FileStorage

Add(Point)

/Writes data to a file storage.

public FileStorage Add(Point val)

Parameters

val Point

Returns

FileStorage

Add(Point2d)

Writes data to a file storage.

public FileStorage Add(Point2d val)

Parameters

val Point2d

Returns

FileStorage

Add(Point2f)

Writes data to a file storage.

public FileStorage Add(Point2f val)

Parameters

val Point2f

Returns

FileStorage

Add(Point3d)

Writes data to a file storage.

public FileStorage Add(Point3d val)

Parameters

val Point3d

Returns

FileStorage

Add(Point3f)

Writes data to a file storage.

public FileStorage Add(Point3f val)

Parameters

val Point3f

Returns

FileStorage

Add(Point3i)

Writes data to a file storage.

public FileStorage Add(Point3i val)

Parameters

val Point3i

Returns

FileStorage

Add(Range)

Writes data to a file storage.

public FileStorage Add(Range val)

Parameters

val Range

Returns

FileStorage

Add(Rect)

Writes data to a file storage.

public FileStorage Add(Rect val)

Parameters

val Rect

Returns

FileStorage

Add(Rect2d)

Writes data to a file storage.

public FileStorage Add(Rect2d val)

Parameters

val Rect2d

Returns

FileStorage

Add(Rect2f)

Writes data to a file storage.

public FileStorage Add(Rect2f val)

Parameters

val Rect2f

Returns

FileStorage

Add(Scalar)

Writes data to a file storage.

public FileStorage Add(Scalar val)

Parameters

val Scalar

Returns

FileStorage

Add(Size)

Writes data to a file storage.

public FileStorage Add(Size val)

Parameters

val Size

Returns

FileStorage

Add(Size2d)

Writes data to a file storage.

public FileStorage Add(Size2d val)

Parameters

val Size2d

Returns

FileStorage

Add(Size2f)

Writes data to a file storage.

public FileStorage Add(Size2f val)

Parameters

val Size2f

Returns

FileStorage

Add(SparseMat)

Writes data to a file storage.

public FileStorage Add(SparseMat val)

Parameters

val SparseMat

Returns

FileStorage

Add(Vec2b)

Writes data to a file storage.

public FileStorage Add(Vec2b val)

Parameters

val Vec2b

Returns

FileStorage

Add(Vec2d)

Writes data to a file storage.

public FileStorage Add(Vec2d val)

Parameters

val Vec2d

Returns

FileStorage

Add(Vec2f)

Writes data to a file storage.

public FileStorage Add(Vec2f val)

Parameters

val Vec2f

Returns

FileStorage

Add(Vec2i)

Writes data to a file storage.

public FileStorage Add(Vec2i val)

Parameters

val Vec2i

Returns

FileStorage

Add(Vec2s)

Writes data to a file storage.

public FileStorage Add(Vec2s val)

Parameters

val Vec2s

Returns

FileStorage

Add(Vec2w)

Writes data to a file storage.

public FileStorage Add(Vec2w val)

Parameters

val Vec2w

Returns

FileStorage

Add(Vec3b)

Writes data to a file storage.

public FileStorage Add(Vec3b val)

Parameters

val Vec3b

Returns

FileStorage

Add(Vec3d)

Writes data to a file storage.

public FileStorage Add(Vec3d val)

Parameters

val Vec3d

Returns

FileStorage

Add(Vec3f)

Writes data to a file storage.

public FileStorage Add(Vec3f val)

Parameters

val Vec3f

Returns

FileStorage

Add(Vec3i)

Writes data to a file storage.

public FileStorage Add(Vec3i val)

Parameters

val Vec3i

Returns

FileStorage

Add(Vec3s)

Writes data to a file storage.

public FileStorage Add(Vec3s val)

Parameters

val Vec3s

Returns

FileStorage

Add(Vec3w)

Writes data to a file storage.

public FileStorage Add(Vec3w val)

Parameters

val Vec3w

Returns

FileStorage

Add(Vec4b)

Writes data to a file storage.

public FileStorage Add(Vec4b val)

Parameters

val Vec4b

Returns

FileStorage

Add(Vec4d)

Writes data to a file storage.

public FileStorage Add(Vec4d val)

Parameters

val Vec4d

Returns

FileStorage

Add(Vec4f)

Writes data to a file storage.

public FileStorage Add(Vec4f val)

Parameters

val Vec4f

Returns

FileStorage

Add(Vec4i)

Writes data to a file storage.

public FileStorage Add(Vec4i val)

Parameters

val Vec4i

Returns

FileStorage

Add(Vec4s)

Writes data to a file storage.

public FileStorage Add(Vec4s val)

Parameters

val Vec4s

Returns

FileStorage

Add(Vec4w)

Writes data to a file storage.

public FileStorage Add(Vec4w val)

Parameters

val Vec4w

Returns

FileStorage

Add(Vec6b)

Writes data to a file storage.

public FileStorage Add(Vec6b val)

Parameters

val Vec6b

Returns

FileStorage

Add(Vec6d)

Writes data to a file storage.

public FileStorage Add(Vec6d val)

Parameters

val Vec6d

Returns

FileStorage

Add(Vec6f)

Writes data to a file storage.

public FileStorage Add(Vec6f val)

Parameters

val Vec6f

Returns

FileStorage

Add(Vec6i)

Writes data to a file storage.

public FileStorage Add(Vec6i val)

Parameters

val Vec6i

Returns

FileStorage

Add(Vec6s)

Writes data to a file storage.

public FileStorage Add(Vec6s val)

Parameters

val Vec6s

Returns

FileStorage

Add(Vec6w)

Writes data to a file storage.

public FileStorage Add(Vec6w val)

Parameters

val Vec6w

Returns

FileStorage

Add(IEnumerable<DMatch>)

Writes data to a file storage.

public FileStorage Add(IEnumerable<DMatch> val)

Parameters

val IEnumerable<DMatch>

Returns

FileStorage

Add(IEnumerable<KeyPoint>)

Writes data to a file storage.

public FileStorage Add(IEnumerable<KeyPoint> val)

Parameters

val IEnumerable<KeyPoint>

Returns

FileStorage

Add(double)

Writes data to a file storage.

public FileStorage Add(double val)

Parameters

val double

Returns

FileStorage

Add(int)

Writes data to a file storage.

public FileStorage Add(int val)

Parameters

val int

Returns

FileStorage

Add(float)

Writes data to a file storage.

public FileStorage Add(float val)

Parameters

val float

Returns

FileStorage

Add(string)

Writes data to a file storage.

public FileStorage Add(string val)

Parameters

val string

Returns

FileStorage

DisposeUnmanaged()

Releases unmanaged resources

protected override void DisposeUnmanaged()

EndWriteStruct()

public void EndWriteStruct()

GetDefaultObjectName(string)

Returns the normalized object name for the specified file name

public static string GetDefaultObjectName(string fileName)

Parameters

fileName string

Returns

string

GetFirstTopLevelNode()

Returns the first element of the top-level mapping

public FileNode? GetFirstTopLevelNode()

Returns

FileNode

The first element of the top-level mapping.

IsOpened()

Returns true if the object is associated with currently opened file.

public virtual bool IsOpened()

Returns

bool

Open(string, Modes, string?)

operator that performs PCA. The previously stored data, if any, is released

public virtual bool Open(string fileName, FileStorage.Modes flags, string? encoding = null)

Parameters

fileName string

Name of the file to open or the text string to read the data from. Extension of the file (.xml, .yml/.yaml or .json) determines its format (XML, YAML or JSON respectively). Also you can append .gz to work with compressed files, for example myHugeMatrix.xml.gz. If both FileStorage::WRITE and FileStorage::MEMORY flags are specified, source is used just to specify the output file format (e.g. mydata.xml, .yml etc.). A file name can also contain parameters. You can use this format, "*?base64" (e.g. "file.json?base64" (case sensitive)), as an alternative to FileStorage::BASE64 flag.

flags FileStorage.Modes

Mode of operation.

encoding string

Encoding of the file. Note that UTF-16 XML encoding is not supported currently and you should use 8-bit encoding instead of it.

Returns

bool

Release()

Closes the file and releases all the memory buffers

public virtual void Release()

ReleaseAndGetString()

Closes the file, releases all the memory buffers and returns the text string

public string ReleaseAndGetString()

Returns

string

Root(int)

Returns the top-level mapping. YAML supports multiple streams

public FileNode? Root(int streamIdx = 0)

Parameters

streamIdx int

Zero-based index of the stream. In most cases there is only one stream in the file. However, YAML supports multiple streams and so there can be several.

Returns

FileNode

The top-level mapping.

StartWriteStruct(string, int, string)

public void StartWriteStruct(string name, int flags, string typeName)

Parameters

name string
flags int
typeName string

Write(string, Mat)

public void Write(string name, Mat value)

Parameters

name string
value Mat

Write(string, SparseMat)

public void Write(string name, SparseMat value)

Parameters

name string
value SparseMat

Write(string, IEnumerable<DMatch>)

public void Write(string name, IEnumerable<DMatch> value)

Parameters

name string
value IEnumerable<DMatch>

Write(string, IEnumerable<KeyPoint>)

public void Write(string name, IEnumerable<KeyPoint> value)

Parameters

name string
value IEnumerable<KeyPoint>

Write(string, double)

public void Write(string name, double value)

Parameters

name string
value double

Write(string, int)

public void Write(string name, int value)

Parameters

name string
value int

Write(string, float)

public void Write(string name, float value)

Parameters

name string
value float

Write(string, string)

public void Write(string name, string value)

Parameters

name string
value string

WriteComment(string, bool)

Writes a comment. The function writes a comment into file storage. The comments are skipped when the storage is read.

public void WriteComment(string comment, bool append = false)

Parameters

comment string

The written comment, single-line or multi-line

append bool

If true, the function tries to put the comment at the end of current line. Else if the comment is multi-line, or if it does not fit at the end of the current line, the comment starts a new line.

WriteRaw(string, nint, int)

Writes one or more numbers of the specified format to the currently written structure

public void WriteRaw(string fmt, nint vec, int len)

Parameters

fmt string

Specification of each array element, see @ref format_spec "format specification"

vec nint

Pointer to the written array.

len int

Number of the uchar elements to write.

WriteScalar(double)

public void WriteScalar(double value)

Parameters

value double

WriteScalar(int)

public void WriteScalar(int value)

Parameters

value int

WriteScalar(float)

public void WriteScalar(float value)

Parameters

value float

WriteScalar(string)

public void WriteScalar(string value)

Parameters

value string