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
sourcestringName 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.).
flagsFileStorage.ModesencodingstringEncoding 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
this[string]
Returns the specified element of the top-level mapping
public FileNode? this[string nodeName] { get; }
Parameters
nodeNamestring
Property Value
State
the writer state
public FileStorage.States State { get; }
Property Value
Methods
Add(DMatch)
Writes data to a file storage.
public FileStorage Add(DMatch val)
Parameters
valDMatch
Returns
Add(KeyPoint)
Writes data to a file storage.
public FileStorage Add(KeyPoint val)
Parameters
valKeyPoint
Returns
Add(Mat)
Writes data to a file storage.
public FileStorage Add(Mat val)
Parameters
valMat
Returns
Add(Point)
/Writes data to a file storage.
public FileStorage Add(Point val)
Parameters
valPoint
Returns
Add(Point2d)
Writes data to a file storage.
public FileStorage Add(Point2d val)
Parameters
valPoint2d
Returns
Add(Point2f)
Writes data to a file storage.
public FileStorage Add(Point2f val)
Parameters
valPoint2f
Returns
Add(Point3d)
Writes data to a file storage.
public FileStorage Add(Point3d val)
Parameters
valPoint3d
Returns
Add(Point3f)
Writes data to a file storage.
public FileStorage Add(Point3f val)
Parameters
valPoint3f
Returns
Add(Point3i)
Writes data to a file storage.
public FileStorage Add(Point3i val)
Parameters
valPoint3i
Returns
Add(Range)
Writes data to a file storage.
public FileStorage Add(Range val)
Parameters
valRange
Returns
Add(Rect)
Writes data to a file storage.
public FileStorage Add(Rect val)
Parameters
valRect
Returns
Add(Rect2d)
Writes data to a file storage.
public FileStorage Add(Rect2d val)
Parameters
valRect2d
Returns
Add(Rect2f)
Writes data to a file storage.
public FileStorage Add(Rect2f val)
Parameters
valRect2f
Returns
Add(Scalar)
Writes data to a file storage.
public FileStorage Add(Scalar val)
Parameters
valScalar
Returns
Add(Size)
Writes data to a file storage.
public FileStorage Add(Size val)
Parameters
valSize
Returns
Add(Size2d)
Writes data to a file storage.
public FileStorage Add(Size2d val)
Parameters
valSize2d
Returns
Add(Size2f)
Writes data to a file storage.
public FileStorage Add(Size2f val)
Parameters
valSize2f
Returns
Add(SparseMat)
Writes data to a file storage.
public FileStorage Add(SparseMat val)
Parameters
valSparseMat
Returns
Add(Vec2b)
Writes data to a file storage.
public FileStorage Add(Vec2b val)
Parameters
valVec2b
Returns
Add(Vec2d)
Writes data to a file storage.
public FileStorage Add(Vec2d val)
Parameters
valVec2d
Returns
Add(Vec2f)
Writes data to a file storage.
public FileStorage Add(Vec2f val)
Parameters
valVec2f
Returns
Add(Vec2i)
Writes data to a file storage.
public FileStorage Add(Vec2i val)
Parameters
valVec2i
Returns
Add(Vec2s)
Writes data to a file storage.
public FileStorage Add(Vec2s val)
Parameters
valVec2s
Returns
Add(Vec2w)
Writes data to a file storage.
public FileStorage Add(Vec2w val)
Parameters
valVec2w
Returns
Add(Vec3b)
Writes data to a file storage.
public FileStorage Add(Vec3b val)
Parameters
valVec3b
Returns
Add(Vec3d)
Writes data to a file storage.
public FileStorage Add(Vec3d val)
Parameters
valVec3d
Returns
Add(Vec3f)
Writes data to a file storage.
public FileStorage Add(Vec3f val)
Parameters
valVec3f
Returns
Add(Vec3i)
Writes data to a file storage.
public FileStorage Add(Vec3i val)
Parameters
valVec3i
Returns
Add(Vec3s)
Writes data to a file storage.
public FileStorage Add(Vec3s val)
Parameters
valVec3s
Returns
Add(Vec3w)
Writes data to a file storage.
public FileStorage Add(Vec3w val)
Parameters
valVec3w
Returns
Add(Vec4b)
Writes data to a file storage.
public FileStorage Add(Vec4b val)
Parameters
valVec4b
Returns
Add(Vec4d)
Writes data to a file storage.
public FileStorage Add(Vec4d val)
Parameters
valVec4d
Returns
Add(Vec4f)
Writes data to a file storage.
public FileStorage Add(Vec4f val)
Parameters
valVec4f
Returns
Add(Vec4i)
Writes data to a file storage.
public FileStorage Add(Vec4i val)
Parameters
valVec4i
Returns
Add(Vec4s)
Writes data to a file storage.
public FileStorage Add(Vec4s val)
Parameters
valVec4s
Returns
Add(Vec4w)
Writes data to a file storage.
public FileStorage Add(Vec4w val)
Parameters
valVec4w
Returns
Add(Vec6b)
Writes data to a file storage.
public FileStorage Add(Vec6b val)
Parameters
valVec6b
Returns
Add(Vec6d)
Writes data to a file storage.
public FileStorage Add(Vec6d val)
Parameters
valVec6d
Returns
Add(Vec6f)
Writes data to a file storage.
public FileStorage Add(Vec6f val)
Parameters
valVec6f
Returns
Add(Vec6i)
Writes data to a file storage.
public FileStorage Add(Vec6i val)
Parameters
valVec6i
Returns
Add(Vec6s)
Writes data to a file storage.
public FileStorage Add(Vec6s val)
Parameters
valVec6s
Returns
Add(Vec6w)
Writes data to a file storage.
public FileStorage Add(Vec6w val)
Parameters
valVec6w
Returns
Add(IEnumerable<DMatch>)
Writes data to a file storage.
public FileStorage Add(IEnumerable<DMatch> val)
Parameters
valIEnumerable<DMatch>
Returns
Add(IEnumerable<KeyPoint>)
Writes data to a file storage.
public FileStorage Add(IEnumerable<KeyPoint> val)
Parameters
valIEnumerable<KeyPoint>
Returns
Add(double)
Writes data to a file storage.
public FileStorage Add(double val)
Parameters
valdouble
Returns
Add(int)
Writes data to a file storage.
public FileStorage Add(int val)
Parameters
valint
Returns
Add(float)
Writes data to a file storage.
public FileStorage Add(float val)
Parameters
valfloat
Returns
Add(string)
Writes data to a file storage.
public FileStorage Add(string val)
Parameters
valstring
Returns
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
fileNamestring
Returns
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
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
fileNamestringName 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.
flagsFileStorage.ModesMode of operation.
encodingstringEncoding of the file. Note that UTF-16 XML encoding is not supported currently and you should use 8-bit encoding instead of it.
Returns
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
Root(int)
Returns the top-level mapping. YAML supports multiple streams
public FileNode? Root(int streamIdx = 0)
Parameters
streamIdxintZero-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
Write(string, Mat)
public void Write(string name, Mat value)
Parameters
Write(string, SparseMat)
public void Write(string name, SparseMat value)
Parameters
Write(string, IEnumerable<DMatch>)
public void Write(string name, IEnumerable<DMatch> value)
Parameters
namestringvalueIEnumerable<DMatch>
Write(string, IEnumerable<KeyPoint>)
public void Write(string name, IEnumerable<KeyPoint> value)
Parameters
namestringvalueIEnumerable<KeyPoint>
Write(string, double)
public void Write(string name, double value)
Parameters
Write(string, int)
public void Write(string name, int value)
Parameters
Write(string, float)
public void Write(string name, float value)
Parameters
Write(string, string)
public void Write(string name, string value)
Parameters
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
commentstringThe written comment, single-line or multi-line
appendboolIf 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
fmtstringSpecification of each array element, see @ref format_spec "format specification"
vecnintPointer to the written array.
lenintNumber of the uchar elements to write.
WriteScalar(double)
public void WriteScalar(double value)
Parameters
valuedouble
WriteScalar(int)
public void WriteScalar(int value)
Parameters
valueint
WriteScalar(float)
public void WriteScalar(float value)
Parameters
valuefloat
WriteScalar(string)
public void WriteScalar(string value)
Parameters
valuestring