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
432cf115
Commit
432cf115
authored
May 18, 2015
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added read/write functions for vector<DMatch> + the test (
http://code.opencv.org/issues/4308
)
parent
e0136e39
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
41 additions
and
0 deletions
+41
-0
persistence.hpp
modules/core/include/opencv2/core/persistence.hpp
+2
-0
persistence.cpp
modules/core/src/persistence.cpp
+29
-0
test_matchers_algorithmic.cpp
modules/features2d/test/test_matchers_algorithmic.cpp
+10
-0
No files found.
modules/core/include/opencv2/core/persistence.hpp
View file @
432cf115
...
...
@@ -660,6 +660,7 @@ CV_EXPORTS void write( FileStorage& fs, const String& name, const String& value
CV_EXPORTS
void
write
(
FileStorage
&
fs
,
const
String
&
name
,
const
Mat
&
value
);
CV_EXPORTS
void
write
(
FileStorage
&
fs
,
const
String
&
name
,
const
SparseMat
&
value
);
CV_EXPORTS
void
write
(
FileStorage
&
fs
,
const
String
&
name
,
const
std
::
vector
<
KeyPoint
>&
value
);
CV_EXPORTS
void
write
(
FileStorage
&
fs
,
const
String
&
name
,
const
std
::
vector
<
DMatch
>&
value
);
CV_EXPORTS
void
writeScalar
(
FileStorage
&
fs
,
int
value
);
CV_EXPORTS
void
writeScalar
(
FileStorage
&
fs
,
float
value
);
...
...
@@ -678,6 +679,7 @@ CV_EXPORTS void read(const FileNode& node, String& value, const String& default_
CV_EXPORTS
void
read
(
const
FileNode
&
node
,
Mat
&
mat
,
const
Mat
&
default_mat
=
Mat
()
);
CV_EXPORTS
void
read
(
const
FileNode
&
node
,
SparseMat
&
mat
,
const
SparseMat
&
default_mat
=
SparseMat
()
);
CV_EXPORTS
void
read
(
const
FileNode
&
node
,
std
::
vector
<
KeyPoint
>&
keypoints
);
CV_EXPORTS
void
read
(
const
FileNode
&
node
,
std
::
vector
<
DMatch
>&
matches
);
template
<
typename
_Tp
>
static
inline
void
read
(
const
FileNode
&
node
,
Point_
<
_Tp
>&
value
,
const
Point_
<
_Tp
>&
default_value
)
{
...
...
modules/core/src/persistence.cpp
View file @
432cf115
...
...
@@ -5594,6 +5594,35 @@ void read(const FileNode& node, std::vector<KeyPoint>& keypoints)
}
}
void
write
(
FileStorage
&
fs
,
const
String
&
objname
,
const
std
::
vector
<
DMatch
>&
matches
)
{
cv
::
internal
::
WriteStructContext
ws
(
fs
,
objname
,
CV_NODE_SEQ
+
CV_NODE_FLOW
);
int
i
,
n
=
(
int
)
matches
.
size
();
for
(
i
=
0
;
i
<
n
;
i
++
)
{
const
DMatch
&
m
=
matches
[
i
];
cv
::
write
(
fs
,
m
.
queryIdx
);
cv
::
write
(
fs
,
m
.
trainIdx
);
cv
::
write
(
fs
,
m
.
imgIdx
);
cv
::
write
(
fs
,
m
.
distance
);
}
}
void
read
(
const
FileNode
&
node
,
std
::
vector
<
DMatch
>&
matches
)
{
matches
.
resize
(
0
);
FileNodeIterator
it
=
node
.
begin
(),
it_end
=
node
.
end
();
for
(
;
it
!=
it_end
;
)
{
DMatch
m
;
it
>>
m
.
queryIdx
>>
m
.
trainIdx
>>
m
.
imgIdx
>>
m
.
distance
;
matches
.
push_back
(
m
);
}
}
int
FileNode
::
type
()
const
{
return
!
node
?
NONE
:
(
node
->
tag
&
TYPE_MASK
);
}
bool
FileNode
::
isNamed
()
const
{
return
!
node
?
false
:
(
node
->
tag
&
NAMED
)
!=
0
;
}
...
...
modules/features2d/test/test_matchers_algorithmic.cpp
View file @
432cf115
...
...
@@ -543,3 +543,13 @@ TEST( Features2d_DescriptorMatcher_FlannBased, regression )
DescriptorMatcher
::
create
(
"FlannBased"
),
0.04
f
);
test
.
safe_run
();
}
TEST
(
Features2d_DMatch
,
read_write
)
{
FileStorage
fs
(
".xml"
,
FileStorage
::
WRITE
+
FileStorage
::
MEMORY
);
vector
<
DMatch
>
matches
;
matches
.
push_back
(
DMatch
(
1
,
2
,
3
,
4.5
f
));
fs
<<
"Match"
<<
matches
;
String
str
=
fs
.
releaseAndGetString
();
ASSERT_NE
(
strstr
(
str
.
c_str
(),
"4.5"
),
(
char
*
)
0
);
}
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