Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
ad404ef4
Commit
ad404ef4
authored
Sep 17, 2013
by
Andrey Pavlenko
Committed by
OpenCV Buildbot
Sep 17, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1446 from lluisgomez:scene_text_detection_NM_fix2
parents
eff21788
d25309f8
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
61 additions
and
47 deletions
+61
-47
erfilter.hpp
modules/objdetect/include/opencv2/objdetect/erfilter.hpp
+24
-4
erfilter.cpp
modules/objdetect/src/erfilter.cpp
+35
-41
erfilter.cpp
samples/cpp/erfilter.cpp
+2
-2
No files found.
modules/objdetect/include/opencv2/objdetect/erfilter.hpp
View file @
ad404ef4
...
...
@@ -47,6 +47,7 @@
#include "opencv2/core.hpp"
#include <vector>
#include <deque>
#include <string>
namespace
cv
{
...
...
@@ -163,7 +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
...
...
@@ -171,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
<
ERFilter
>
createERFilterNM1
(
const
Ptr
<
ERFilter
::
Callback
>&
cb
=
Ptr
<
ERFilter
::
Callback
>
()
,
CV_EXPORTS
Ptr
<
ERFilter
>
createERFilterNM1
(
const
Ptr
<
ERFilter
::
Callback
>&
cb
,
int
thresholdDelta
=
1
,
float
minArea
=
0.00025
,
float
maxArea
=
0.13
,
float
minProbability
=
0.4
,
bool
nonMaxSuppression
=
true
,
...
...
@@ -187,13 +189,31 @@ CV_EXPORTS Ptr<ERFilter> createERFilterNM1(const Ptr<ERFilter::Callback>& 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
<
ERFilter
>
createERFilterNM2
(
const
Ptr
<
ERFilter
::
Callback
>&
cb
=
Ptr
<
ERFilter
::
Callback
>
()
,
CV_EXPORTS
Ptr
<
ERFilter
>
createERFilterNM2
(
const
Ptr
<
ERFilter
::
Callback
>&
cb
,
float
minProbability
=
0.3
);
/*!
Allow to implicitly load the default classifier when creating an ERFilter object.
The function takes as parameter the XML or YAML file with the classifier model
(e.g. trained_classifierNM1.xml) returns a pointer to ERFilter::Callback.
*/
CV_EXPORTS
Ptr
<
ERFilter
::
Callback
>
loadClassifierNM1
(
const
std
::
string
&
filename
);
/*!
Allow to implicitly load the default classifier when creating an ERFilter object.
The function takes as parameter the XML or YAML file with the classifier model
(e.g. trained_classifierNM1.xml) returns a pointer to ERFilter::Callback.
*/
CV_EXPORTS
Ptr
<
ERFilter
::
Callback
>
loadClassifierNM2
(
const
std
::
string
&
filename
);
// computeNMChannels operation modes
enum
{
ERFILTER_NM_RGBLGrad
=
0
,
ERFILTER_NM_IHSGrad
=
1
...
...
modules/objdetect/src/erfilter.cpp
View file @
ad404ef4
...
...
@@ -137,7 +137,7 @@ class CV_EXPORTS ERClassifierNM1 : public ERFilter::Callback
{
public
:
//Constructor
ERClassifierNM1
();
ERClassifierNM1
(
const
std
::
string
&
filename
);
// Destructor
~
ERClassifierNM1
()
{};
...
...
@@ -153,7 +153,7 @@ class CV_EXPORTS ERClassifierNM2 : public ERFilter::Callback
{
public
:
//constructor
ERClassifierNM2
();
ERClassifierNM2
(
const
std
::
string
&
filename
);
// Destructor
~
ERClassifierNM2
()
{};
...
...
@@ -988,24 +988,13 @@ int ERFilterNM::getNumRejected()
// load default 1st stage classifier if found
ERClassifierNM1
::
ERClassifierNM1
()
ERClassifierNM1
::
ERClassifierNM1
(
const
std
::
string
&
filename
)
{
if
(
ifstream
(
"./trained_classifierNM1.xml"
))
{
// 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"
);
}
if
(
ifstream
(
filename
.
c_str
()))
boost
.
load
(
filename
.
c_str
(),
"boost"
);
else
{
// File not found
CV_Error
(
CV_StsBadArg
,
"Default classifier ./trained_classifierNM1.xml not found!"
);
}
CV_Error
(
CV_StsBadArg
,
"Default classifier file not found!"
);
};
double
ERClassifierNM1
::
eval
(
const
ERStat
&
stat
)
...
...
@@ -1026,24 +1015,12 @@ double ERClassifierNM1::eval(const ERStat& stat)
// load default 2nd stage classifier if found
ERClassifierNM2
::
ERClassifierNM2
()
ERClassifierNM2
::
ERClassifierNM2
(
const
std
::
string
&
filename
)
{
if
(
ifstream
(
"./trained_classifierNM2.xml"
))
{
// 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"
);
}
if
(
ifstream
(
filename
.
c_str
()))
boost
.
load
(
filename
.
c_str
(),
"boost"
);
else
{
// File not found
CV_Error
(
CV_StsBadArg
,
"Default classifier ./trained_classifierNM2.xml not found!"
);
}
CV_Error
(
CV_StsBadArg
,
"Default classifier file not found!"
);
};
double
ERClassifierNM2
::
eval
(
const
ERStat
&
stat
)
...
...
@@ -1079,7 +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
...
...
@@ -1099,9 +1077,6 @@ Ptr<ERFilter> createERFilterNM1(const Ptr<ERFilter::Callback>& cb, int threshold
Ptr
<
ERFilterNM
>
filter
=
makePtr
<
ERFilterNM
>
();
if
(
cb
==
NULL
)
filter
->
setCallback
(
makePtr
<
ERClassifierNM1
>
());
else
filter
->
setCallback
(
cb
);
filter
->
setThresholdDelta
(
thresholdDelta
);
...
...
@@ -1123,7 +1098,8 @@ Ptr<ERFilter> createERFilterNM1(const Ptr<ERFilter::Callback>& 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
<
ERFilter
>
createERFilterNM2
(
const
Ptr
<
ERFilter
::
Callback
>&
cb
,
float
minProbability
)
...
...
@@ -1133,15 +1109,33 @@ Ptr<ERFilter> createERFilterNM2(const Ptr<ERFilter::Callback>& cb, float minProb
Ptr
<
ERFilterNM
>
filter
=
makePtr
<
ERFilterNM
>
();
if
(
cb
==
NULL
)
filter
->
setCallback
(
makePtr
<
ERClassifierNM2
>
());
else
filter
->
setCallback
(
cb
);
filter
->
setMinProbability
(
minProbability
);
return
(
Ptr
<
ERFilter
>
)
filter
;
}
/*!
Allow to implicitly load the default classifier when creating an ERFilter object.
The function takes as parameter the XML or YAML file with the classifier model
(e.g. trained_classifierNM1.xml) returns a pointer to ERFilter::Callback.
*/
Ptr
<
ERFilter
::
Callback
>
loadClassifierNM1
(
const
std
::
string
&
filename
)
{
return
makePtr
<
ERClassifierNM1
>
(
filename
);
}
/*!
Allow to implicitly load the default classifier when creating an ERFilter object.
The function takes as parameter the XML or YAML file with the classifier model
(e.g. trained_classifierNM2.xml) returns a pointer to ERFilter::Callback.
*/
Ptr
<
ERFilter
::
Callback
>
loadClassifierNM2
(
const
std
::
string
&
filename
)
{
return
makePtr
<
ERClassifierNM2
>
(
filename
);
}
/* ------------------------------------------------------------------------------------*/
/* -------------------------------- Compute Channels NM -------------------------------*/
...
...
samples/cpp/erfilter.cpp
View file @
ad404ef4
...
...
@@ -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
<
ERFilter
>
er_filter1
=
createERFilterNM1
();
Ptr
<
ERFilter
>
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
<
ERFilter
>
er_filter2
=
createERFilterNM2
();
Ptr
<
ERFilter
>
er_filter2
=
createERFilterNM2
(
loadClassifierNM2
(
"trained_classifierNM2.xml"
)
);
er_filter2
->
run
(
grey
,
regions
);
t
=
(
double
)
getTickCount
()
-
t
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment