added read/write functions for vector<DMatch> + the test (http://code.opencv.org/issues/4308)
This commit is contained in:
@@ -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; }
|
||||
|
||||
|
Reference in New Issue
Block a user