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
cb329400
Commit
cb329400
authored
Jan 30, 2013
by
marina.kolpakova
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix tests
parent
8d9c9c26
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
29 additions
and
114 deletions
+29
-114
perf_softcascade.cpp
modules/gpu/perf/perf_softcascade.cpp
+1
-50
icf-sc.cu
modules/gpu/src/cuda/icf-sc.cu
+1
-1
softcascade.cpp
modules/gpu/src/softcascade.cpp
+2
-14
test_softcascade.cpp
modules/gpu/test/test_softcascade.cpp
+25
-39
objdetect.hpp
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
+0
-10
No files found.
modules/gpu/perf/perf_softcascade.cpp
View file @
cb329400
...
...
@@ -194,52 +194,6 @@ RUN_GPU(SCascadeTestRoi, detectEachRoi)
NO_CPU
(
SCascadeTestRoi
,
detectEachRoi
)
SC_PERF_TEST_P
(
SCascadeTest
,
detectOnIntegral
,
testing
::
Combine
(
testing
::
Values
(
std
::
string
(
"cv/cascadeandhog/cascades/inria_caltech-17.01.2013.xml"
),
std
::
string
(
"cv/cascadeandhog/cascades/sc_cvpr_2012_to_opencv_new_format.xml"
)),
testing
::
Values
(
std
::
string
(
"cv/cascadeandhog/integrals.xml"
))))
static
std
::
string
itoa
(
long
i
)
{
static
char
s
[
65
];
sprintf
(
s
,
"%ld"
,
i
);
return
std
::
string
(
s
);
}
RUN_GPU
(
SCascadeTest
,
detectOnIntegral
)
{
cv
::
Mat
cpu
=
readImage
(
"cv/cascadeandhog/images/image_00000000_0.png"
);
ASSERT_FALSE
(
cpu
.
empty
());
cv
::
ICFPreprocessor
preprocessor
;
cv
::
Mat
test_res
(
cpu
.
rows
/
4
*
10
+
1
,
cpu
.
cols
/
4
+
1
,
CV_8UC1
);
preprocessor
.
apply
(
cpu
,
test_res
);
cv
::
gpu
::
SCascade
cascade
;
cv
::
FileStorage
fs
(
perf
::
TestBase
::
getDataPath
(
GET_PARAM
(
0
)),
cv
::
FileStorage
::
READ
);
ASSERT_TRUE
(
fs
.
isOpened
());
ASSERT_TRUE
(
cascade
.
load
(
fs
.
getFirstTopLevelNode
()));
cv
::
gpu
::
GpuMat
objectBoxes
(
1
,
10000
*
sizeof
(
cv
::
gpu
::
SCascade
::
Detection
),
CV_8UC1
),
rois
(
cv
::
Size
(
640
,
480
),
CV_8UC1
);
rois
.
setTo
(
1
);
cv
::
gpu
::
GpuMat
hogluv
(
test_res
);
cascade
.
detect
(
hogluv
,
rois
,
objectBoxes
);
TEST_CYCLE
()
{
cascade
.
detect
(
hogluv
,
rois
,
objectBoxes
);
}
SANITY_CHECK
(
sortDetections
(
objectBoxes
));
}
NO_CPU
(
SCascadeTest
,
detectOnIntegral
)
SC_PERF_TEST_P
(
SCascadeTest
,
detectStream
,
testing
::
Combine
(
testing
::
Values
(
std
::
string
(
"cv/cascadeandhog/cascades/inria_caltech-17.01.2013.xml"
),
...
...
@@ -271,10 +225,7 @@ RUN_GPU(SCascadeTest, detectStream)
cascade
.
detect
(
colored
,
rois
,
objectBoxes
,
s
);
}
#ifdef HAVE_CUDA
cudaDeviceSynchronize
();
#endif
s
.
waitForCompletion
();
SANITY_CHECK
(
sortDetections
(
objectBoxes
));
}
...
...
modules/gpu/src/cuda/icf-sc.cu
View file @
cb329400
...
...
@@ -547,7 +547,7 @@ void CascadeInvoker<Policy>::operator()(const PtrStepSzb& roi, const PtrStepSzi&
soft_cascade<Policy, false><<<grid, Policy::block(), 0, stream>>>(inv, det, max_det, ctr, 0);
cudaSafeCall( cudaGetLastError());
grid = dim3(fw, fh / Policy::STA_Y,
38
- downscales);
grid = dim3(fw, fh / Policy::STA_Y,
min(38, scales)
- downscales);
soft_cascade<Policy, true><<<grid, Policy::block(), 0, stream>>>(inv, det, max_det, ctr, downscales);
if (!stream)
...
...
modules/gpu/src/softcascade.cpp
View file @
cb329400
...
...
@@ -133,10 +133,6 @@ struct cv::gpu::SCascade::Fields
std
::
string
fformat
=
(
string
)
root
[
SC_FEATURE_FORMAT
];
bool
useBoxes
=
(
fformat
==
"BOX"
);
if
(
useBoxes
)
std
::
cout
<<
"use boxes!!!"
;
ushort
shrinkage
=
cv
::
saturate_cast
<
ushort
>
((
int
)
root
[
SC_SHRINKAGE
]);
FileNode
fn
=
root
[
SC_OCTAVES
];
...
...
@@ -154,13 +150,8 @@ struct cv::gpu::SCascade::Fields
{
FileNode
fns
=
*
it
;
float
scale
=
powf
(
2.
f
,
saturate_cast
<
float
>
((
int
)
fns
[
SC_OCT_SCALE
]));
std
::
cout
<<
"octave scale "
<<
scale
<<
std
::
endl
;
bool
isUPOctave
=
scale
>=
1
;
if
(
isUPOctave
)
std
::
cout
<<
"isUPOctave"
<<
std
::
endl
;
ushort
nweaks
=
saturate_cast
<
ushort
>
((
int
)
fns
[
SC_OCT_WEAKS
]);
ushort2
size
;
...
...
@@ -225,11 +216,9 @@ struct cv::gpu::SCascade::Fields
{
inIt
+=
2
;
int
featureIdx
=
(
int
)(
*
(
inIt
++
));
// std::cout << " featureIdx " << featureIdx << " " << feature_rects[featureIdx] << std::endl;
float
orig_threshold
=
(
float
)(
*
(
inIt
++
));
unsigned
int
th
=
saturate_cast
<
unsigned
int
>
((
int
)
orig_threshold
);
// std::cout << "orig_threshold " << orig_threshold << " converted " << th << std::endl;
cv
::
Rect
&
r
=
feature_rects
[
featureIdx
];
uchar4
rect
;
rect
.
x
=
saturate_cast
<
uchar
>
(
r
.
x
);
...
...
@@ -248,7 +237,6 @@ struct cv::gpu::SCascade::Fields
vleaves
.
push_back
((
float
)(
*
inIt
));
}
}
std
::
cout
<<
std
::
endl
;
}
cv
::
Mat
hoctaves
(
1
,
(
int
)
(
voctaves
.
size
()
*
sizeof
(
Octave
)),
CV_8UC1
,
(
uchar
*
)
&
(
voctaves
[
0
]));
...
...
@@ -424,7 +412,7 @@ public:
// 160x120x10
GpuMat
shrunk
;
// tempor
ial mat for integral
l
// tempor
al mat for integra
l
GpuMat
integralBuffer
;
// 161x121x10
...
...
@@ -591,7 +579,7 @@ private:
cv
::
gpu
::
cartToPolar
(
dfdx
,
dfdy
,
mag
,
ang
,
true
,
s
);
// norm
o
lize magnitude to uchar interval and angles to 6 bins
// norm
a
lize magnitude to uchar interval and angles to 6 bins
GpuMat
nmag
(
fplane
,
cv
::
Rect
(
0
,
4
*
fh
,
fw
,
fh
));
GpuMat
nang
(
fplane
,
cv
::
Rect
(
0
,
5
*
fh
,
fw
,
fh
));
...
...
modules/gpu/test/test_softcascade.cpp
View file @
cb329400
...
...
@@ -219,15 +219,30 @@ INSTANTIATE_TEST_CASE_P(GPU_SoftCascade, SCascadeTestRoi, testing::Combine(
testing
::
Range
(
0
,
5
)));
////////////////////////////////////////
PARAM_TEST_CASE
(
SCascadeTestAll
,
cv
::
gpu
::
DeviceInfo
,
std
::
string
)
namespace
{
struct
Fixture
{
std
::
string
path
;
int
expected
;
Fixture
(){}
Fixture
(
std
::
string
p
,
int
e
)
:
path
(
p
),
expected
(
e
)
{}
};
}
PARAM_TEST_CASE
(
SCascadeTestAll
,
cv
::
gpu
::
DeviceInfo
,
Fixture
)
{
std
::
string
xml
;
int
expected
;
virtual
void
SetUp
()
{
cv
::
gpu
::
setDevice
(
GET_PARAM
(
0
).
deviceID
());
xml
=
path
(
GET_PARAM
(
1
));
xml
=
path
(
GET_PARAM
(
1
).
path
);
expected
=
GET_PARAM
(
1
).
expected
;
}
};
...
...
@@ -265,34 +280,7 @@ GPU_TEST_P(SCascadeTestAll, detect)
}
SHOW
(
coloredCpu
);
// ASSERT_EQ(count, 2448);
}
GPU_TEST_P
(
SCascadeTestAll
,
detectOnIntegral
)
{
cv
::
gpu
::
SCascade
cascade
;
cv
::
FileStorage
fs
(
xml
,
cv
::
FileStorage
::
READ
);
ASSERT_TRUE
(
fs
.
isOpened
());
ASSERT_TRUE
(
cascade
.
load
(
fs
.
getFirstTopLevelNode
()));
cv
::
Mat
coloredCpu
=
cv
::
imread
(
path
(
"images/image_00000000_0.png"
));
cv
::
ICFPreprocessor
preprocessor
;
cv
::
Mat
integrals
(
coloredCpu
.
rows
/
4
*
10
+
1
,
coloredCpu
.
cols
/
4
+
1
,
CV_8UC1
);
preprocessor
.
apply
(
coloredCpu
,
integrals
);
GpuMat
hogluv
(
integrals
);
GpuMat
objectBoxes
(
1
,
100000
,
CV_8UC1
),
rois
(
cv
::
Size
(
640
,
480
),
CV_8UC1
);
rois
.
setTo
(
1
);
objectBoxes
.
setTo
(
0
);
cascade
.
detect
(
hogluv
,
rois
,
objectBoxes
);
// typedef cv::gpu::SCascade::Detection Detection;
// cv::Mat detections(objectBoxes);
// int a = *(detections.ptr<int>(0));
// ASSERT_EQ(a, 1024);
ASSERT_EQ
(
*
count
,
expected
);
}
GPU_TEST_P
(
SCascadeTestAll
,
detectStream
)
...
...
@@ -308,9 +296,7 @@ GPU_TEST_P(SCascadeTestAll, detectStream)
ASSERT_FALSE
(
coloredCpu
.
empty
());
GpuMat
colored
(
coloredCpu
),
objectBoxes
(
1
,
100000
,
CV_8UC1
),
rois
(
colored
.
size
(),
CV_8UC1
);
rois
.
setTo
(
0
);
GpuMat
sub
(
rois
,
cv
::
Rect
(
rois
.
cols
/
4
,
rois
.
rows
/
4
,
rois
.
cols
/
2
,
rois
.
rows
/
2
));
sub
.
setTo
(
cv
::
Scalar
::
all
(
1
));
rois
.
setTo
(
cv
::
Scalar
::
all
(
1
));
cv
::
gpu
::
Stream
s
;
...
...
@@ -318,14 +304,14 @@ GPU_TEST_P(SCascadeTestAll, detectStream)
cascade
.
detect
(
colored
,
rois
,
objectBoxes
,
s
);
s
.
waitForCompletion
();
//
typedef cv::gpu::SCascade::Detection Detection;
//
cv::Mat detections(objectBoxes);
//
int a = *(detections.ptr<int>(0));
// ASSERT_EQ(a, 2448
);
typedef
cv
::
gpu
::
SCascade
::
Detection
Detection
;
cv
::
Mat
detections
(
objectBoxes
);
int
a
=
*
(
detections
.
ptr
<
int
>
(
0
));
ASSERT_EQ
(
a
,
expected
);
}
INSTANTIATE_TEST_CASE_P
(
GPU_SoftCascade
,
SCascadeTestAll
,
testing
::
Combine
(
ALL_DEVICES
,
testing
::
Values
(
std
::
string
(
"cascades/inria_caltech-17.01.2013.xml"
),
std
::
string
(
"cascades/sc_cvpr_2012_to_opencv_new_format.xml"
))));
testing
::
Values
(
Fixture
(
"cascades/inria_caltech-17.01.2013.xml"
,
7
),
Fixture
(
"cascades/sc_cvpr_2012_to_opencv_new_format.xml"
,
1291
))));
#endif
modules/objdetect/include/opencv2/objdetect/objdetect.hpp
View file @
cb329400
...
...
@@ -488,16 +488,6 @@ protected:
Ptr
<
MaskGenerator
>
maskGenerator
;
};
class
CV_EXPORTS_W
ICFPreprocessor
{
public
:
CV_WRAP
ICFPreprocessor
();
CV_WRAP
void
apply
(
cv
::
InputArray
_frame
,
cv
::
OutputArray
_integrals
)
const
;
protected
:
enum
{
BINS
=
10
};
};
// Implementation of soft (stageless) cascaded detector.
class
CV_EXPORTS_W
SCascade
:
public
Algorithm
{
...
...
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