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
d2e88e1d
Commit
d2e88e1d
authored
Nov 26, 2012
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
nms: part 1
parent
a9f10e5c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
8 deletions
+95
-8
gpu.hpp
modules/gpu/include/opencv2/gpu/gpu.hpp
+4
-2
icf-sc.cu
modules/gpu/src/cuda/icf-sc.cu
+66
-1
gpu_init.cpp
modules/gpu/src/gpu_init.cpp
+4
-4
softcascade.cpp
modules/gpu/src/softcascade.cpp
+21
-1
No files found.
modules/gpu/include/opencv2/gpu/gpu.hpp
View file @
d2e88e1d
...
...
@@ -1552,12 +1552,14 @@ public:
enum
{
PEDESTRIAN
=
0
};
};
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 rejfactor is used for NMS.
SCascade
(
const
double
minScale
=
0.4
,
const
double
maxScale
=
5.
,
const
int
scales
=
55
,
const
int
rej
factor
=
1
);
SCascade
(
const
double
minScale
=
0.4
,
const
double
maxScale
=
5.
,
const
int
scales
=
55
,
const
int
rej
Criteria
=
1
);
virtual
~
SCascade
();
...
...
@@ -1595,7 +1597,7 @@ private:
double
maxScale
;
int
scales
;
int
rej
factor
;
int
rej
Criteria
;
};
////////////////////////////////// SURF //////////////////////////////////////////
...
...
modules/gpu/src/cuda/icf-sc.cu
View file @
d2e88e1d
...
...
@@ -41,9 +41,10 @@
//M*/
#include <opencv2/gpu/device/common.hpp>
#include <icf.hpp>
#include <stdio.h>
#include <float.h>
#include <stdio.h>
namespace cv { namespace gpu { namespace device {
namespace icf {
...
...
@@ -79,6 +80,70 @@ namespace icf {
}
}
__device__ __forceinline__ float overlapArea(const Detection &a, const Detection &b)
{
int w = ::min(a.x + a.w, b.x + b.w) - ::max(a.x, b.x);
int h = ::min(a.y + a.h, b.y + b.h) - ::max(a.y, b.y);
return (w < 0 || h < 0)? 0.f : (float)(w * h);
}
__global__ void overlap(const uint* n, const Detection* detections, uchar* overlaps)
{
const int idx = threadIdx.x;
const int total = *n;
for (int i = idx; i < total; i += 192)
{
const Detection& a = detections[i];
bool excluded = false;
for (int j = i + 1; j < total; ++j)
{
const Detection& b = detections[j];
float ovl = overlapArea(a, b) / ::min(a.w * a.h, b.w * b.h);
if (ovl > 0.65f)
{
int suppessed = (a.confidence > b.confidence)? j : i;
overlaps[suppessed] = 1;
excluded = excluded || (suppessed == i);
}
if (__all(excluded)) break;
}
}
}
__global__ void collect(const uint* n, const Detection* detections, uchar* overlaps)
{
const int idx = threadIdx.x;
const int total = *n;
for (int i = idx; i < total; i += 192)
{
if (!overlaps[i])
{
const Detection& det = detections[i];
// printf("%d: %d %d %d %d %f\n", i, det.x, det.y, det.w, det.h, det.confidence );
}
}
}
void suppress(const PtrStepSzb& objects, PtrStepSzb overlaps, PtrStepSzi ndetections)
{
int block = 192;
int grid = 1;
overlap<<<grid, block>>>((uint*)ndetections.ptr(0), (Detection*)objects.ptr(0), (uchar*)overlaps.ptr(0));
collect<<<grid, block>>>((uint*)ndetections.ptr(0), (Detection*)objects.ptr(0), (uchar*)overlaps.ptr(0));
// if (!stream)
{
cudaSafeCall( cudaGetLastError());
cudaSafeCall( cudaDeviceSynchronize());
}
}
template<typename Policy>
struct PrefixSum
{
...
...
modules/gpu/src/gpu_init.cpp
View file @
d2e88e1d
...
...
@@ -46,10 +46,10 @@ namespace cv { namespace gpu
{
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_gpu
(
void
)
{
...
...
modules/gpu/src/softcascade.cpp
View file @
d2e88e1d
...
...
@@ -85,6 +85,8 @@ namespace cv { namespace gpu { namespace device {
namespace
icf
{
void
fillBins
(
cv
::
gpu
::
PtrStepSzb
hogluv
,
const
cv
::
gpu
::
PtrStepSzf
&
nangle
,
const
int
fw
,
const
int
fh
,
const
int
bins
,
cudaStream_t
stream
);
void
suppress
(
const
PtrStepSzb
&
objects
,
PtrStepSzb
overlaps
,
PtrStepSzi
ndetections
);
}
namespace
imgproc
{
...
...
@@ -309,6 +311,8 @@ struct cv::gpu::SCascade::Fields
hogluv
.
create
((
fh
/
shr
)
*
HOG_LUV_BINS
+
1
,
fw
/
shr
+
1
,
CV_32SC1
);
hogluv
.
setTo
(
cv
::
Scalar
::
all
(
0
));
overlaps
.
create
(
1
,
5000
,
CV_8UC1
);
return
true
;
}
...
...
@@ -437,7 +441,15 @@ private:
}
}
#include <iostream>
public
:
void
suppress
(
GpuMat
&
ndetections
,
GpuMat
&
objects
)
{
ensureSizeIsEnough
(
objects
.
rows
,
objects
.
cols
,
CV_8UC1
,
overlaps
);
overlaps
.
setTo
(
0
);
device
::
icf
::
suppress
(
objects
,
overlaps
,
ndetections
);
// std::cout << cv::Mat(overlaps) << std::endl;
}
// scales range
float
minScale
;
...
...
@@ -469,6 +481,9 @@ public:
// 161x121x10
GpuMat
hogluv
;
// used for area overlap computing during
GpuMat
overlaps
;
// Cascade from xml
GpuMat
octaves
;
GpuMat
stages
;
...
...
@@ -478,6 +493,8 @@ public:
GpuMat
sobelBuf
;
GpuMat
collected
;
std
::
vector
<
device
::
icf
::
Octave
>
voctaves
;
DeviceInfo
info
;
...
...
@@ -494,7 +511,7 @@ public:
};
cv
::
gpu
::
SCascade
::
SCascade
(
const
double
mins
,
const
double
maxs
,
const
int
sc
,
const
int
rjf
)
:
fields
(
0
),
minScale
(
mins
),
maxScale
(
maxs
),
scales
(
sc
),
rej
factor
(
rjf
)
{}
:
fields
(
0
),
minScale
(
mins
),
maxScale
(
maxs
),
scales
(
sc
),
rej
Criteria
(
rjf
)
{}
cv
::
gpu
::
SCascade
::~
SCascade
()
{
delete
fields
;
}
...
...
@@ -534,6 +551,9 @@ void cv::gpu::SCascade::detect(InputArray image, InputArray _rois, OutputArray _
cudaStream_t
stream
=
StreamAccessor
::
getStream
(
s
);
flds
.
detect
(
rois
,
tmp
,
objects
,
stream
);
// if (rejCriteria != NO_REJECT)
flds
.
suppress
(
tmp
,
objects
);
}
void
cv
::
gpu
::
SCascade
::
genRoi
(
InputArray
_roi
,
OutputArray
_mask
,
Stream
&
stream
)
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