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
464826c2
Commit
464826c2
authored
Dec 12, 2012
by
cuda-geek
Committed by
OpenCV Buildbot
Dec 12, 2012
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #181 from cuda-geek:nms
parents
eaeae4a1
2d45af79
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
65 additions
and
8 deletions
+65
-8
objdetect.hpp
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
+5
-3
objdetect_init.cpp
modules/objdetect/src/objdetect_init.cpp
+4
-4
softcascade.cpp
modules/objdetect/src/softcascade.cpp
+56
-1
No files found.
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
View file @
464826c2
...
...
@@ -534,12 +534,14 @@ public:
int
shrinkage
;
};
enum
{
NO_REJECT
=
1
,
DOLLAR
=
2
,
/*PASCAL = 4,*/
DEFAULT
=
NO_REJECT
};
// An empty cascade will be created.
// Param minScale is a minimum scale relative to the original size of the image on which cascade will be applyed.
// Param minScale is a maximum scale relative to the original size of the image on which cascade will be applyed.
// Param scales is a number of scales from minScale to maxScale.
// Param rej
factor
is used for NMS.
CV_WRAP
SCascade
(
const
double
minScale
=
0.4
,
const
double
maxScale
=
5.
,
const
int
scales
=
55
,
const
int
rej
factor
=
1
);
// Param rej
Criteria
is used for NMS.
CV_WRAP
SCascade
(
const
double
minScale
=
0.4
,
const
double
maxScale
=
5.
,
const
int
scales
=
55
,
const
int
rej
Criteria
=
1
);
CV_WRAP
virtual
~
SCascade
();
...
...
@@ -571,7 +573,7 @@ private:
double
maxScale
;
int
scales
;
int
rej
factor
;
int
rej
Criteria
;
};
CV_EXPORTS
bool
initModule_objdetect
(
void
);
...
...
modules/objdetect/src/objdetect_init.cpp
View file @
464826c2
...
...
@@ -46,10 +46,10 @@ namespace cv
{
CV_INIT_ALGORITHM
(
SCascade
,
"CascadeDetector.SCascade"
,
obj
.
info
()
->
addParam
(
obj
,
"minScale"
,
obj
.
minScale
);
obj
.
info
()
->
addParam
(
obj
,
"maxScale"
,
obj
.
maxScale
);
obj
.
info
()
->
addParam
(
obj
,
"scales"
,
obj
.
scales
);
obj
.
info
()
->
addParam
(
obj
,
"rej
factor"
,
obj
.
rejfactor
));
obj
.
info
()
->
addParam
(
obj
,
"minScale"
,
obj
.
minScale
);
obj
.
info
()
->
addParam
(
obj
,
"maxScale"
,
obj
.
maxScale
);
obj
.
info
()
->
addParam
(
obj
,
"scales"
,
obj
.
scales
);
obj
.
info
()
->
addParam
(
obj
,
"rej
Criteria"
,
obj
.
rejCriteria
));
bool
initModule_objdetect
(
void
)
{
...
...
modules/objdetect/src/softcascade.cpp
View file @
464826c2
...
...
@@ -422,7 +422,7 @@ struct cv::SCascade::Fields
};
cv
::
SCascade
::
SCascade
(
const
double
mins
,
const
double
maxs
,
const
int
nsc
,
const
int
rej
)
:
fields
(
0
),
minScale
(
mins
),
maxScale
(
maxs
),
scales
(
nsc
),
rej
factor
(
rej
)
{}
:
fields
(
0
),
minScale
(
mins
),
maxScale
(
maxs
),
scales
(
nsc
),
rej
Criteria
(
rej
)
{}
cv
::
SCascade
::~
SCascade
()
{
delete
fields
;}
...
...
@@ -439,6 +439,57 @@ bool cv::SCascade::load(const FileNode& fn)
return
fields
->
fill
(
fn
);
}
namespace
{
typedef
cv
::
SCascade
::
Detection
Detection
;
typedef
std
::
vector
<
Detection
>
dvector
;
struct
ConfidenceGt
{
bool
operator
()(
const
Detection
&
a
,
const
Detection
&
b
)
const
{
return
a
.
confidence
>
b
.
confidence
;
}
};
static
float
overlap
(
const
cv
::
Rect
&
a
,
const
cv
::
Rect
&
b
)
{
int
w
=
std
::
min
(
a
.
x
+
a
.
width
,
b
.
x
+
b
.
width
)
-
std
::
max
(
a
.
x
,
b
.
x
);
int
h
=
std
::
min
(
a
.
y
+
a
.
height
,
b
.
y
+
b
.
height
)
-
std
::
max
(
a
.
y
,
b
.
y
);
return
(
w
<
0
||
h
<
0
)
?
0.
f
:
(
float
)(
w
*
h
);
}
void
DollarNMS
(
dvector
&
objects
)
{
static
const
float
DollarThreshold
=
0.65
f
;
std
::
sort
(
objects
.
begin
(),
objects
.
end
(),
ConfidenceGt
());
for
(
dvector
::
iterator
dIt
=
objects
.
begin
();
dIt
!=
objects
.
end
();
++
dIt
)
{
const
Detection
&
a
=
*
dIt
;
for
(
dvector
::
iterator
next
=
dIt
+
1
;
next
!=
objects
.
end
();
)
{
const
Detection
&
b
=
*
next
;
const
float
ovl
=
overlap
(
a
.
bb
,
b
.
bb
)
/
std
::
min
(
a
.
bb
.
area
(),
b
.
bb
.
area
());
if
(
ovl
>
DollarThreshold
)
next
=
objects
.
erase
(
next
);
else
++
next
;
}
}
}
static
void
suppress
(
int
type
,
std
::
vector
<
Detection
>&
objects
)
{
CV_Assert
(
type
==
cv
::
SCascade
::
DOLLAR
);
DollarNMS
(
objects
);
}
}
void
cv
::
SCascade
::
detectNoRoi
(
const
cv
::
Mat
&
image
,
std
::
vector
<
Detection
>&
objects
)
const
{
Fields
&
fld
=
*
fields
;
...
...
@@ -459,6 +510,8 @@ void cv::SCascade::detectNoRoi(const cv::Mat& image, std::vector<Detection>& obj
}
}
}
if
(
rejCriteria
!=
NO_REJECT
)
suppress
(
rejCriteria
,
objects
);
}
void
cv
::
SCascade
::
detect
(
cv
::
InputArray
_image
,
cv
::
InputArray
_rois
,
std
::
vector
<
Detection
>&
objects
)
const
...
...
@@ -506,6 +559,8 @@ void cv::SCascade::detect(cv::InputArray _image, cv::InputArray _rois, std::vect
}
}
}
if
(
rejCriteria
!=
NO_REJECT
)
suppress
(
rejCriteria
,
objects
);
}
void
cv
::
SCascade
::
detect
(
InputArray
_image
,
InputArray
_rois
,
OutputArray
_rects
,
OutputArray
_confs
)
const
...
...
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