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
896c34fa
Commit
896c34fa
authored
8 years ago
by
Vladislav Sovrasov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add support of type headings from YAML1.2
parent
89a740a6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
0 deletions
+37
-0
persistence.cpp
modules/core/src/persistence.cpp
+20
-0
test_io.cpp
modules/core/test/test_io.cpp
+17
-0
No files found.
modules/core/src/persistence.cpp
View file @
896c34fa
...
...
@@ -1475,6 +1475,26 @@ icvYMLParseValue( CvFileStorage* fs, char* ptr, CvFileNode* node,
ptr
++
;
value_type
|=
CV_NODE_USER
;
}
if
(
d
==
'<'
)
//support of full type heading from YAML 1.2
{
const
char
*
yamlTypeHeading
=
"<tag:yaml.org,2002:"
;
const
size_t
headingLenght
=
strlen
(
yamlTypeHeading
);
char
*
typeEndPtr
=
++
ptr
;
do
d
=
*++
typeEndPtr
;
while
(
cv_isprint
(
d
)
&&
d
!=
' '
&&
d
!=
'>'
);
if
(
d
==
'>'
&&
(
size_t
)(
typeEndPtr
-
ptr
)
>
headingLenght
)
{
if
(
memcmp
(
ptr
,
yamlTypeHeading
,
headingLenght
)
==
0
)
{
value_type
|=
CV_NODE_USER
;
*
typeEndPtr
=
' '
;
ptr
+=
headingLenght
-
1
;
}
}
}
endptr
=
ptr
++
;
do
d
=
*++
endptr
;
...
...
This diff is collapsed.
Click to expand it.
modules/core/test/test_io.cpp
View file @
896c34fa
...
...
@@ -996,3 +996,20 @@ TEST(Core_InputOutput, filestorage_vec_vec_io)
remove
((
fileName
+
formats
[
i
]).
c_str
());
}
}
TEST
(
Core_InputOutput
,
filestorage_yaml_advanvced_type_heading
)
{
String
content
=
"%YAML:1.0
\n
cameraMatrix: !<tag:yaml.org,2002:opencv-matrix>
\n
"
" rows: 1
\n
"
" cols: 1
\n
"
" dt: d
\n
"
" data: [ 1. ]"
;
cv
::
FileStorage
fs
(
content
,
cv
::
FileStorage
::
READ
|
cv
::
FileStorage
::
MEMORY
);
cv
::
Mat
inputMatrix
;
cv
::
Mat
actualMatrix
=
cv
::
Mat
::
eye
(
1
,
1
,
CV_64F
);
fs
[
"cameraMatrix"
]
>>
inputMatrix
;
ASSERT_EQ
(
cv
::
norm
(
inputMatrix
,
actualMatrix
,
NORM_INF
),
0.
);
}
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