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
e20a93f7
Commit
e20a93f7
authored
Jul 11, 2016
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
imgproc test: Canny with custom gradient
parent
575de89e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
56 additions
and
12 deletions
+56
-12
test_canny.cpp
modules/imgproc/test/ocl/test_canny.cpp
+30
-7
test_canny.cpp
modules/imgproc/test/test_canny.cpp
+24
-3
ocl_test.hpp
modules/ts/include/opencv2/ts/ocl_test.hpp
+2
-2
No files found.
modules/imgproc/test/ocl/test_canny.cpp
View file @
e20a93f7
...
...
@@ -54,13 +54,13 @@ namespace ocl {
////////////////////////////////////////////////////////
// Canny
IMPLEMENT_PARAM_CLASS
(
Ap
p
ertureSize
,
int
)
IMPLEMENT_PARAM_CLASS
(
ApertureSize
,
int
)
IMPLEMENT_PARAM_CLASS
(
L2gradient
,
bool
)
IMPLEMENT_PARAM_CLASS
(
UseRoi
,
bool
)
PARAM_TEST_CASE
(
Canny
,
Channels
,
Ap
p
ertureSize
,
L2gradient
,
UseRoi
)
PARAM_TEST_CASE
(
Canny
,
Channels
,
ApertureSize
,
L2gradient
,
UseRoi
)
{
int
cn
,
ap
p
erture_size
;
int
cn
,
aperture_size
;
bool
useL2gradient
,
use_roi
;
TEST_DECLARE_INPUT_PARAMETER
(
src
);
...
...
@@ -69,7 +69,7 @@ PARAM_TEST_CASE(Canny, Channels, AppertureSize, L2gradient, UseRoi)
virtual
void
SetUp
()
{
cn
=
GET_PARAM
(
0
);
ap
p
erture_size
=
GET_PARAM
(
1
);
aperture_size
=
GET_PARAM
(
1
);
useL2gradient
=
GET_PARAM
(
2
);
use_roi
=
GET_PARAM
(
3
);
}
...
...
@@ -105,8 +105,31 @@ OCL_TEST_P(Canny, Accuracy)
eps
=
12e-3
;
#endif
OCL_OFF
(
cv
::
Canny
(
src_roi
,
dst_roi
,
low_thresh
,
high_thresh
,
apperture_size
,
useL2gradient
));
OCL_ON
(
cv
::
Canny
(
usrc_roi
,
udst_roi
,
low_thresh
,
high_thresh
,
apperture_size
,
useL2gradient
));
OCL_OFF
(
cv
::
Canny
(
src_roi
,
dst_roi
,
low_thresh
,
high_thresh
,
aperture_size
,
useL2gradient
));
OCL_ON
(
cv
::
Canny
(
usrc_roi
,
udst_roi
,
low_thresh
,
high_thresh
,
aperture_size
,
useL2gradient
));
EXPECT_MAT_SIMILAR
(
dst_roi
,
udst_roi
,
eps
);
EXPECT_MAT_SIMILAR
(
dst
,
udst
,
eps
);
}
OCL_TEST_P
(
Canny
,
AccuracyCustomGradient
)
{
generateTestData
();
const
double
low_thresh
=
50.0
,
high_thresh
=
100.0
;
double
eps
=
1e-2
;
#ifdef ANDROID
if
(
cv
::
ocl
::
Device
::
getDefault
().
isNVidia
())
eps
=
12e-3
;
#endif
OCL_OFF
(
cv
::
Canny
(
src_roi
,
dst_roi
,
low_thresh
,
high_thresh
,
aperture_size
,
useL2gradient
));
OCL_ON
(
UMat
dx
,
dy
;
Sobel
(
usrc_roi
,
dx
,
CV_16S
,
1
,
0
,
aperture_size
,
1
,
0
,
BORDER_REPLICATE
);
Sobel
(
usrc_roi
,
dy
,
CV_16S
,
0
,
1
,
aperture_size
,
1
,
0
,
BORDER_REPLICATE
);
cv
::
Canny
(
dx
,
dy
,
udst_roi
,
low_thresh
,
high_thresh
,
useL2gradient
);
);
EXPECT_MAT_SIMILAR
(
dst_roi
,
udst_roi
,
eps
);
EXPECT_MAT_SIMILAR
(
dst
,
udst
,
eps
);
...
...
@@ -114,7 +137,7 @@ OCL_TEST_P(Canny, Accuracy)
OCL_INSTANTIATE_TEST_CASE_P
(
ImgProc
,
Canny
,
testing
::
Combine
(
testing
::
Values
(
1
,
3
),
testing
::
Values
(
Ap
pertureSize
(
3
),
Ap
pertureSize
(
5
)),
testing
::
Values
(
Ap
ertureSize
(
3
),
A
pertureSize
(
5
)),
testing
::
Values
(
L2gradient
(
false
),
L2gradient
(
true
)),
testing
::
Values
(
UseRoi
(
false
),
UseRoi
(
true
))));
...
...
modules/imgproc/test/test_canny.cpp
View file @
e20a93f7
...
...
@@ -47,7 +47,7 @@ using namespace std;
class
CV_CannyTest
:
public
cvtest
::
ArrayTest
{
public
:
CV_CannyTest
();
CV_CannyTest
(
bool
custom_deriv
=
false
);
protected
:
void
get_test_array_types_and_sizes
(
int
test_case_idx
,
vector
<
vector
<
Size
>
>&
sizes
,
vector
<
vector
<
int
>
>&
types
);
...
...
@@ -61,10 +61,11 @@ protected:
bool
use_true_gradient
;
double
threshold1
,
threshold2
;
bool
test_cpp
;
bool
test_custom_deriv
;
};
CV_CannyTest
::
CV_CannyTest
()
CV_CannyTest
::
CV_CannyTest
(
bool
custom_deriv
)
{
test_array
[
INPUT
].
push_back
(
NULL
);
test_array
[
OUTPUT
].
push_back
(
NULL
);
...
...
@@ -75,6 +76,7 @@ CV_CannyTest::CV_CannyTest()
threshold1
=
threshold2
=
0
;
test_cpp
=
false
;
test_custom_deriv
=
custom_deriv
;
}
...
...
@@ -99,6 +101,9 @@ void CV_CannyTest::get_test_array_types_and_sizes( int test_case_idx,
use_true_gradient
=
cvtest
::
randInt
(
rng
)
%
2
!=
0
;
test_cpp
=
(
cvtest
::
randInt
(
rng
)
&
256
)
==
0
;
ts
->
printf
(
cvtest
::
TS
::
LOG
,
"Canny(size = %d x %d, aperture_size = %d, threshold1 = %g, threshold2 = %g, L2 = %s) test_cpp = %s (test case #%d)
\n
"
,
sizes
[
0
][
0
].
width
,
sizes
[
0
][
0
].
height
,
aperture_size
,
threshold1
,
threshold2
,
use_true_gradient
?
"TRUE"
:
"FALSE"
,
test_cpp
?
"TRUE"
:
"FALSE"
,
test_case_idx
);
}
...
...
@@ -123,9 +128,24 @@ double CV_CannyTest::get_success_error_level( int /*test_case_idx*/, int /*i*/,
void
CV_CannyTest
::
run_func
()
{
if
(
!
test_cpp
)
if
(
test_custom_deriv
)
{
cv
::
Mat
_out
=
cv
::
cvarrToMat
(
test_array
[
OUTPUT
][
0
]);
cv
::
Mat
src
=
cv
::
cvarrToMat
(
test_array
[
INPUT
][
0
]);
cv
::
Mat
dx
,
dy
;
int
m
=
aperture_size
;
Point
anchor
(
m
/
2
,
m
/
2
);
Mat
dxkernel
=
cvtest
::
calcSobelKernel2D
(
1
,
0
,
m
,
0
);
Mat
dykernel
=
cvtest
::
calcSobelKernel2D
(
0
,
1
,
m
,
0
);
cvtest
::
filter2D
(
src
,
dx
,
CV_16S
,
dxkernel
,
anchor
,
0
,
BORDER_REPLICATE
);
cvtest
::
filter2D
(
src
,
dy
,
CV_16S
,
dykernel
,
anchor
,
0
,
BORDER_REPLICATE
);
cv
::
Canny
(
dx
,
dy
,
_out
,
threshold1
,
threshold2
,
use_true_gradient
);
}
else
if
(
!
test_cpp
)
{
cvCanny
(
test_array
[
INPUT
][
0
],
test_array
[
OUTPUT
][
0
],
threshold1
,
threshold2
,
aperture_size
+
(
use_true_gradient
?
CV_CANNY_L2_GRADIENT
:
0
));
}
else
{
cv
::
Mat
_out
=
cv
::
cvarrToMat
(
test_array
[
OUTPUT
][
0
]);
...
...
@@ -283,5 +303,6 @@ int CV_CannyTest::validate_test_results( int test_case_idx )
}
TEST
(
Imgproc_Canny
,
accuracy
)
{
CV_CannyTest
test
;
test
.
safe_run
();
}
TEST
(
Imgproc_Canny
,
accuracy_deriv
)
{
CV_CannyTest
test
(
true
);
test
.
safe_run
();
}
/* End of file. */
modules/ts/include/opencv2/ts/ocl_test.hpp
View file @
e20a93f7
...
...
@@ -349,8 +349,8 @@ IMPLEMENT_PARAM_CLASS(Channels, int)
#define OCL_TEST_F(name, ...) typedef name OCL_##name; TEST_F(OCL_##name, __VA_ARGS__)
#define OCL_TEST(name, ...) TEST(OCL_##name, __VA_ARGS__)
#define OCL_OFF(
fn) cv::ocl::setUseOpenCL(false); fn
#define OCL_ON(
fn) cv::ocl::setUseOpenCL(true); fn
#define OCL_OFF(
...) cv::ocl::setUseOpenCL(false); __VA_ARGS__ ;
#define OCL_ON(
...) cv::ocl::setUseOpenCL(true); __VA_ARGS__ ;
#define OCL_ALL_DEPTHS Values(CV_8U, CV_8S, CV_16U, CV_16S, CV_32S, CV_32F, CV_64F)
#define OCL_ALL_CHANNELS Values(1, 2, 3, 4)
...
...
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