Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
d3930cde
Commit
d3930cde
authored
9 years ago
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #6482 from paroj:filestorage_py
parents
a2d8e7fa
bf688da5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
53 additions
and
3 deletions
+53
-3
persistence.hpp
modules/core/include/opencv2/core/persistence.hpp
+34
-3
persistence.cpp
modules/core/src/persistence.cpp
+19
-0
No files found.
modules/core/include/opencv2/core/persistence.hpp
View file @
d3930cde
...
...
@@ -398,7 +398,7 @@ public:
FileNode
operator
[](
const
String
&
nodename
)
const
;
/** @overload */
CV_WRAP
FileNode
operator
[](
const
char
*
nodename
)
const
;
CV_WRAP
_AS
(
getNode
)
FileNode
operator
[](
const
char
*
nodename
)
const
;
/** @brief Returns the obsolete C FileStorage structure.
@returns Pointer to the underlying C FileStorage structure
...
...
@@ -425,6 +425,27 @@ public:
*/
void
writeObj
(
const
String
&
name
,
const
void
*
obj
);
/**
* @brief Simplified writing API to use with bindings.
* @param name Name of the written object
* @param val Value of the written object
*/
CV_WRAP
void
write
(
const
String
&
name
,
double
val
);
/// @overload
CV_WRAP
void
write
(
const
String
&
name
,
const
String
&
val
);
/// @overload
CV_WRAP
void
write
(
const
String
&
name
,
InputArray
val
);
/** @brief Writes a comment.
The function writes a comment into file storage. The comments are skipped when the storage is read.
@param comment The written comment, single-line or multi-line
@param append 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.
*/
CV_WRAP
void
writeComment
(
const
String
&
comment
,
bool
append
=
false
);
/** @brief Returns the normalized object name for the specified name of a file.
@param filename Name of a file
@returns The normalized object name.
...
...
@@ -499,12 +520,12 @@ public:
/** @overload
@param nodename Name of an element in the mapping node.
*/
CV_WRAP
FileNode
operator
[](
const
char
*
nodename
)
const
;
CV_WRAP
_AS
(
getNode
)
FileNode
operator
[](
const
char
*
nodename
)
const
;
/** @overload
@param i Index of an element in the sequence node.
*/
CV_WRAP
FileNode
operator
[](
int
i
)
const
;
CV_WRAP
_AS
(
at
)
FileNode
operator
[](
int
i
)
const
;
/** @brief Returns type of the node.
@returns Type of the node. See FileNode::Type
...
...
@@ -566,6 +587,13 @@ public:
//! reads the registered object and returns pointer to it
void
*
readObj
()
const
;
//! Simplified reading API to use with bindings.
CV_WRAP
double
real
()
const
;
//! Simplified reading API to use with bindings.
CV_WRAP
String
string
()
const
;
//! Simplified reading API to use with bindings.
CV_WRAP
Mat
mat
()
const
;
// do not use wrapper pointer classes for better efficiency
const
CvFileStorage
*
fs
;
const
CvFileNode
*
node
;
...
...
@@ -1198,6 +1226,9 @@ inline FileNode::operator int() const { int value; read(*this, value, 0);
inline
FileNode
::
operator
float
()
const
{
float
value
;
read
(
*
this
,
value
,
0.
f
);
return
value
;
}
inline
FileNode
::
operator
double
()
const
{
double
value
;
read
(
*
this
,
value
,
0.
);
return
value
;
}
inline
FileNode
::
operator
String
()
const
{
String
value
;
read
(
*
this
,
value
,
value
);
return
value
;
}
inline
double
FileNode
::
real
()
const
{
return
double
(
*
this
);
}
inline
String
FileNode
::
string
()
const
{
return
String
(
*
this
);
}
inline
Mat
FileNode
::
mat
()
const
{
Mat
value
;
read
(
*
this
,
value
,
value
);
return
value
;
}
inline
FileNodeIterator
FileNode
::
begin
()
const
{
return
FileNodeIterator
(
fs
,
node
);
}
inline
FileNodeIterator
FileNode
::
end
()
const
{
return
FileNodeIterator
(
fs
,
node
,
size
());
}
inline
void
FileNode
::
readRaw
(
const
String
&
fmt
,
uchar
*
vec
,
size_t
len
)
const
{
begin
().
readRaw
(
fmt
,
vec
,
len
);
}
...
...
This diff is collapsed.
Click to expand it.
modules/core/src/persistence.cpp
View file @
d3930cde
...
...
@@ -5271,6 +5271,25 @@ void FileStorage::writeObj( const String& name, const void* obj )
cvWrite
(
fs
,
name
.
size
()
>
0
?
name
.
c_str
()
:
0
,
obj
);
}
void
FileStorage
::
write
(
const
String
&
name
,
double
val
)
{
*
this
<<
name
<<
val
;
}
void
FileStorage
::
write
(
const
String
&
name
,
const
String
&
val
)
{
*
this
<<
name
<<
val
;
}
void
FileStorage
::
write
(
const
String
&
name
,
InputArray
val
)
{
*
this
<<
name
<<
val
.
getMat
();
}
void
FileStorage
::
writeComment
(
const
String
&
comment
,
bool
append
)
{
cvWriteComment
(
fs
,
comment
.
c_str
(),
append
?
1
:
0
);
}
FileNode
FileStorage
::
operator
[](
const
String
&
nodename
)
const
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment