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
ce0297ed
Commit
ce0297ed
authored
Aug 08, 2014
by
Vadim Pisarevsky
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3050 from ElenaGvozdeva:ocl_fixed_impg
parents
88672f41
b5f251c8
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
8 deletions
+50
-8
templmatch.cpp
modules/imgproc/src/templmatch.cpp
+3
-2
test_filter2d.cpp
modules/imgproc/test/ocl/test_filter2d.cpp
+1
-1
test_histogram.cpp
modules/imgproc/test/ocl/test_histogram.cpp
+6
-2
test_match_template.cpp
modules/imgproc/test/ocl/test_match_template.cpp
+11
-3
ocl_test.hpp
modules/ts/include/opencv2/ts/ocl_test.hpp
+29
-0
No files found.
modules/imgproc/src/templmatch.cpp
View file @
ce0297ed
...
...
@@ -454,14 +454,15 @@ static bool matchTemplate_CCOEFF(InputArray _image, InputArray _templ, OutputArr
if
(
cn
==
1
)
{
float
templ_sum
=
static_cast
<
float
>
(
sum
(
_templ
)[
0
])
/
tsize
.
area
();
Scalar
templMean
=
mean
(
templ
);
float
templ_sum
=
(
float
)
templMean
[
0
];
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadWrite
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sum
);
}
else
{
Vec4f
templ_sum
=
Vec4f
::
all
(
0
);
templ_sum
=
sum
(
templ
)
/
tsize
.
area
(
);
templ_sum
=
(
Vec4f
)
mean
(
templ
);
k
.
args
(
ocl
::
KernelArg
::
ReadOnlyNoSize
(
image_sums
),
ocl
::
KernelArg
::
ReadWrite
(
result
),
templ
.
rows
,
templ
.
cols
,
templ_sum
);
}
...
...
modules/imgproc/test/ocl/test_filter2d.cpp
View file @
ce0297ed
...
...
@@ -125,7 +125,7 @@ OCL_INSTANTIATE_TEST_CASE_P(ImageProc, Filter2D,
Combine
(
Values
(
CV_8U
,
CV_16U
,
CV_32F
),
OCL_ALL_CHANNELS
,
Values
(
3
,
5
,
9
),
// Kernel size
Values
(
3
,
5
,
7
),
// Kernel size
Values
(
1
,
4
,
8
),
// Width mutiple
Values
((
BorderType
)
BORDER_CONSTANT
,
(
BorderType
)
BORDER_REPLICATE
,
...
...
modules/imgproc/test/ocl/test_histogram.cpp
View file @
ce0297ed
...
...
@@ -99,6 +99,10 @@ PARAM_TEST_CASE(CalcBackProject, MatDepth, int, bool)
Size
roiSize
=
randomSize
(
1
,
MAX_VALUE
);
int
totalChannels
=
0
;
ranges
.
clear
();
channels
.
clear
();
for
(
int
i
=
0
;
i
<
N
;
++
i
)
{
Border
srcBorder
=
randomBorder
(
0
,
useRoi
?
MAX_VALUE
:
0
);
...
...
@@ -202,9 +206,9 @@ OCL_TEST_P(CalcBackProject, Mat)
OCL_ON
(
cv
::
calcBackProject
(
uimages_roi
,
channels
,
uhist_roi
,
udst_roi
,
ranges
,
scale
));
Size
dstSize
=
dst_roi
.
size
();
int
nDiffs
=
(
int
)(
0.03
f
*
dstSize
.
height
*
dstSize
.
width
);
int
nDiffs
=
std
::
max
((
int
)(
0.07
f
*
dstSize
.
area
()),
1
);
//check if the dst mats are the same except
3
% difference
//check if the dst mats are the same except
7
% difference
EXPECT_MAT_N_DIFF
(
dst_roi
,
udst_roi
,
nDiffs
);
}
}
...
...
modules/imgproc/test/ocl/test_match_template.cpp
View file @
ce0297ed
...
...
@@ -97,9 +97,17 @@ PARAM_TEST_CASE(MatchTemplate, MatDepth, Channels, MatchTemplType, bool)
UMAT_UPLOAD_OUTPUT_PARAMETER
(
result
);
}
void
Near
(
double
threshold
=
0.0
)
void
Near
()
{
OCL_EXPECT_MATS_NEAR_RELATIVE
(
result
,
threshold
);
bool
isNormed
=
method
==
TM_CCORR_NORMED
||
method
==
TM_SQDIFF_NORMED
||
method
==
TM_CCOEFF_NORMED
;
if
(
isNormed
)
OCL_EXPECT_MATS_NEAR
(
result
,
3e-2
);
else
OCL_EXPECT_MATS_NEAR_RELATIVE_SPARSE
(
result
,
1.5e-2
);
}
};
...
...
@@ -112,7 +120,7 @@ OCL_TEST_P(MatchTemplate, Mat)
OCL_OFF
(
cv
::
matchTemplate
(
image_roi
,
templ_roi
,
result_roi
,
method
));
OCL_ON
(
cv
::
matchTemplate
(
uimage_roi
,
utempl_roi
,
uresult_roi
,
method
));
Near
(
1.5e-4
);
Near
();
}
}
...
...
modules/ts/include/opencv2/ts/ocl_test.hpp
View file @
ce0297ed
...
...
@@ -159,6 +159,25 @@ do \
<< "Size: " << name ## _roi.size() << std::endl; \
} while ((void)0, 0)
//for sparse matrix
#define OCL_EXPECT_MATS_NEAR_RELATIVE_SPARSE(name, eps) \
do \
{ \
ASSERT_EQ(name ## _roi.type(), u ## name ## _roi.type()); \
ASSERT_EQ(name ## _roi.size(), u ## name ## _roi.size()); \
EXPECT_LE(TestUtils::checkNormRelativeSparse(name ## _roi, u ## name ## _roi), eps) \
<< "Size: " << name ## _roi.size() << std::endl; \
Point _offset; \
Size _wholeSize; \
name ## _roi.locateROI(_wholeSize, _offset); \
Mat _mask(name.size(), CV_8UC1, Scalar::all(255)); \
_mask(Rect(_offset, name ## _roi.size())).setTo(Scalar::all(0)); \
ASSERT_EQ(name.type(), u ## name.type()); \
ASSERT_EQ(name.size(), u ## name.size()); \
EXPECT_LE(TestUtils::checkNormRelativeSparse(name, u ## name, _mask), eps) \
<< "Size: " << name ## _roi.size() << std::endl; \
} while ((void)0, 0)
#define EXPECT_MAT_SIMILAR(mat1, mat2, eps) \
do \
{ \
...
...
@@ -274,6 +293,16 @@ struct CV_EXPORTS TestUtils
std
::
max
((
double
)
std
::
numeric_limits
<
float
>::
epsilon
(),
(
double
)
std
::
max
(
cvtest
::
norm
(
m1
.
getMat
(),
cv
::
NORM_INF
),
cvtest
::
norm
(
m2
.
getMat
(),
cv
::
NORM_INF
)));
}
static
inline
double
checkNormRelativeSparse
(
InputArray
m1
,
InputArray
m2
,
InputArray
mask
=
noArray
())
{
double
norm_inf
=
cvtest
::
norm
(
m1
.
getMat
(),
m2
.
getMat
(),
cv
::
NORM_INF
,
mask
);
double
norm_rel
=
norm_inf
/
std
::
max
((
double
)
std
::
numeric_limits
<
float
>::
epsilon
(),
(
double
)
std
::
max
(
cvtest
::
norm
(
m1
.
getMat
(),
cv
::
NORM_INF
),
cvtest
::
norm
(
m2
.
getMat
(),
cv
::
NORM_INF
)));
return
std
::
min
(
norm_inf
,
norm_rel
);
}
};
#define TEST_DECLARE_INPUT_PARAMETER(name) Mat name, name ## _roi; UMat u ## name, u ## name ## _roi
...
...
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