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
af13c860
Commit
af13c860
authored
Feb 27, 2013
by
Andrey Kamaev
Committed by
OpenCV Buildbot
Feb 27, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #568 from bitwangyaoyao:2.4_moments
parents
5d43ce85
dba2ec05
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
74 additions
and
0 deletions
+74
-0
ocl.hpp
modules/ocl/include/opencv2/ocl/ocl.hpp
+2
-0
moments.cl
modules/ocl/src/kernels/moments.cl
+0
-0
moments.cpp
modules/ocl/src/moments.cpp
+0
-0
test_moments.cpp
modules/ocl/test/test_moments.cpp
+72
-0
No files found.
modules/ocl/include/opencv2/ocl/ocl.hpp
View file @
af13c860
...
...
@@ -1773,6 +1773,8 @@ namespace cv
const
oclMat
&
bu
,
const
oclMat
&
bv
,
float
pos
,
oclMat
&
newFrame
,
oclMat
&
buf
);
//! computes moments of the rasterized shape or a vector of points
CV_EXPORTS
Moments
ocl_moments
(
InputArray
_array
,
bool
binaryImage
);
}
}
#if defined _MSC_VER && _MSC_VER >= 1200
...
...
modules/ocl/src/kernels/moments.cl
0 → 100644
View file @
af13c860
This diff is collapsed.
Click to expand it.
modules/ocl/src/moments.cpp
0 → 100644
View file @
af13c860
This diff is collapsed.
Click to expand it.
modules/ocl/test/test_moments.cpp
0 → 100644
View file @
af13c860
#include "precomp.hpp"
#include <iomanip>
#include "opencv2/imgproc/imgproc_c.h"
#ifdef HAVE_OPENCL
using
namespace
cv
;
using
namespace
cv
::
ocl
;
using
namespace
cvtest
;
using
namespace
testing
;
using
namespace
std
;
extern
string
workdir
;
PARAM_TEST_CASE
(
MomentsTestBase
,
MatType
,
bool
)
{
int
type
;
cv
::
Mat
mat1
;
bool
test_contours
;
virtual
void
SetUp
()
{
type
=
GET_PARAM
(
0
);
test_contours
=
GET_PARAM
(
1
);
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
Size
size
(
10
*
MWIDTH
,
10
*
MHEIGHT
);
mat1
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
}
void
Compare
(
Moments
&
cpu
,
Moments
&
gpu
)
{
Mat
gpu_dst
,
cpu_dst
;
HuMoments
(
cpu
,
cpu_dst
);
HuMoments
(
gpu
,
gpu_dst
);
EXPECT_MAT_NEAR
(
gpu_dst
,
cpu_dst
,
.5
,
""
);
}
};
struct
ocl_Moments
:
MomentsTestBase
{};
TEST_P
(
ocl_Moments
,
Mat
)
{
bool
binaryImage
=
0
;
SetUp
();
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
if
(
test_contours
)
{
Mat
src
=
imread
(
workdir
+
"../cpp/pic3.png"
,
1
);
Mat
src_gray
,
canny_output
;
cvtColor
(
src
,
src_gray
,
CV_BGR2GRAY
);
vector
<
vector
<
Point
>
>
contours
;
vector
<
Vec4i
>
hierarchy
;
Canny
(
src_gray
,
canny_output
,
100
,
200
,
3
);
findContours
(
canny_output
,
contours
,
hierarchy
,
CV_RETR_TREE
,
CV_CHAIN_APPROX_SIMPLE
,
Point
(
0
,
0
)
);
for
(
size_t
i
=
0
;
i
<
contours
.
size
();
i
++
)
{
Moments
m
=
moments
(
contours
[
i
],
false
);
Moments
dm
=
ocl
::
ocl_moments
(
contours
[
i
],
false
);
Compare
(
m
,
dm
);
}
}
cv
::
_InputArray
_array
(
mat1
);
cv
::
Moments
CvMom
=
cv
::
moments
(
_array
,
binaryImage
);
cv
::
Moments
oclMom
=
cv
::
ocl
::
ocl_moments
(
_array
,
binaryImage
);
Compare
(
CvMom
,
oclMom
);
}
}
INSTANTIATE_TEST_CASE_P
(
Moments
,
ocl_Moments
,
Combine
(
Values
(
CV_8UC1
,
CV_16UC1
,
CV_16SC1
,
CV_64FC1
),
Values
(
true
,
false
)));
#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