renamed getDefaultClassifierNM{1,2}() to loadClassifierNM{1,2}() and added "const std::string& filename" parameter (mandatory).
This commit is contained in:
parent
95d92c099c
commit
75fdfba281
@ -47,6 +47,7 @@
|
|||||||
#include "opencv2/core.hpp"
|
#include "opencv2/core.hpp"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
namespace cv
|
namespace cv
|
||||||
{
|
{
|
||||||
@ -164,7 +165,7 @@ public:
|
|||||||
|
|
||||||
\param cb Callback with the classifier.
|
\param cb Callback with the classifier.
|
||||||
if omitted tries to load a default classifier from file trained_classifierNM1.xml
|
if omitted tries to load a default classifier from file trained_classifierNM1.xml
|
||||||
default classifier can be implicitly load with function getDefaultClassifierNM1()
|
default classifier can be implicitly load with function loadClassifierNM1()
|
||||||
\param thresholdDelta Threshold step in subsequent thresholds when extracting the component tree
|
\param thresholdDelta Threshold step in subsequent thresholds when extracting the component tree
|
||||||
\param minArea The minimum area (% of image size) allowed for retreived ER's
|
\param minArea The minimum area (% of image size) allowed for retreived ER's
|
||||||
\param minArea The maximum area (% of image size) allowed for retreived ER's
|
\param minArea The maximum area (% of image size) allowed for retreived ER's
|
||||||
@ -189,7 +190,7 @@ CV_EXPORTS Ptr<ERFilter> createERFilterNM1(const Ptr<ERFilter::Callback>& cb = P
|
|||||||
|
|
||||||
\param cb Callback with the classifier
|
\param cb Callback with the classifier
|
||||||
if omitted tries to load a default classifier from file trained_classifierNM2.xml
|
if omitted tries to load a default classifier from file trained_classifierNM2.xml
|
||||||
default classifier can be implicitly load with function getDefaultClassifierNM2()
|
default classifier can be implicitly load with function loadClassifierNM2()
|
||||||
\param minProbability The minimum probability P(er|character) allowed for retreived ER's
|
\param minProbability The minimum probability P(er|character) allowed for retreived ER's
|
||||||
*/
|
*/
|
||||||
CV_EXPORTS Ptr<ERFilter> createERFilterNM2(const Ptr<ERFilter::Callback>& cb = Ptr<ERFilter::Callback>(),
|
CV_EXPORTS Ptr<ERFilter> createERFilterNM2(const Ptr<ERFilter::Callback>& cb = Ptr<ERFilter::Callback>(),
|
||||||
@ -198,21 +199,19 @@ CV_EXPORTS Ptr<ERFilter> createERFilterNM2(const Ptr<ERFilter::Callback>& cb = P
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
Allow to implicitly load the default classifier when creating an ERFilter object.
|
Allow to implicitly load the default classifier when creating an ERFilter object.
|
||||||
The function takes no parameters and returns a pointer to ERFilter::Callback.
|
The function takes as parameter the XML or YAML file with the classifier model
|
||||||
The dafault classifier is loaded from file trained_classifierNM1.xml
|
(e.g. trained_classifierNM1.xml) returns a pointer to ERFilter::Callback.
|
||||||
if it's found in current directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CV_EXPORTS Ptr<ERFilter::Callback> getDefaultClassifierNM1();
|
CV_EXPORTS Ptr<ERFilter::Callback> loadClassifierNM1(const std::string& filename);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Allow to implicitly load the default classifier when creating an ERFilter object.
|
Allow to implicitly load the default classifier when creating an ERFilter object.
|
||||||
The function takes no parameters and returns a pointer to ERFilter::Callback.
|
The function takes as parameter the XML or YAML file with the classifier model
|
||||||
The dafault classifier is loaded from file trained_classifierNM2.xml
|
(e.g. trained_classifierNM1.xml) returns a pointer to ERFilter::Callback.
|
||||||
if it's found in current directory.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CV_EXPORTS Ptr<ERFilter::Callback> getDefaultClassifierNM2();
|
CV_EXPORTS Ptr<ERFilter::Callback> loadClassifierNM2(const std::string& filename);
|
||||||
|
|
||||||
|
|
||||||
// computeNMChannels operation modes
|
// computeNMChannels operation modes
|
||||||
|
@ -137,7 +137,7 @@ class CV_EXPORTS ERClassifierNM1 : public ERFilter::Callback
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//Constructor
|
//Constructor
|
||||||
ERClassifierNM1();
|
ERClassifierNM1(const std::string& filename);
|
||||||
// Destructor
|
// Destructor
|
||||||
~ERClassifierNM1() {};
|
~ERClassifierNM1() {};
|
||||||
|
|
||||||
@ -153,7 +153,7 @@ class CV_EXPORTS ERClassifierNM2 : public ERFilter::Callback
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
//constructor
|
//constructor
|
||||||
ERClassifierNM2();
|
ERClassifierNM2(const std::string& filename);
|
||||||
// Destructor
|
// Destructor
|
||||||
~ERClassifierNM2() {};
|
~ERClassifierNM2() {};
|
||||||
|
|
||||||
@ -988,24 +988,13 @@ int ERFilterNM::getNumRejected()
|
|||||||
|
|
||||||
|
|
||||||
// load default 1st stage classifier if found
|
// load default 1st stage classifier if found
|
||||||
ERClassifierNM1::ERClassifierNM1()
|
ERClassifierNM1::ERClassifierNM1(const std::string& filename)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (ifstream("./trained_classifierNM1.xml"))
|
if (ifstream(filename.c_str()))
|
||||||
{
|
boost.load( filename.c_str(), "boost" );
|
||||||
// The file with default classifier exists
|
|
||||||
boost.load("./trained_classifierNM1.xml", "boost");
|
|
||||||
}
|
|
||||||
else if (ifstream("./training/trained_classifierNM1.xml"))
|
|
||||||
{
|
|
||||||
// The file with default classifier exists
|
|
||||||
boost.load("./training/trained_classifierNM1.xml", "boost");
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
CV_Error(CV_StsBadArg, "Default classifier file not found!");
|
||||||
// File not found
|
|
||||||
CV_Error(CV_StsBadArg, "Default classifier ./trained_classifierNM1.xml not found!");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
double ERClassifierNM1::eval(const ERStat& stat)
|
double ERClassifierNM1::eval(const ERStat& stat)
|
||||||
@ -1026,24 +1015,12 @@ double ERClassifierNM1::eval(const ERStat& stat)
|
|||||||
|
|
||||||
|
|
||||||
// load default 2nd stage classifier if found
|
// load default 2nd stage classifier if found
|
||||||
ERClassifierNM2::ERClassifierNM2()
|
ERClassifierNM2::ERClassifierNM2(const std::string& filename)
|
||||||
{
|
{
|
||||||
|
if (ifstream(filename.c_str()))
|
||||||
if (ifstream("./trained_classifierNM2.xml"))
|
boost.load( filename.c_str(), "boost" );
|
||||||
{
|
|
||||||
// The file with default classifier exists
|
|
||||||
boost.load("./trained_classifierNM2.xml", "boost");
|
|
||||||
}
|
|
||||||
else if (ifstream("./training/trained_classifierNM2.xml"))
|
|
||||||
{
|
|
||||||
// The file with default classifier exists
|
|
||||||
boost.load("./training/trained_classifierNM2.xml", "boost");
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
CV_Error(CV_StsBadArg, "Default classifier file not found!");
|
||||||
// File not found
|
|
||||||
CV_Error(CV_StsBadArg, "Default classifier ./trained_classifierNM2.xml not found!");
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
double ERClassifierNM2::eval(const ERStat& stat)
|
double ERClassifierNM2::eval(const ERStat& stat)
|
||||||
@ -1080,6 +1057,7 @@ double ERClassifierNM2::eval(const ERStat& stat)
|
|||||||
|
|
||||||
\param cb Callback with the classifier.
|
\param cb Callback with the classifier.
|
||||||
if omitted tries to load a default classifier from file trained_classifierNM1.xml
|
if omitted tries to load a default classifier from file trained_classifierNM1.xml
|
||||||
|
default classifier can be implicitly load with function loadClassifierNM1()
|
||||||
\param thresholdDelta Threshold step in subsequent thresholds when extracting the component tree
|
\param thresholdDelta Threshold step in subsequent thresholds when extracting the component tree
|
||||||
\param minArea The minimum area (% of image size) allowed for retreived ER's
|
\param minArea The minimum area (% of image size) allowed for retreived ER's
|
||||||
\param minArea The maximum area (% of image size) allowed for retreived ER's
|
\param minArea The maximum area (% of image size) allowed for retreived ER's
|
||||||
@ -1100,9 +1078,11 @@ Ptr<ERFilter> createERFilterNM1(const Ptr<ERFilter::Callback>& cb, int threshold
|
|||||||
Ptr<ERFilterNM> filter = makePtr<ERFilterNM>();
|
Ptr<ERFilterNM> filter = makePtr<ERFilterNM>();
|
||||||
|
|
||||||
if (cb == NULL)
|
if (cb == NULL)
|
||||||
filter->setCallback(makePtr<ERClassifierNM1>());
|
filter->setCallback(makePtr<ERClassifierNM1>("trained_classifierNM1.xml"));
|
||||||
else
|
else
|
||||||
filter->setCallback(cb);
|
filter->setCallback(cb);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
filter->setThresholdDelta(thresholdDelta);
|
filter->setThresholdDelta(thresholdDelta);
|
||||||
filter->setMinArea(minArea);
|
filter->setMinArea(minArea);
|
||||||
@ -1124,6 +1104,7 @@ Ptr<ERFilter> createERFilterNM1(const Ptr<ERFilter::Callback>& cb, int threshold
|
|||||||
|
|
||||||
\param cb Callback with the classifier
|
\param cb Callback with the classifier
|
||||||
if omitted tries to load a default classifier from file trained_classifierNM2.xml
|
if omitted tries to load a default classifier from file trained_classifierNM2.xml
|
||||||
|
default classifier can be implicitly load with function loadClassifierNM1()
|
||||||
\param minProbability The minimum probability P(er|character) allowed for retreived ER's
|
\param minProbability The minimum probability P(er|character) allowed for retreived ER's
|
||||||
*/
|
*/
|
||||||
Ptr<ERFilter> createERFilterNM2(const Ptr<ERFilter::Callback>& cb, float minProbability)
|
Ptr<ERFilter> createERFilterNM2(const Ptr<ERFilter::Callback>& cb, float minProbability)
|
||||||
@ -1134,7 +1115,7 @@ Ptr<ERFilter> createERFilterNM2(const Ptr<ERFilter::Callback>& cb, float minProb
|
|||||||
Ptr<ERFilterNM> filter = makePtr<ERFilterNM>();
|
Ptr<ERFilterNM> filter = makePtr<ERFilterNM>();
|
||||||
|
|
||||||
if (cb == NULL)
|
if (cb == NULL)
|
||||||
filter->setCallback(makePtr<ERClassifierNM2>());
|
filter->setCallback(makePtr<ERClassifierNM2>("trained_classifierNM2.xml"));
|
||||||
else
|
else
|
||||||
filter->setCallback(cb);
|
filter->setCallback(cb);
|
||||||
|
|
||||||
@ -1144,25 +1125,23 @@ Ptr<ERFilter> createERFilterNM2(const Ptr<ERFilter::Callback>& cb, float minProb
|
|||||||
|
|
||||||
/*!
|
/*!
|
||||||
Allow to implicitly load the default classifier when creating an ERFilter object.
|
Allow to implicitly load the default classifier when creating an ERFilter object.
|
||||||
The function takes no parameters and returns a pointer to ERFilter::Callback.
|
The function takes as parameter the XML or YAML file with the classifier model
|
||||||
The dafault classifier is loaded from file trained_classifierNM1.xml
|
(e.g. trained_classifierNM1.xml) returns a pointer to ERFilter::Callback.
|
||||||
if it's found in current directory.
|
|
||||||
*/
|
*/
|
||||||
Ptr<ERFilter::Callback> getDefaultClassifierNM1()
|
Ptr<ERFilter::Callback> loadClassifierNM1(const std::string& filename)
|
||||||
|
|
||||||
{
|
{
|
||||||
return makePtr<ERClassifierNM1>();
|
return makePtr<ERClassifierNM1>(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
Allow to implicitly load the default classifier when creating an ERFilter object.
|
Allow to implicitly load the default classifier when creating an ERFilter object.
|
||||||
The function takes no parameters and returns a pointer to ERFilter::Callback.
|
The function takes as parameter the XML or YAML file with the classifier model
|
||||||
The dafault classifier is loaded from file trained_classifierNM2.xml
|
(e.g. trained_classifierNM2.xml) returns a pointer to ERFilter::Callback.
|
||||||
if it's found in current directory.
|
|
||||||
*/
|
*/
|
||||||
Ptr<ERFilter::Callback> getDefaultClassifierNM2()
|
Ptr<ERFilter::Callback> loadClassifierNM2(const std::string& filename)
|
||||||
{
|
{
|
||||||
return makePtr<ERClassifierNM2>();
|
return makePtr<ERClassifierNM2>(filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user