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
d4371833
Commit
d4371833
authored
Sep 17, 2013
by
Alexander Smorkalov
Committed by
OpenCV Buildbot
Sep 17, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1439 from ilya-lavrenov:convertTo
parents
9cf301e2
f20cc2bc
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
32 deletions
+40
-32
matrix_operations.cpp
modules/ocl/src/matrix_operations.cpp
+32
-24
operator_convertTo.cl
modules/ocl/src/opencl/operator_convertTo.cl
+0
-0
test_matrix_operation.cpp
modules/ocl/test/test_matrix_operation.cpp
+0
-0
utility.hpp
modules/ocl/test/utility.hpp
+8
-8
No files found.
modules/ocl/src/matrix_operations.cpp
View file @
d4371833
...
...
@@ -382,40 +382,50 @@ void cv::ocl::oclMat::copyTo( oclMat &mat, const oclMat &mask) const
///////////////////////////////////////////////////////////////////////////
static
void
convert_run
(
const
oclMat
&
src
,
oclMat
&
dst
,
double
alpha
,
double
beta
)
{
string
kernelName
=
"convert_to_S"
;
stringstream
idxStr
;
idxStr
<<
src
.
depth
();
kernelName
+=
idxStr
.
str
();
string
kernelName
=
"convert_to"
;
float
alpha_f
=
alpha
,
beta_f
=
beta
;
int
sdepth
=
src
.
depth
(),
ddepth
=
dst
.
depth
();
int
sstep1
=
(
int
)
src
.
step1
(),
dstep1
=
(
int
)
dst
.
step1
();
int
cols1
=
src
.
cols
*
src
.
oclchannels
();
char
buildOptions
[
150
],
convertString
[
50
];
const
char
*
typeMap
[]
=
{
"uchar"
,
"char"
,
"ushort"
,
"short"
,
"int"
,
"float"
,
"double"
};
sprintf
(
convertString
,
"convert_%s_sat_rte"
,
typeMap
[
ddepth
]);
sprintf
(
buildOptions
,
"-D srcT=%s -D dstT=%s -D convertToDstType=%s"
,
typeMap
[
sdepth
],
typeMap
[
ddepth
],
CV_32F
==
ddepth
||
ddepth
==
CV_64F
?
""
:
convertString
);
CV_DbgAssert
(
src
.
rows
==
dst
.
rows
&&
src
.
cols
==
dst
.
cols
);
vector
<
pair
<
size_t
,
const
void
*>
>
args
;
size_t
localThreads
[
3
]
=
{
16
,
16
,
1
};
size_t
globalThreads
[
3
];
globalThreads
[
0
]
=
(
dst
.
cols
+
localThreads
[
0
]
-
1
)
/
localThreads
[
0
]
*
localThreads
[
0
];
globalThreads
[
1
]
=
(
dst
.
rows
+
localThreads
[
1
]
-
1
)
/
localThreads
[
1
]
*
localThreads
[
1
];
globalThreads
[
2
]
=
1
;
int
dststep_in_pixel
=
dst
.
step
/
dst
.
elemSize
(),
dstoffset_in_pixel
=
dst
.
offset
/
dst
.
elemSize
();
int
srcstep_in_pixel
=
src
.
step
/
src
.
elemSize
(),
srcoffset_in_pixel
=
src
.
offset
/
src
.
elemSize
();
if
(
dst
.
type
()
==
CV_8UC1
)
{
globalThreads
[
0
]
=
((
dst
.
cols
+
4
)
/
4
+
localThreads
[
0
])
/
localThreads
[
0
]
*
localThreads
[
0
];
}
size_t
localThreads
[
3
]
=
{
16
,
16
,
1
};
size_t
globalThreads
[
3
]
=
{
divUp
(
cols1
,
localThreads
[
0
])
*
localThreads
[
0
],
divUp
(
dst
.
rows
,
localThreads
[
1
])
*
localThreads
[
1
],
1
};
int
doffset1
=
dst
.
offset
/
dst
.
elemSize1
();
int
soffset1
=
src
.
offset
/
src
.
elemSize1
();
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
src
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_mem
)
,
(
void
*
)
&
dst
.
data
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
src
.
cols
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
cols1
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
src
.
rows
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
s
rcstep_in_pixel
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
s
rcoffset_in_pixel
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dst
step_in_pixel
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
d
stoffset_in_pixel
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
s
step1
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
s
offset1
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
dst
ep1
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_int
)
,
(
void
*
)
&
d
offset1
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_float
)
,
(
void
*
)
&
alpha_f
));
args
.
push_back
(
make_pair
(
sizeof
(
cl_float
)
,
(
void
*
)
&
beta_f
));
openCLExecuteKernel
(
dst
.
clCxt
,
&
operator_convertTo
,
kernelName
,
globalThreads
,
localThreads
,
args
,
dst
.
oclchannels
(),
dst
.
depth
()
);
localThreads
,
args
,
-
1
,
-
1
,
buildOptions
);
}
void
cv
::
ocl
::
oclMat
::
convertTo
(
oclMat
&
dst
,
int
rtype
,
double
alpha
,
double
beta
)
const
{
//cout << "cv::ocl::oclMat::convertTo()" << endl;
if
(
!
clCxt
->
supportsFeature
(
Context
::
CL_DOUBLE
)
&&
(
depth
()
==
CV_64F
||
dst
.
depth
()
==
CV_64F
))
{
CV_Error
(
CV_GpuNotSupported
,
"Selected device don't support double
\r\n
"
);
return
;
}
bool
noScale
=
fabs
(
alpha
-
1
)
<
std
::
numeric_limits
<
double
>::
epsilon
()
&&
fabs
(
beta
)
<
std
::
numeric_limits
<
double
>::
epsilon
();
...
...
@@ -425,7 +435,6 @@ void cv::ocl::oclMat::convertTo( oclMat &dst, int rtype, double alpha, double be
else
rtype
=
CV_MAKETYPE
(
CV_MAT_DEPTH
(
rtype
),
channels
());
//int scn = channels();
int
sdepth
=
depth
(),
ddepth
=
CV_MAT_DEPTH
(
rtype
);
if
(
sdepth
==
ddepth
&&
noScale
)
{
...
...
@@ -447,7 +456,6 @@ void cv::ocl::oclMat::convertTo( oclMat &dst, int rtype, double alpha, double be
///////////////////////////////////////////////////////////////////////////
oclMat
&
cv
::
ocl
::
oclMat
::
operator
=
(
const
Scalar
&
s
)
{
//cout << "cv::ocl::oclMat::=" << endl;
setTo
(
s
);
return
*
this
;
}
...
...
modules/ocl/src/opencl/operator_convertTo.cl
View file @
d4371833
This diff is collapsed.
Click to expand it.
modules/ocl/test/test_matrix_operation.cpp
View file @
d4371833
This diff is collapsed.
Click to expand it.
modules/ocl/test/utility.hpp
View file @
d4371833
...
...
@@ -41,9 +41,15 @@
#ifndef __OPENCV_TEST_UTILITY_HPP__
#define __OPENCV_TEST_UTILITY_HPP__
#define LOOP_TIMES 1
#define MWIDTH 256
#define MHEIGHT 256
#define MIN_VALUE 171
#define MAX_VALUE 351
//#define RANDOMROI
int
randomInt
(
int
minVal
,
int
maxVal
);
double
randomDouble
(
double
minVal
,
double
maxVal
);
...
...
@@ -73,6 +79,7 @@ double checkSimilarity(const cv::Mat &m1, const cv::Mat &m2);
//oclMat create
cv
::
ocl
::
oclMat
createMat_ocl
(
cv
::
Size
size
,
int
type
,
bool
useRoi
=
false
);
cv
::
ocl
::
oclMat
loadMat_ocl
(
const
cv
::
Mat
&
m
,
bool
useRoi
=
false
);
#define EXPECT_MAT_NORM(mat, eps) \
{ \
EXPECT_LE(checkNorm(cv::Mat(mat)), eps) \
...
...
@@ -84,14 +91,7 @@ cv::ocl::oclMat loadMat_ocl(const cv::Mat& m, bool useRoi = false);
ASSERT_EQ(mat1.size(), mat2.size()); \
EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps); \
}
/*
#define EXPECT_MAT_NEAR(mat1, mat2, eps,s) \
{ \
ASSERT_EQ(mat1.type(), mat2.type()); \
ASSERT_EQ(mat1.size(), mat2.size()); \
EXPECT_LE(checkNorm(cv::Mat(mat1), cv::Mat(mat2)), eps)<<s; \
}
*/
#define EXPECT_MAT_SIMILAR(mat1, mat2, eps) \
{ \
ASSERT_EQ(mat1.type(), mat2.type()); \
...
...
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