From d25309f82e1bb67ea17dfdabe01a2de1dfc13ec0 Mon Sep 17 00:00:00 2001 From: lluis Date: Fri, 13 Sep 2013 16:29:21 +0200 Subject: [PATCH] first parameter of createERFilterNM1/createERFilterNM2 is now mandatory. changed the sample program to use the new prototypes --- .../include/opencv2/objdetect/erfilter.hpp | 8 ++++---- modules/objdetect/src/erfilter.cpp | 16 ++++------------ samples/cpp/erfilter.cpp | 4 ++-- 3 files changed, 10 insertions(+), 18 deletions(-) diff --git a/modules/objdetect/include/opencv2/objdetect/erfilter.hpp b/modules/objdetect/include/opencv2/objdetect/erfilter.hpp index 6f45a88b01..69809a8d17 100644 --- a/modules/objdetect/include/opencv2/objdetect/erfilter.hpp +++ b/modules/objdetect/include/opencv2/objdetect/erfilter.hpp @@ -164,8 +164,8 @@ public: local minimum is greater than minProbabilityDiff). \param cb Callback with the classifier. - if omitted tries to load a default classifier from file trained_classifierNM1.xml default classifier can be implicitly load with function loadClassifierNM1() + from file in samples/cpp/trained_classifierNM1.xml \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 maximum area (% of image size) allowed for retreived ER's @@ -173,7 +173,7 @@ public: \param nonMaxSuppression Whenever non-maximum suppression is done over the branch probabilities \param minProbability The minimum probability difference between local maxima and local minima ERs */ -CV_EXPORTS Ptr createERFilterNM1(const Ptr& cb = Ptr(), +CV_EXPORTS Ptr createERFilterNM1(const Ptr& cb, int thresholdDelta = 1, float minArea = 0.00025, float maxArea = 0.13, float minProbability = 0.4, bool nonMaxSuppression = true, @@ -189,11 +189,11 @@ CV_EXPORTS Ptr createERFilterNM1(const Ptr& cb = P additional features: hole area ratio, convex hull ratio, and number of outer inflexion points. \param cb Callback with the classifier - if omitted tries to load a default classifier from file trained_classifierNM2.xml default classifier can be implicitly load with function loadClassifierNM2() + from file in samples/cpp/trained_classifierNM2.xml \param minProbability The minimum probability P(er|character) allowed for retreived ER's */ -CV_EXPORTS Ptr createERFilterNM2(const Ptr& cb = Ptr(), +CV_EXPORTS Ptr createERFilterNM2(const Ptr& cb, float minProbability = 0.3); diff --git a/modules/objdetect/src/erfilter.cpp b/modules/objdetect/src/erfilter.cpp index dc3b30bfe2..6e19b34bac 100644 --- a/modules/objdetect/src/erfilter.cpp +++ b/modules/objdetect/src/erfilter.cpp @@ -1056,8 +1056,8 @@ double ERClassifierNM2::eval(const ERStat& stat) local minimum is greater than minProbabilityDiff). \param cb Callback with the classifier. - if omitted tries to load a default classifier from file trained_classifierNM1.xml default classifier can be implicitly load with function loadClassifierNM1() + from file in samples/cpp/trained_classifierNM1.xml \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 maximum area (% of image size) allowed for retreived ER's @@ -1077,12 +1077,7 @@ Ptr createERFilterNM1(const Ptr& cb, int threshold Ptr filter = makePtr(); - if (cb == NULL) - filter->setCallback(makePtr("trained_classifierNM1.xml")); - else - filter->setCallback(cb); - - + filter->setCallback(cb); filter->setThresholdDelta(thresholdDelta); filter->setMinArea(minArea); @@ -1103,8 +1098,8 @@ Ptr createERFilterNM1(const Ptr& cb, int threshold additional features: hole area ratio, convex hull ratio, and number of outer inflexion points. \param cb Callback with the classifier - if omitted tries to load a default classifier from file trained_classifierNM2.xml default classifier can be implicitly load with function loadClassifierNM1() + from file in samples/cpp/trained_classifierNM2.xml \param minProbability The minimum probability P(er|character) allowed for retreived ER's */ Ptr createERFilterNM2(const Ptr& cb, float minProbability) @@ -1114,10 +1109,7 @@ Ptr createERFilterNM2(const Ptr& cb, float minProb Ptr filter = makePtr(); - if (cb == NULL) - filter->setCallback(makePtr("trained_classifierNM2.xml")); - else - filter->setCallback(cb); + filter->setCallback(cb); filter->setMinProbability(minProbability); return (Ptr)filter; diff --git a/samples/cpp/erfilter.cpp b/samples/cpp/erfilter.cpp index 8a2a45f9c4..69009b82aa 100644 --- a/samples/cpp/erfilter.cpp +++ b/samples/cpp/erfilter.cpp @@ -58,7 +58,7 @@ int main(int argc, const char * argv[]) double t = (double)getTickCount(); // Build ER tree and filter with the 1st stage default classifier - Ptr er_filter1 = createERFilterNM1(); + Ptr er_filter1 = createERFilterNM1(loadClassifierNM1("trained_classifierNM1.xml")); er_filter1->run(grey, regions); @@ -89,7 +89,7 @@ int main(int argc, const char * argv[]) t = (double)getTickCount(); // Default second stage classifier - Ptr er_filter2 = createERFilterNM2(); + Ptr er_filter2 = createERFilterNM2(loadClassifierNM2("trained_classifierNM2.xml")); er_filter2->run(grey, regions); t = (double)getTickCount() - t;