diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index a1d196d677..fe3af39365 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -3139,6 +3139,7 @@ public: template static Ptr<_Tp> load(const String& filename, const String& objname=String()) { FileStorage fs(filename, FileStorage::READ); + CV_Assert(fs.isOpened()); FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname]; if (fn.empty()) return Ptr<_Tp>(); Ptr<_Tp> obj = _Tp::create(); diff --git a/modules/ml/src/ann_mlp.cpp b/modules/ml/src/ann_mlp.cpp index cbaa6dbf39..4a47b3df42 100644 --- a/modules/ml/src/ann_mlp.cpp +++ b/modules/ml/src/ann_mlp.cpp @@ -1399,7 +1399,7 @@ Ptr ANN_MLP::load(const String& filepath) { FileStorage fs; fs.open(filepath, FileStorage::READ); - + CV_Assert(fs.isOpened()); Ptr ann = makePtr(); ((ANN_MLPImpl*)ann.get())->read(fs.getFirstTopLevelNode());