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
a99118c4
Commit
a99118c4
authored
Dec 09, 2016
by
apavlenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moving CannyVX test from ocl to cpp file
parent
4246d366
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
103 additions
and
84 deletions
+103
-84
test_canny.cpp
modules/imgproc/test/ocl/test_canny.cpp
+0
-84
test_canny.cpp
modules/imgproc/test/test_canny.cpp
+103
-0
No files found.
modules/imgproc/test/ocl/test_canny.cpp
View file @
a99118c4
...
...
@@ -133,90 +133,6 @@ OCL_INSTANTIATE_TEST_CASE_P(ImgProc, Canny, testing::Combine(
testing
::
Values
(
L2gradient
(
false
),
L2gradient
(
true
)),
testing
::
Values
(
UseRoi
(
false
),
UseRoi
(
true
))));
IMPLEMENT_PARAM_CLASS
(
ImagePath
,
string
)
//IMPLEMENT_PARAM_CLASS(ApertureSize, int)
//IMPLEMENT_PARAM_CLASS(L2gradient, bool)
PARAM_TEST_CASE
(
CannyVX
,
ImagePath
,
ApertureSize
,
L2gradient
)
{
string
imgPath
;
int
kSize
;
bool
useL2
;
TEST_DECLARE_INPUT_PARAMETER
(
src
);
TEST_DECLARE_OUTPUT_PARAMETER
(
dst
);
virtual
void
SetUp
()
{
imgPath
=
GET_PARAM
(
0
);
kSize
=
GET_PARAM
(
1
);
useL2
=
GET_PARAM
(
2
);
}
void
loadImage
()
{
src
=
readImage
(
imgPath
,
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
src
.
empty
())
<<
"cann't load image: "
<<
imgPath
;
}
};
TEST_P
(
CannyVX
,
Accuracy
)
{
if
(
haveOpenVX
())
{
loadImage
();
setUseOpenVX
(
false
);
Mat
canny
;
cv
::
Canny
(
src
,
canny
,
100
,
150
,
3
);
setUseOpenVX
(
true
);
Mat
cannyVX
;
cv
::
Canny
(
src
,
cannyVX
,
100
,
150
,
3
);
setUseOpenVX
(
false
);
Mat
diff
,
diff1
;
absdiff
(
canny
,
cannyVX
,
diff
);
boxFilter
(
diff
,
diff1
,
-
1
,
Size
(
3
,
3
));
diff1
=
diff1
>
255
/
9
*
3
;
erode
(
diff1
,
diff1
,
Mat
());
double
error
=
cv
::
norm
(
diff1
,
NORM_L1
)
/
255
;
const
int
maxError
=
10
;
if
(
error
>
maxError
)
{
string
outPath
=
string
(
"CannyVX-diff-"
)
+
imgPath
+
'-'
+
'k'
+
char
(
kSize
+
'0'
)
+
'-'
+
(
useL2
?
"l2"
:
"l1"
);
std
::
replace
(
outPath
.
begin
(),
outPath
.
end
(),
'/'
,
'_'
);
std
::
replace
(
outPath
.
begin
(),
outPath
.
end
(),
'\\'
,
'_'
);
std
::
replace
(
outPath
.
begin
(),
outPath
.
end
(),
'.'
,
'_'
);
imwrite
(
outPath
+
".png"
,
diff
);
}
ASSERT_LE
(
error
,
maxError
);
}
}
INSTANTIATE_TEST_CASE_P
(
ImgProc
,
CannyVX
,
testing
::
Combine
(
testing
::
Values
(
string
(
"shared/baboon.png"
),
string
(
"shared/fruits.png"
),
string
(
"shared/lena.png"
),
string
(
"shared/pic1.png"
),
string
(
"shared/pic3.png"
),
string
(
"shared/pic5.png"
),
string
(
"shared/pic6.png"
)
),
testing
::
Values
(
ApertureSize
(
3
),
ApertureSize
(
5
)),
testing
::
Values
(
L2gradient
(
false
),
L2gradient
(
true
))
)
);
}
// namespace ocl
}
// namespace cvtest
...
...
modules/imgproc/test/test_canny.cpp
View file @
a99118c4
...
...
@@ -306,4 +306,107 @@ int CV_CannyTest::validate_test_results( int test_case_idx )
TEST
(
DISABLED_Imgproc_Canny
,
accuracy
)
{
CV_CannyTest
test
;
test
.
safe_run
();
}
TEST
(
DISABLED_Imgproc_Canny
,
accuracy_deriv
)
{
CV_CannyTest
test
(
true
);
test
.
safe_run
();
}
/*
* Comparing OpenVX based implementation with the main one
*/
#ifndef IMPLEMENT_PARAM_CLASS
#define IMPLEMENT_PARAM_CLASS(name, type) \
class name \
{ \
public: \
name ( type arg = type ()) : val_(arg) {} \
operator type () const {return val_;} \
private: \
type val_; \
}; \
inline void PrintTo( name param, std::ostream* os) \
{ \
*os << #name << "(" << testing::PrintToString(static_cast< type >(param)) << ")"; \
}
#endif // IMPLEMENT_PARAM_CLASS
IMPLEMENT_PARAM_CLASS
(
ImagePath
,
string
)
IMPLEMENT_PARAM_CLASS
(
ApertureSize
,
int
)
IMPLEMENT_PARAM_CLASS
(
L2gradient
,
bool
)
PARAM_TEST_CASE
(
CannyVX
,
ImagePath
,
ApertureSize
,
L2gradient
)
{
string
imgPath
;
int
kSize
;
bool
useL2
;
Mat
src
,
dst
;
virtual
void
SetUp
()
{
imgPath
=
GET_PARAM
(
0
);
kSize
=
GET_PARAM
(
1
);
useL2
=
GET_PARAM
(
2
);
}
void
loadImage
()
{
src
=
cv
::
imread
(
cvtest
::
TS
::
ptr
()
->
get_data_path
()
+
imgPath
,
IMREAD_GRAYSCALE
);
ASSERT_FALSE
(
src
.
empty
())
<<
"cann't load image: "
<<
imgPath
;
}
};
TEST_P
(
CannyVX
,
Accuracy
)
{
if
(
haveOpenVX
())
{
loadImage
();
setUseOpenVX
(
false
);
Mat
canny
;
cv
::
Canny
(
src
,
canny
,
100
,
150
,
3
);
setUseOpenVX
(
true
);
Mat
cannyVX
;
cv
::
Canny
(
src
,
cannyVX
,
100
,
150
,
3
);
setUseOpenVX
(
false
);
Mat
diff
,
diff1
;
absdiff
(
canny
,
cannyVX
,
diff
);
boxFilter
(
diff
,
diff1
,
-
1
,
Size
(
3
,
3
));
const
int
minPixelsAroud
=
3
;
// empirical number
diff1
=
diff1
>
255
/
9
*
minPixelsAroud
;
erode
(
diff1
,
diff1
,
Mat
());
double
error
=
cv
::
norm
(
diff1
,
NORM_L1
)
/
255
;
const
int
maxError
=
10
;
// empirical number
if
(
error
>
maxError
)
{
string
outPath
=
string
(
"CannyVX-diff-"
)
+
imgPath
+
'-'
+
'k'
+
char
(
kSize
+
'0'
)
+
'-'
+
(
useL2
?
"l2"
:
"l1"
);
std
::
replace
(
outPath
.
begin
(),
outPath
.
end
(),
'/'
,
'_'
);
std
::
replace
(
outPath
.
begin
(),
outPath
.
end
(),
'\\'
,
'_'
);
std
::
replace
(
outPath
.
begin
(),
outPath
.
end
(),
'.'
,
'_'
);
imwrite
(
outPath
+
".png"
,
diff
);
}
ASSERT_LE
(
error
,
maxError
);
}
}
INSTANTIATE_TEST_CASE_P
(
ImgProc
,
CannyVX
,
testing
::
Combine
(
testing
::
Values
(
string
(
"shared/baboon.png"
),
string
(
"shared/fruits.png"
),
string
(
"shared/lena.png"
),
string
(
"shared/pic1.png"
),
string
(
"shared/pic3.png"
),
string
(
"shared/pic5.png"
),
string
(
"shared/pic6.png"
)
),
testing
::
Values
(
ApertureSize
(
3
),
ApertureSize
(
5
)),
testing
::
Values
(
L2gradient
(
false
),
L2gradient
(
true
))
)
);
/* End of file. */
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