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
e80f5bed
Commit
e80f5bed
authored
Oct 31, 2013
by
Andrey Pavlenko
Committed by
OpenCV Buildbot
Oct 31, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1710 from melody-rain:2.4_moments_ocl
parents
ef9f6905
3dbcd054
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
38 additions
and
36 deletions
+38
-36
ocl.hpp
modules/ocl/include/opencv2/ocl/ocl.hpp
+6
-1
perf_moments.cpp
modules/ocl/perf/perf_moments.cpp
+20
-19
moments.cpp
modules/ocl/src/moments.cpp
+0
-0
moments.cl
modules/ocl/src/opencl/moments.cl
+0
-0
test_moments.cpp
modules/ocl/test/test_moments.cpp
+12
-16
No files found.
modules/ocl/include/opencv2/ocl/ocl.hpp
View file @
e80f5bed
...
@@ -1520,7 +1520,12 @@ namespace cv
...
@@ -1520,7 +1520,12 @@ namespace cv
float
pos
,
oclMat
&
newFrame
,
oclMat
&
buf
);
float
pos
,
oclMat
&
newFrame
,
oclMat
&
buf
);
//! computes moments of the rasterized shape or a vector of points
//! computes moments of the rasterized shape or a vector of points
CV_EXPORTS
Moments
ocl_moments
(
InputArray
_array
,
bool
binaryImage
);
//! _array should be a vector a points standing for the contour
CV_EXPORTS
Moments
ocl_moments
(
InputArray
contour
);
//! src should be a general image uploaded to the GPU.
//! the supported oclMat type are CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1 and CV_64FC1
//! to use type of CV_64FC1, the GPU should support CV_64FC1
CV_EXPORTS
Moments
ocl_moments
(
oclMat
&
src
,
bool
binary
);
class
CV_EXPORTS
StereoBM_OCL
class
CV_EXPORTS
StereoBM_OCL
{
{
...
...
modules/ocl/perf/perf_moments.cpp
View file @
e80f5bed
...
@@ -26,7 +26,7 @@
...
@@ -26,7 +26,7 @@
//
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// this list of conditions and the following disclaimer in the documentation
// and/or other
m
aterials provided with the distribution.
// and/or other
M
aterials provided with the distribution.
//
//
// * The name of the copyright holders may not be used to endorse or promote products
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
// derived from this software without specific prior written permission.
...
@@ -49,41 +49,42 @@
...
@@ -49,41 +49,42 @@
using
namespace
perf
;
using
namespace
perf
;
using
std
::
tr1
::
tuple
;
using
std
::
tr1
::
tuple
;
using
std
::
tr1
::
get
;
using
std
::
tr1
::
get
;
using
namespace
cv
;
using
namespace
cv
::
ocl
;
using
namespace
cvtest
;
using
namespace
testing
;
using
namespace
std
;
///////////// Moments ////////////////////////
typedef
Size_MatType
MomentsFixture
;
///////////// Moments ////////////////////////
//*! performance of image
typedef
tuple
<
Size
,
MatType
,
bool
>
MomentsParamType
;
typedef
TestBaseWithParam
<
MomentsParamType
>
MomentsFixture
;
PERF_TEST_P
(
MomentsFixture
,
DISABLED_
Moments
,
PERF_TEST_P
(
MomentsFixture
,
Moments
,
::
testing
::
Combine
(
OCL_TYPICAL_MAT_SIZES
,
::
testing
::
Combine
(
OCL_TYPICAL_MAT_SIZES
,
OCL_PERF_ENUM
(
CV_8UC1
,
CV_16SC1
,
CV_32FC1
,
CV_64FC1
)))
// TODO does not work properly (see below
)
OCL_PERF_ENUM
(
CV_8UC1
,
CV_16SC1
,
CV_16UC1
,
CV_32FC1
),
::
testing
::
Values
(
false
,
true
))
)
{
{
const
Size_MatType_t
params
=
GetParam
();
const
MomentsParamType
params
=
GetParam
();
const
Size
srcSize
=
get
<
0
>
(
params
);
const
Size
srcSize
=
get
<
0
>
(
params
);
const
int
type
=
get
<
1
>
(
params
);
const
int
type
=
get
<
1
>
(
params
);
const
bool
binaryImage
=
get
<
2
>
(
params
);
Mat
src
(
srcSize
,
type
),
dst
(
7
,
1
,
CV_64F
);
Mat
src
(
srcSize
,
type
),
dst
(
7
,
1
,
CV_64F
);
const
bool
binaryImage
=
false
;
randu
(
src
,
0
,
255
);
cv
::
Moments
mom
;
declare
.
in
(
src
,
WARMUP_RNG
).
out
(
dst
);
oclMat
src_d
(
src
);
cv
::
Moments
mom
;
if
(
RUN_OCL_IMPL
)
if
(
RUN_OCL_IMPL
)
{
{
ocl
::
oclMat
oclSrc
(
src
);
OCL_TEST_CYCLE
()
mom
=
cv
::
ocl
::
ocl_moments
(
src_d
,
binaryImage
);
OCL_TEST_CYCLE
()
mom
=
cv
::
ocl
::
ocl_moments
(
oclSrc
,
binaryImage
);
// TODO Use oclSrc
cv
::
HuMoments
(
mom
,
dst
);
SANITY_CHECK
(
dst
);
}
}
else
if
(
RUN_PLAIN_IMPL
)
else
if
(
RUN_PLAIN_IMPL
)
{
{
TEST_CYCLE
()
mom
=
cv
::
moments
(
src
,
binaryImage
);
TEST_CYCLE
()
mom
=
cv
::
moments
(
src
,
binaryImage
);
cv
::
HuMoments
(
mom
,
dst
);
SANITY_CHECK
(
dst
);
}
}
else
else
OCL_PERF_ELSE
OCL_PERF_ELSE
cv
::
HuMoments
(
mom
,
dst
);
SANITY_CHECK
(
dst
,
1e-3
);
}
}
modules/ocl/src/moments.cpp
View file @
e80f5bed
This diff is collapsed.
Click to expand it.
modules/ocl/src/opencl/moments.cl
View file @
e80f5bed
This diff is collapsed.
Click to expand it.
modules/ocl/test/test_moments.cpp
View file @
e80f5bed
...
@@ -10,18 +10,19 @@ using namespace cvtest;
...
@@ -10,18 +10,19 @@ using namespace cvtest;
using
namespace
testing
;
using
namespace
testing
;
using
namespace
std
;
using
namespace
std
;
PARAM_TEST_CASE
(
MomentsTest
,
MatType
,
bool
)
PARAM_TEST_CASE
(
MomentsTest
,
MatType
,
bool
,
bool
)
{
{
int
type
;
int
type
;
cv
::
Mat
mat
1
;
cv
::
Mat
mat
;
bool
test_contours
;
bool
test_contours
;
bool
binaryImage
;
virtual
void
SetUp
()
virtual
void
SetUp
()
{
{
type
=
GET_PARAM
(
0
);
type
=
GET_PARAM
(
0
);
test_contours
=
GET_PARAM
(
1
);
test_contours
=
GET_PARAM
(
1
);
cv
::
Size
size
(
10
*
MWIDTH
,
10
*
MHEIGHT
);
cv
::
Size
size
(
10
*
MWIDTH
,
10
*
MHEIGHT
);
mat1
=
randomMat
(
size
,
type
,
5
,
16
,
false
);
mat
=
randomMat
(
size
,
type
,
0
,
256
,
false
);
binaryImage
=
GET_PARAM
(
2
);
}
}
void
Compare
(
Moments
&
cpu
,
Moments
&
gpu
)
void
Compare
(
Moments
&
cpu
,
Moments
&
gpu
)
...
@@ -29,16 +30,13 @@ PARAM_TEST_CASE(MomentsTest, MatType, bool)
...
@@ -29,16 +30,13 @@ PARAM_TEST_CASE(MomentsTest, MatType, bool)
Mat
gpu_dst
,
cpu_dst
;
Mat
gpu_dst
,
cpu_dst
;
HuMoments
(
cpu
,
cpu_dst
);
HuMoments
(
cpu
,
cpu_dst
);
HuMoments
(
gpu
,
gpu_dst
);
HuMoments
(
gpu
,
gpu_dst
);
EXPECT_MAT_NEAR
(
gpu_dst
,
cpu_dst
,
.5
);
EXPECT_MAT_NEAR
(
gpu_dst
,
cpu_dst
,
1e-3
);
}
}
};
};
OCL_TEST_P
(
MomentsTest
,
Mat
)
OCL_TEST_P
(
MomentsTest
,
Mat
)
{
{
bool
binaryImage
=
0
;
oclMat
src_d
(
mat
);
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
{
if
(
test_contours
)
if
(
test_contours
)
...
@@ -53,18 +51,16 @@ OCL_TEST_P(MomentsTest, Mat)
...
@@ -53,18 +51,16 @@ OCL_TEST_P(MomentsTest, Mat)
for
(
size_t
i
=
0
;
i
<
contours
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
contours
.
size
();
i
++
)
{
{
Moments
m
=
moments
(
contours
[
i
],
false
);
Moments
m
=
moments
(
contours
[
i
],
false
);
Moments
dm
=
ocl
::
ocl_moments
(
contours
[
i
]
,
false
);
Moments
dm
=
ocl
::
ocl_moments
(
contours
[
i
]);
Compare
(
m
,
dm
);
Compare
(
m
,
dm
);
}
}
}
}
cv
::
_InputArray
_array
(
mat1
);
cv
::
Moments
CvMom
=
cv
::
moments
(
mat
,
binaryImage
);
cv
::
Moments
CvMom
=
cv
::
moments
(
_array
,
binaryImage
);
cv
::
Moments
oclMom
=
cv
::
ocl
::
ocl_moments
(
src_d
,
binaryImage
);
cv
::
Moments
oclMom
=
cv
::
ocl
::
ocl_moments
(
_array
,
binaryImage
);
Compare
(
CvMom
,
oclMom
);
Compare
(
CvMom
,
oclMom
);
}
}
}
}
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
MomentsTest
,
Combine
(
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
MomentsTest
,
Combine
(
Values
(
CV_8UC1
,
CV_16UC1
,
CV_16SC1
,
CV_64FC1
),
Values
(
true
,
fals
e
)));
Values
(
CV_8UC1
,
CV_16UC1
,
CV_16SC1
,
CV_32FC1
,
CV_64FC1
),
Values
(
false
,
true
),
Values
(
false
,
tru
e
)));
#endif // HAVE_OPENCL
#endif // HAVE_OPENCL
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