Merge pull request #10170 from LaurentBerger:Issue10166

pull/10193/head
Vadim Pisarevsky 7 years ago
commit 614e254331
  1. 1
      modules/core/include/opencv2/core.hpp
  2. 2
      modules/ml/src/ann_mlp.cpp

@ -3139,6 +3139,7 @@ public:
template<typename _Tp> static Ptr<_Tp> load(const String& filename, const String& objname=String()) template<typename _Tp> static Ptr<_Tp> load(const String& filename, const String& objname=String())
{ {
FileStorage fs(filename, FileStorage::READ); FileStorage fs(filename, FileStorage::READ);
CV_Assert(fs.isOpened());
FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname]; FileNode fn = objname.empty() ? fs.getFirstTopLevelNode() : fs[objname];
if (fn.empty()) return Ptr<_Tp>(); if (fn.empty()) return Ptr<_Tp>();
Ptr<_Tp> obj = _Tp::create(); Ptr<_Tp> obj = _Tp::create();

@ -1399,7 +1399,7 @@ Ptr<ANN_MLP> ANN_MLP::load(const String& filepath)
{ {
FileStorage fs; FileStorage fs;
fs.open(filepath, FileStorage::READ); fs.open(filepath, FileStorage::READ);
CV_Assert(fs.isOpened());
Ptr<ANN_MLP> ann = makePtr<ANN_MLPImpl>(); Ptr<ANN_MLP> ann = makePtr<ANN_MLPImpl>();
((ANN_MLPImpl*)ann.get())->read(fs.getFirstTopLevelNode()); ((ANN_MLPImpl*)ann.get())->read(fs.getFirstTopLevelNode());

Loading…
Cancel
Save