Skip to content

Commit 11626fe

Browse files
committed
Merge pull request opencv#8975 from sovrasov:fs_additional_errors
2 parents 63e89bc + 6dd9e18 commit 11626fe

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

modules/core/include/opencv2/core/cvstd.inl.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,7 @@ FileNode::operator std::string() const
153153
template<> inline
154154
void operator >> (const FileNode& n, std::string& value)
155155
{
156-
String val;
157-
read(n, val, val);
158-
value = val;
156+
read(n, value, std::string());
159157
}
160158

161159
template<> inline

modules/core/include/opencv2/core/persistence.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ CV_EXPORTS void read(const FileNode& node, int& value, int default_value);
712712
CV_EXPORTS void read(const FileNode& node, float& value, float default_value);
713713
CV_EXPORTS void read(const FileNode& node, double& value, double default_value);
714714
CV_EXPORTS void read(const FileNode& node, String& value, const String& default_value);
715+
CV_EXPORTS void read(const FileNode& node, std::string& value, const std::string& default_value);
715716
CV_EXPORTS void read(const FileNode& node, Mat& mat, const Mat& default_mat = Mat() );
716717
CV_EXPORTS void read(const FileNode& node, SparseMat& mat, const SparseMat& default_mat = SparseMat() );
717718
CV_EXPORTS void read(const FileNode& node, std::vector<KeyPoint>& keypoints);

modules/core/src/persistence.cpp

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7374,29 +7374,33 @@ size_t FileNode::size() const
73747374
void read(const FileNode& node, int& value, int default_value)
73757375
{
73767376
value = !node.node ? default_value :
7377-
CV_NODE_IS_INT(node.node->tag) ? node.node->data.i :
7378-
CV_NODE_IS_REAL(node.node->tag) ? cvRound(node.node->data.f) : 0x7fffffff;
7377+
CV_NODE_IS_INT(node.node->tag) ? node.node->data.i : std::numeric_limits<int>::max();
73797378
}
73807379

73817380
void read(const FileNode& node, float& value, float default_value)
73827381
{
73837382
value = !node.node ? default_value :
73847383
CV_NODE_IS_INT(node.node->tag) ? (float)node.node->data.i :
7385-
CV_NODE_IS_REAL(node.node->tag) ? (float)node.node->data.f : 1e30f;
7384+
CV_NODE_IS_REAL(node.node->tag) ? saturate_cast<float>(node.node->data.f) : std::numeric_limits<float>::max();
73867385
}
73877386

73887387
void read(const FileNode& node, double& value, double default_value)
73897388
{
73907389
value = !node.node ? default_value :
73917390
CV_NODE_IS_INT(node.node->tag) ? (double)node.node->data.i :
7392-
CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : 1e300;
7391+
CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : std::numeric_limits<double>::max();
73937392
}
73947393

73957394
void read(const FileNode& node, String& value, const String& default_value)
73967395
{
73977396
value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? String(node.node->data.str.ptr) : String();
73987397
}
73997398

7399+
void read(const FileNode& node, std::string& value, const std::string& default_value)
7400+
{
7401+
value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? std::string(node.node->data.str.ptr) : default_value;
7402+
}
7403+
74007404
}
74017405

74027406

0 commit comments

Comments
 (0)