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
52ac61d8
Commit
52ac61d8
authored
Aug 14, 2014
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3088 from vbystricky:ocl_enableNormEtc
parents
95a49437
942ff5be
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
22 deletions
+61
-22
convert.cpp
modules/core/src/convert.cpp
+4
-4
minmaxloc.cl
modules/core/src/opencl/minmaxloc.cl
+2
-2
stat.cpp
modules/core/src/stat.cpp
+5
-8
test_arithm.cpp
modules/core/test/ocl/test_arithm.cpp
+50
-8
No files found.
modules/core/src/convert.cpp
View file @
52ac61d8
...
@@ -1765,13 +1765,12 @@ static bool ocl_convertScaleAbs( InputArray _src, OutputArray _dst, double alpha
...
@@ -1765,13 +1765,12 @@ static bool ocl_convertScaleAbs( InputArray _src, OutputArray _dst, double alpha
kercn
=
ocl
::
predictOptimalVectorWidth
(
_src
,
_dst
),
rowsPerWI
=
d
.
isIntel
()
?
4
:
1
;
kercn
=
ocl
::
predictOptimalVectorWidth
(
_src
,
_dst
),
rowsPerWI
=
d
.
isIntel
()
?
4
:
1
;
bool
doubleSupport
=
d
.
doubleFPConfig
()
>
0
;
bool
doubleSupport
=
d
.
doubleFPConfig
()
>
0
;
if
(
depth
==
CV_32F
||
depth
==
CV_64F
)
if
(
!
doubleSupport
&&
depth
==
CV_64F
)
return
false
;
return
false
;
char
cvt
[
2
][
50
];
char
cvt
[
2
][
50
];
int
wdepth
=
std
::
max
(
depth
,
CV_32F
);
int
wdepth
=
std
::
max
(
depth
,
CV_32F
);
ocl
::
Kernel
k
(
"KF"
,
ocl
::
core
::
arithm_oclsrc
,
String
build_opt
=
format
(
"-D OP_CONVERT_SCALE_ABS -D UNARY_OP -D dstT=%s -D srcT1=%s"
format
(
"-D OP_CONVERT_SCALE_ABS -D UNARY_OP -D dstT=%s -D srcT1=%s"
" -D workT=%s -D wdepth=%d -D convertToWT1=%s -D convertToDT=%s"
" -D workT=%s -D wdepth=%d -D convertToWT1=%s -D convertToDT=%s"
" -D workT1=%s -D rowsPerWI=%d%s"
,
" -D workT1=%s -D rowsPerWI=%d%s"
,
ocl
::
typeToStr
(
CV_8UC
(
kercn
)),
ocl
::
typeToStr
(
CV_8UC
(
kercn
)),
...
@@ -1780,7 +1779,8 @@ static bool ocl_convertScaleAbs( InputArray _src, OutputArray _dst, double alpha
...
@@ -1780,7 +1779,8 @@ static bool ocl_convertScaleAbs( InputArray _src, OutputArray _dst, double alpha
ocl
::
convertTypeStr
(
depth
,
wdepth
,
kercn
,
cvt
[
0
]),
ocl
::
convertTypeStr
(
depth
,
wdepth
,
kercn
,
cvt
[
0
]),
ocl
::
convertTypeStr
(
wdepth
,
CV_8U
,
kercn
,
cvt
[
1
]),
ocl
::
convertTypeStr
(
wdepth
,
CV_8U
,
kercn
,
cvt
[
1
]),
ocl
::
typeToStr
(
wdepth
),
rowsPerWI
,
ocl
::
typeToStr
(
wdepth
),
rowsPerWI
,
doubleSupport
?
" -D DOUBLE_SUPPORT"
:
""
));
doubleSupport
?
" -D DOUBLE_SUPPORT"
:
""
);
ocl
::
Kernel
k
(
"KF"
,
ocl
::
core
::
arithm_oclsrc
,
build_opt
);
if
(
k
.
empty
())
if
(
k
.
empty
())
return
false
;
return
false
;
...
...
modules/core/src/opencl/minmaxloc.cl
View file @
52ac61d8
...
@@ -98,7 +98,7 @@
...
@@ -98,7 +98,7 @@
#
ifdef
OP_CALC2
#
ifdef
OP_CALC2
#
define
CALC_MAX2
(
p
)
\
#
define
CALC_MAX2
(
p
)
\
maxval2
=
MAX
(
maxval2,
temp.p
)
;
maxval2
=
MAX
(
maxval2,
temp
2
.p
)
;
#
else
#
else
#
define
CALC_MAX2
(
p
)
#
define
CALC_MAX2
(
p
)
#
endif
#
endif
...
@@ -196,7 +196,7 @@ __kernel void minmaxloc(__global const uchar * srcptr, int src_step, int src_off
...
@@ -196,7 +196,7 @@ __kernel void minmaxloc(__global const uchar * srcptr, int src_step, int src_off
#
ifdef
HAVE_SRC2
#
ifdef
HAVE_SRC2
#
ifdef
HAVE_SRC2_CONT
#
ifdef
HAVE_SRC2_CONT
src2_index
=
mul24
(
id,
srcTSIZE
)
;
src2_index
=
id
*
srcTSIZE
; //
mul24(id, srcTSIZE);
#
else
#
else
src2_index
=
mad24
(
id
/
cols,
src2_step,
mul24
(
id
%
cols,
srcTSIZE
))
;
src2_index
=
mad24
(
id
/
cols,
src2_step,
mul24
(
id
%
cols,
srcTSIZE
))
;
#
endif
#
endif
...
...
modules/core/src/stat.cpp
View file @
52ac61d8
...
@@ -1444,7 +1444,10 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
...
@@ -1444,7 +1444,10 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
bool
doubleSupport
=
dev
.
doubleFPConfig
()
>
0
,
haveMask
=
!
_mask
.
empty
(),
bool
doubleSupport
=
dev
.
doubleFPConfig
()
>
0
,
haveMask
=
!
_mask
.
empty
(),
haveSrc2
=
_src2
.
kind
()
!=
_InputArray
::
NONE
;
haveSrc2
=
_src2
.
kind
()
!=
_InputArray
::
NONE
;
int
type
=
_src
.
type
(),
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
),
int
type
=
_src
.
type
(),
depth
=
CV_MAT_DEPTH
(
type
),
cn
=
CV_MAT_CN
(
type
),
kercn
=
haveMask
?
cn
:
std
::
min
(
4
,
ocl
::
predictOptimalVectorWidth
(
_src
));
kercn
=
haveMask
?
cn
:
std
::
min
(
4
,
ocl
::
predictOptimalVectorWidth
(
_src
,
_src2
));
if
(
haveMask
&&
dev
.
isAMD
())
return
false
;
CV_Assert
(
(
cn
==
1
&&
(
!
haveMask
||
_mask
.
type
()
==
CV_8U
))
||
CV_Assert
(
(
cn
==
1
&&
(
!
haveMask
||
_mask
.
type
()
==
CV_8U
))
||
(
cn
>=
1
&&
!
minLoc
&&
!
maxLoc
)
);
(
cn
>=
1
&&
!
minLoc
&&
!
maxLoc
)
);
...
@@ -1536,7 +1539,7 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
...
@@ -1536,7 +1539,7 @@ static bool ocl_minMaxIdx( InputArray _src, double* minVal, double* maxVal, int*
}
}
size_t
globalsize
=
groupnum
*
wgs
;
size_t
globalsize
=
groupnum
*
wgs
;
if
(
!
k
.
run
(
1
,
&
globalsize
,
&
wgs
,
fals
e
))
if
(
!
k
.
run
(
1
,
&
globalsize
,
&
wgs
,
tru
e
))
return
false
;
return
false
;
static
const
getMinMaxResFunc
functab
[
7
]
=
static
const
getMinMaxResFunc
functab
[
7
]
=
...
@@ -2190,9 +2193,6 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double &
...
@@ -2190,9 +2193,6 @@ static bool ocl_norm( InputArray _src, int normType, InputArray _mask, double &
(
!
doubleSupport
&&
depth
==
CV_64F
))
(
!
doubleSupport
&&
depth
==
CV_64F
))
return
false
;
return
false
;
if
(
depth
==
CV_32F
&&
(
!
_mask
.
empty
()
||
normType
==
NORM_INF
)
)
return
false
;
UMat
src
=
_src
.
getUMat
();
UMat
src
=
_src
.
getUMat
();
if
(
normType
==
NORM_INF
)
if
(
normType
==
NORM_INF
)
...
@@ -2548,9 +2548,6 @@ static bool ocl_norm( InputArray _src1, InputArray _src2, int normType, InputArr
...
@@ -2548,9 +2548,6 @@ static bool ocl_norm( InputArray _src1, InputArray _src2, int normType, InputArr
normType
&=
~
NORM_RELATIVE
;
normType
&=
~
NORM_RELATIVE
;
bool
normsum
=
normType
==
NORM_L1
||
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
;
bool
normsum
=
normType
==
NORM_L1
||
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
;
if
(
!
normsum
||
!
_mask
.
empty
()
)
return
false
;
if
(
normsum
)
if
(
normsum
)
{
{
if
(
!
ocl_sum
(
_src1
,
sc1
,
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
?
if
(
!
ocl_sum
(
_src1
,
sc1
,
normType
==
NORM_L2
||
normType
==
NORM_L2SQR
?
...
...
modules/core/test/ocl/test_arithm.cpp
View file @
52ac61d8
...
@@ -341,7 +341,7 @@ OCL_TEST_P(Mul, Mat_Scalar_Scale)
...
@@ -341,7 +341,7 @@ OCL_TEST_P(Mul, Mat_Scalar_Scale)
OCL_OFF
(
cv
::
multiply
(
src1_roi
,
val
,
dst1_roi
,
val
[
0
]));
OCL_OFF
(
cv
::
multiply
(
src1_roi
,
val
,
dst1_roi
,
val
[
0
]));
OCL_ON
(
cv
::
multiply
(
usrc1_roi
,
val
,
udst1_roi
,
val
[
0
]));
OCL_ON
(
cv
::
multiply
(
usrc1_roi
,
val
,
udst1_roi
,
val
[
0
]));
Near
(
udst1_roi
.
depth
()
>=
CV_32F
?
2
e-2
:
1
);
Near
(
udst1_roi
.
depth
()
>=
CV_32F
?
1
e-2
:
1
);
}
}
}
}
...
@@ -397,7 +397,7 @@ OCL_TEST_P(Div, Mat_Scale)
...
@@ -397,7 +397,7 @@ OCL_TEST_P(Div, Mat_Scale)
OCL_OFF
(
cv
::
divide
(
src1_roi
,
src2_roi
,
dst1_roi
,
val
[
0
]));
OCL_OFF
(
cv
::
divide
(
src1_roi
,
src2_roi
,
dst1_roi
,
val
[
0
]));
OCL_ON
(
cv
::
divide
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
,
val
[
0
]));
OCL_ON
(
cv
::
divide
(
usrc1_roi
,
usrc2_roi
,
udst1_roi
,
val
[
0
]));
Near
(
udst1_roi
.
depth
()
>=
CV_32F
?
2e-2
:
1
);
Near
(
udst1_roi
.
depth
()
>=
CV_32F
?
4e-3
:
1
);
}
}
}
}
...
@@ -1303,7 +1303,7 @@ OCL_TEST_P(Norm, NORM_INF_2args)
...
@@ -1303,7 +1303,7 @@ OCL_TEST_P(Norm, NORM_INF_2args)
OCL_OFF
(
const
double
cpuRes
=
cv
::
norm
(
src1_roi
,
src2_roi
,
type
));
OCL_OFF
(
const
double
cpuRes
=
cv
::
norm
(
src1_roi
,
src2_roi
,
type
));
OCL_ON
(
const
double
gpuRes
=
cv
::
norm
(
usrc1_roi
,
usrc2_roi
,
type
));
OCL_ON
(
const
double
gpuRes
=
cv
::
norm
(
usrc1_roi
,
usrc2_roi
,
type
));
EXPECT_
NEAR
(
cpuRes
,
gpuRes
,
0.2
);
EXPECT_
PRED3
(
relativeError
,
cpuRes
,
gpuRes
,
1e-6
);
}
}
}
}
...
@@ -1323,7 +1323,7 @@ OCL_TEST_P(Norm, NORM_INF_2args_mask)
...
@@ -1323,7 +1323,7 @@ OCL_TEST_P(Norm, NORM_INF_2args_mask)
OCL_OFF
(
const
double
cpuRes
=
cv
::
norm
(
src1_roi
,
src2_roi
,
type
,
mask_roi
));
OCL_OFF
(
const
double
cpuRes
=
cv
::
norm
(
src1_roi
,
src2_roi
,
type
,
mask_roi
));
OCL_ON
(
const
double
gpuRes
=
cv
::
norm
(
usrc1_roi
,
usrc2_roi
,
type
,
umask_roi
));
OCL_ON
(
const
double
gpuRes
=
cv
::
norm
(
usrc1_roi
,
usrc2_roi
,
type
,
umask_roi
));
EXPECT_
NEAR
(
cpuRes
,
gpuRes
,
0.1
);
EXPECT_
PRED3
(
relativeError
,
cpuRes
,
gpuRes
,
1e-6
);
}
}
}
}
...
@@ -1547,7 +1547,49 @@ OCL_TEST_P(InRange, Scalar)
...
@@ -1547,7 +1547,49 @@ OCL_TEST_P(InRange, Scalar)
//////////////////////////////// ConvertScaleAbs ////////////////////////////////////////////////
//////////////////////////////// ConvertScaleAbs ////////////////////////////////////////////////
typedef
ArithmTestBase
ConvertScaleAbs
;
PARAM_TEST_CASE
(
ConvertScaleAbs
,
MatDepth
,
Channels
,
bool
)
{
int
depth
;
int
cn
;
bool
use_roi
;
cv
::
Scalar
val
;
TEST_DECLARE_INPUT_PARAMETER
(
src
);
TEST_DECLARE_OUTPUT_PARAMETER
(
dst
);
virtual
void
SetUp
()
{
depth
=
GET_PARAM
(
0
);
cn
=
GET_PARAM
(
1
);
use_roi
=
GET_PARAM
(
2
);
}
virtual
void
generateTestData
()
{
const
int
stype
=
CV_MAKE_TYPE
(
depth
,
cn
);
const
int
dtype
=
CV_MAKE_TYPE
(
CV_8U
,
cn
);
Size
roiSize
=
randomSize
(
1
,
MAX_VALUE
);
Border
srcBorder
=
randomBorder
(
0
,
use_roi
?
MAX_VALUE
:
0
);
randomSubMat
(
src
,
src_roi
,
roiSize
,
srcBorder
,
stype
,
2
,
11
);
// FIXIT: Test with minV, maxV
Border
dstBorder
=
randomBorder
(
0
,
use_roi
?
MAX_VALUE
:
0
);
randomSubMat
(
dst
,
dst_roi
,
roiSize
,
dstBorder
,
dtype
,
5
,
16
);
val
=
cv
::
Scalar
(
rng
.
uniform
(
-
100.0
,
100.0
),
rng
.
uniform
(
-
100.0
,
100.0
),
rng
.
uniform
(
-
100.0
,
100.0
),
rng
.
uniform
(
-
100.0
,
100.0
));
UMAT_UPLOAD_INPUT_PARAMETER
(
src
);
UMAT_UPLOAD_OUTPUT_PARAMETER
(
dst
);
}
void
Near
(
double
threshold
=
0.
)
{
OCL_EXPECT_MATS_NEAR
(
dst
,
threshold
);
}
};
OCL_TEST_P
(
ConvertScaleAbs
,
Mat
)
OCL_TEST_P
(
ConvertScaleAbs
,
Mat
)
{
{
...
@@ -1555,10 +1597,10 @@ OCL_TEST_P(ConvertScaleAbs, Mat)
...
@@ -1555,10 +1597,10 @@ OCL_TEST_P(ConvertScaleAbs, Mat)
{
{
generateTestData
();
generateTestData
();
OCL_OFF
(
cv
::
convertScaleAbs
(
src
1_roi
,
dst1
_roi
,
val
[
0
],
val
[
1
]));
OCL_OFF
(
cv
::
convertScaleAbs
(
src
_roi
,
dst
_roi
,
val
[
0
],
val
[
1
]));
OCL_ON
(
cv
::
convertScaleAbs
(
usrc
1_roi
,
udst1
_roi
,
val
[
0
],
val
[
1
]));
OCL_ON
(
cv
::
convertScaleAbs
(
usrc
_roi
,
udst
_roi
,
val
[
0
],
val
[
1
]));
Near
(
depth
<=
CV_32S
?
1
:
1e-6
);
Near
(
1
);
}
}
}
}
...
...
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