Merge pull request #8975 from sovrasov:fs_additional_errors

This commit is contained in:
Alexander Alekhin 2017-07-14 17:13:50 +00:00
commit 11626fe32c
3 changed files with 10 additions and 7 deletions

View File

@ -153,9 +153,7 @@ FileNode::operator std::string() const
template<> inline template<> inline
void operator >> (const FileNode& n, std::string& value) void operator >> (const FileNode& n, std::string& value)
{ {
String val; read(n, value, std::string());
read(n, val, val);
value = val;
} }
template<> inline template<> inline

View File

@ -712,6 +712,7 @@ CV_EXPORTS void read(const FileNode& node, int& value, int default_value);
CV_EXPORTS void read(const FileNode& node, float& value, float default_value); CV_EXPORTS void read(const FileNode& node, float& value, float default_value);
CV_EXPORTS void read(const FileNode& node, double& value, double default_value); CV_EXPORTS void read(const FileNode& node, double& value, double default_value);
CV_EXPORTS void read(const FileNode& node, String& value, const String& default_value); CV_EXPORTS void read(const FileNode& node, String& value, const String& default_value);
CV_EXPORTS void read(const FileNode& node, std::string& value, const std::string& default_value);
CV_EXPORTS void read(const FileNode& node, Mat& mat, const Mat& default_mat = Mat() ); 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, 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<KeyPoint>& keypoints);

View File

@ -7374,22 +7374,21 @@ size_t FileNode::size() const
void read(const FileNode& node, int& value, int default_value) void read(const FileNode& node, int& value, int default_value)
{ {
value = !node.node ? default_value : value = !node.node ? default_value :
CV_NODE_IS_INT(node.node->tag) ? node.node->data.i : CV_NODE_IS_INT(node.node->tag) ? node.node->data.i : std::numeric_limits<int>::max();
CV_NODE_IS_REAL(node.node->tag) ? cvRound(node.node->data.f) : 0x7fffffff;
} }
void read(const FileNode& node, float& value, float default_value) void read(const FileNode& node, float& value, float default_value)
{ {
value = !node.node ? default_value : value = !node.node ? default_value :
CV_NODE_IS_INT(node.node->tag) ? (float)node.node->data.i : CV_NODE_IS_INT(node.node->tag) ? (float)node.node->data.i :
CV_NODE_IS_REAL(node.node->tag) ? (float)node.node->data.f : 1e30f; CV_NODE_IS_REAL(node.node->tag) ? saturate_cast<float>(node.node->data.f) : std::numeric_limits<float>::max();
} }
void read(const FileNode& node, double& value, double default_value) void read(const FileNode& node, double& value, double default_value)
{ {
value = !node.node ? default_value : value = !node.node ? default_value :
CV_NODE_IS_INT(node.node->tag) ? (double)node.node->data.i : CV_NODE_IS_INT(node.node->tag) ? (double)node.node->data.i :
CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : 1e300; CV_NODE_IS_REAL(node.node->tag) ? node.node->data.f : std::numeric_limits<double>::max();
} }
void read(const FileNode& node, String& value, const String& default_value) void read(const FileNode& node, String& value, const String& default_value)
@ -7397,6 +7396,11 @@ void read(const FileNode& node, String& value, const String& default_value)
value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? String(node.node->data.str.ptr) : String(); value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? String(node.node->data.str.ptr) : String();
} }
void read(const FileNode& node, std::string& value, const std::string& default_value)
{
value = !node.node ? default_value : CV_NODE_IS_STRING(node.node->tag) ? std::string(node.node->data.str.ptr) : default_value;
}
} }