Skip to content

Commit 75533fc

Browse files
authored
Merge pull request opencv#8098 from chrizandr:Tree_load_Wrapper
Add wrappers for load functions for DTrees and Boost classifiers
2 parents 82902b6 + d22df8c commit 75533fc

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

modules/ml/include/opencv2/ml.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1137,6 +1137,17 @@ class CV_EXPORTS_W DTrees : public StatModel
11371137
file using Algorithm::load\<DTrees\>(filename).
11381138
*/
11391139
CV_WRAP static Ptr<DTrees> create();
1140+
1141+
/** @brief Loads and creates a serialized DTrees from a file
1142+
*
1143+
* Use DTree::save to serialize and store an DTree to disk.
1144+
* Load the DTree from this file again, by calling this function with the path to the file.
1145+
* Optionally specify the node for the file containing the classifier
1146+
*
1147+
* @param filepath path to serialized DTree
1148+
* @param nodeName name of node containing the classifier
1149+
*/
1150+
CV_WRAP static Ptr<DTrees> load(const String& filepath , const String& nodeName = String());
11401151
};
11411152

11421153
/****************************************************************************************\
@@ -1251,6 +1262,17 @@ class CV_EXPORTS_W Boost : public DTrees
12511262
/** Creates the empty model.
12521263
Use StatModel::train to train the model, Algorithm::load\<Boost\>(filename) to load the pre-trained model. */
12531264
CV_WRAP static Ptr<Boost> create();
1265+
1266+
/** @brief Loads and creates a serialized Boost from a file
1267+
*
1268+
* Use Boost::save to serialize and store an RTree to disk.
1269+
* Load the Boost from this file again, by calling this function with the path to the file.
1270+
* Optionally specify the node for the file containing the classifier
1271+
*
1272+
* @param filepath path to serialized Boost
1273+
* @param nodeName name of node containing the classifier
1274+
*/
1275+
CV_WRAP static Ptr<Boost> load(const String& filepath , const String& nodeName = String());
12541276
};
12551277

12561278
/****************************************************************************************\

modules/ml/src/boost.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,11 @@ Ptr<Boost> Boost::create()
507507
return makePtr<BoostImpl>();
508508
}
509509

510+
Ptr<Boost> Boost::load(const String& filepath, const String& nodeName)
511+
{
512+
return Algorithm::load<Boost>(filepath, nodeName);
513+
}
514+
510515
}}
511516

512517
/* End of file. */

modules/ml/src/tree.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,6 +1941,12 @@ Ptr<DTrees> DTrees::create()
19411941
return makePtr<DTreesImpl>();
19421942
}
19431943

1944+
Ptr<DTrees> DTrees::load(const String& filepath, const String& nodeName)
1945+
{
1946+
return Algorithm::load<DTrees>(filepath, nodeName);
1947+
}
1948+
1949+
19441950
}
19451951
}
19461952

0 commit comments

Comments
 (0)