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
6eb5a95a
Commit
6eb5a95a
authored
May 13, 2013
by
Vadim Pisarevsky
Committed by
OpenCV Buildbot
May 13, 2013
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #871 from bitwangyaoyao:2.4_acry
parents
fd83f2f5
e23884a2
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
319 additions
and
1421 deletions
+319
-1421
interpolation.hpp
modules/ocl/test/interpolation.hpp
+0
-120
precomp.hpp
modules/ocl/test/precomp.hpp
+0
-1
test_arithm.cpp
modules/ocl/test/test_arithm.cpp
+91
-400
test_blend.cpp
modules/ocl/test/test_blend.cpp
+49
-14
test_brute_force_matcher.cpp
modules/ocl/test/test_brute_force_matcher.cpp
+9
-5
test_calib3d.cpp
modules/ocl/test/test_calib3d.cpp
+1
-1
test_color.cpp
modules/ocl/test/test_color.cpp
+3
-3
test_columnsum.cpp
modules/ocl/test/test_columnsum.cpp
+2
-14
test_fft.cpp
modules/ocl/test/test_fft.cpp
+4
-4
test_filters.cpp
modules/ocl/test/test_filters.cpp
+86
-566
test_gemm.cpp
modules/ocl/test/test_gemm.cpp
+1
-2
test_haar.cpp
modules/ocl/test/test_haar.cpp
+1
-0
test_hog.cpp
modules/ocl/test/test_hog.cpp
+2
-3
test_imgproc.cpp
modules/ocl/test/test_imgproc.cpp
+35
-141
test_match_template.cpp
modules/ocl/test/test_match_template.cpp
+2
-11
test_matrix_operation.cpp
modules/ocl/test/test_matrix_operation.cpp
+12
-59
test_moments.cpp
modules/ocl/test/test_moments.cpp
+5
-5
test_pyrdown.cpp
modules/ocl/test/test_pyrdown.cpp
+2
-17
test_pyrlk.cpp
modules/ocl/test/test_pyrlk.cpp
+0
-12
test_pyrup.cpp
modules/ocl/test/test_pyrup.cpp
+2
-8
test_split_merge.cpp
modules/ocl/test/test_split_merge.cpp
+8
-31
utility.hpp
modules/ocl/test/utility.hpp
+4
-4
No files found.
modules/ocl/test/interpolation.hpp
deleted
100644 → 0
View file @
fd83f2f5
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// Intel License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of Intel Corporation may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef __OPENCV_TEST_INTERPOLATION_HPP__
#define __OPENCV_TEST_INTERPOLATION_HPP__
template
<
typename
T
>
T
readVal
(
const
cv
::
Mat
&
src
,
int
y
,
int
x
,
int
c
,
int
border_type
,
cv
::
Scalar
borderVal
=
cv
::
Scalar
())
{
if
(
border_type
==
cv
::
BORDER_CONSTANT
)
return
(
y
>=
0
&&
y
<
src
.
rows
&&
x
>=
0
&&
x
<
src
.
cols
)
?
src
.
at
<
T
>
(
y
,
x
*
src
.
channels
()
+
c
)
:
cv
::
saturate_cast
<
T
>
(
borderVal
.
val
[
c
]);
return
src
.
at
<
T
>
(
cv
::
borderInterpolate
(
y
,
src
.
rows
,
border_type
),
cv
::
borderInterpolate
(
x
,
src
.
cols
,
border_type
)
*
src
.
channels
()
+
c
);
}
template
<
typename
T
>
struct
NearestInterpolator
{
static
T
getValue
(
const
cv
::
Mat
&
src
,
float
y
,
float
x
,
int
c
,
int
border_type
,
cv
::
Scalar
borderVal
=
cv
::
Scalar
())
{
return
readVal
<
T
>
(
src
,
cvFloor
(
y
),
cvFloor
(
x
),
c
,
border_type
,
borderVal
);
}
};
template
<
typename
T
>
struct
LinearInterpolator
{
static
T
getValue
(
const
cv
::
Mat
&
src
,
float
y
,
float
x
,
int
c
,
int
border_type
,
cv
::
Scalar
borderVal
=
cv
::
Scalar
())
{
x
-=
0.5
f
;
y
-=
0.5
f
;
int
x1
=
cvFloor
(
x
);
int
y1
=
cvFloor
(
y
);
int
x2
=
x1
+
1
;
int
y2
=
y1
+
1
;
float
res
=
0
;
res
+=
readVal
<
T
>
(
src
,
y1
,
x1
,
c
,
border_type
,
borderVal
)
*
((
x2
-
x
)
*
(
y2
-
y
));
res
+=
readVal
<
T
>
(
src
,
y1
,
x2
,
c
,
border_type
,
borderVal
)
*
((
x
-
x1
)
*
(
y2
-
y
));
res
+=
readVal
<
T
>
(
src
,
y2
,
x1
,
c
,
border_type
,
borderVal
)
*
((
x2
-
x
)
*
(
y
-
y1
));
res
+=
readVal
<
T
>
(
src
,
y2
,
x2
,
c
,
border_type
,
borderVal
)
*
((
x
-
x1
)
*
(
y
-
y1
));
return
cv
::
saturate_cast
<
T
>
(
res
);
}
};
template
<
typename
T
>
struct
CubicInterpolator
{
static
float
getValue
(
float
p
[
4
],
float
x
)
{
return
p
[
1
]
+
0.5
*
x
*
(
p
[
2
]
-
p
[
0
]
+
x
*
(
2.0
*
p
[
0
]
-
5.0
*
p
[
1
]
+
4.0
*
p
[
2
]
-
p
[
3
]
+
x
*
(
3.0
*
(
p
[
1
]
-
p
[
2
])
+
p
[
3
]
-
p
[
0
])));
}
static
float
getValue
(
float
p
[
4
][
4
],
float
x
,
float
y
)
{
float
arr
[
4
];
arr
[
0
]
=
getValue
(
p
[
0
],
x
);
arr
[
1
]
=
getValue
(
p
[
1
],
x
);
arr
[
2
]
=
getValue
(
p
[
2
],
x
);
arr
[
3
]
=
getValue
(
p
[
3
],
x
);
return
getValue
(
arr
,
y
);
}
static
T
getValue
(
const
cv
::
Mat
&
src
,
float
y
,
float
x
,
int
c
,
int
border_type
,
cv
::
Scalar
borderVal
=
cv
::
Scalar
())
{
int
ix
=
cvRound
(
x
);
int
iy
=
cvRound
(
y
);
float
vals
[
4
][
4
]
=
{
{
readVal
<
T
>
(
src
,
iy
-
2
,
ix
-
2
,
c
,
border_type
,
borderVal
),
readVal
<
T
>
(
src
,
iy
-
2
,
ix
-
1
,
c
,
border_type
,
borderVal
),
readVal
<
T
>
(
src
,
iy
-
2
,
ix
,
c
,
border_type
,
borderVal
),
readVal
<
T
>
(
src
,
iy
-
2
,
ix
+
1
,
c
,
border_type
,
borderVal
)},
{
readVal
<
T
>
(
src
,
iy
-
1
,
ix
-
2
,
c
,
border_type
,
borderVal
),
readVal
<
T
>
(
src
,
iy
-
1
,
ix
-
1
,
c
,
border_type
,
borderVal
),
readVal
<
T
>
(
src
,
iy
-
1
,
ix
,
c
,
border_type
,
borderVal
),
readVal
<
T
>
(
src
,
iy
-
1
,
ix
+
1
,
c
,
border_type
,
borderVal
)},
{
readVal
<
T
>
(
src
,
iy
,
ix
-
2
,
c
,
border_type
,
borderVal
),
readVal
<
T
>
(
src
,
iy
,
ix
-
1
,
c
,
border_type
,
borderVal
),
readVal
<
T
>
(
src
,
iy
,
ix
,
c
,
border_type
,
borderVal
),
readVal
<
T
>
(
src
,
iy
,
ix
+
1
,
c
,
border_type
,
borderVal
)},
{
readVal
<
T
>
(
src
,
iy
+
1
,
ix
-
2
,
c
,
border_type
,
borderVal
),
readVal
<
T
>
(
src
,
iy
+
1
,
ix
-
1
,
c
,
border_type
,
borderVal
),
readVal
<
T
>
(
src
,
iy
+
1
,
ix
,
c
,
border_type
,
borderVal
),
readVal
<
T
>
(
src
,
iy
+
1
,
ix
+
1
,
c
,
border_type
,
borderVal
)},
};
return
cv
::
saturate_cast
<
T
>
(
getValue
(
vals
,
(
x
-
ix
+
2.0
)
/
4.0
,
(
y
-
iy
+
2.0
)
/
4.0
));
}
};
#endif // __OPENCV_TEST_INTERPOLATION_HPP__
modules/ocl/test/precomp.hpp
View file @
6eb5a95a
...
...
@@ -71,7 +71,6 @@
#include "opencv2/ocl/ocl.hpp"
#include "utility.hpp"
#include "interpolation.hpp"
//#include "add_test_info.h"
#endif
...
...
modules/ocl/test/test_arithm.cpp
View file @
6eb5a95a
...
...
@@ -12,6 +12,7 @@
//
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
...
...
@@ -21,6 +22,7 @@
// Jiang Liyuan,jlyuan001.good@163.com
// Rock Li, Rock.Li@amd.com
// Zailong Wu, bullet@yeah.net
// Yao Wang, bitwangyaoyao@gmail.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
...
...
@@ -87,14 +89,13 @@ PARAM_TEST_CASE(ArithmTestBase, MatType, bool)
int
maskx
;
int
masky
;
//src mat with roi
cv
::
Mat
mat1_roi
;
cv
::
Mat
mat2_roi
;
cv
::
Mat
mask_roi
;
cv
::
Mat
dst_roi
;
cv
::
Mat
dst1_roi
;
//bak
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
cv
::
ocl
::
oclMat
gdst1_whole
;
//bak
...
...
@@ -125,10 +126,6 @@ PARAM_TEST_CASE(ArithmTestBase, MatType, bool)
val
=
cv
::
Scalar
(
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
));
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
random_roi
()
...
...
@@ -175,14 +172,22 @@ PARAM_TEST_CASE(ArithmTestBase, MatType, bool)
gmask
=
mask_roi
;
//end
}
void
Near
(
double
threshold
=
0.
)
{
EXPECT_MAT_NEAR
(
dst
,
Mat
(
gdst_whole
),
threshold
);
}
void
Near1
(
double
threshold
=
0.
)
{
EXPECT_MAT_NEAR
(
dst1
,
Mat
(
gdst1_whole
),
threshold
);
}
};
////////////////////////////////lut/////////////////////////////////////////////////
struct
Lut
:
ArithmTestBase
{};
#define VARNAME(A) string(#A);
TEST_P
(
Lut
,
Mat
)
{
...
...
@@ -203,20 +208,12 @@ TEST_P(Lut, Mat)
cv
::
LUT
(
mat1_roi
,
mat2_roi
,
dst_roi
);
cv
::
ocl
::
LUT
(
gmat1
,
gmat2
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
s
[
1024
];
sprintf
(
s
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0
,
s
);
Near
(
0
);
}
}
////////////////////////////////exp/////////////////////////////////////////////////
struct
Exp
:
ArithmTestBase
{};
TEST_P
(
Exp
,
Mat
)
...
...
@@ -227,20 +224,12 @@ TEST_P(Exp, Mat)
cv
::
exp
(
mat1_roi
,
dst_roi
);
cv
::
ocl
::
exp
(
gmat1
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
s
[
1024
];
sprintf
(
s
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
2
,
s
);
Near
(
2
);
}
}
////////////////////////////////log/////////////////////////////////////////////////
struct
Log
:
ArithmTestBase
{};
TEST_P
(
Log
,
Mat
)
...
...
@@ -249,24 +238,14 @@ TEST_P(Log, Mat)
{
random_roi
();
cv
::
log
(
mat1_roi
,
dst_roi
);
cv
::
ocl
::
log
(
gmat1
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
s
[
1024
];
sprintf
(
s
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1
,
s
);
Near
(
1
);
}
}
////////////////////////////////add/////////////////////////////////////////////////
struct
Add
:
ArithmTestBase
{};
TEST_P
(
Add
,
Mat
)
...
...
@@ -277,12 +256,7 @@ TEST_P(Add, Mat)
cv
::
add
(
mat1_roi
,
mat2_roi
,
dst_roi
);
cv
::
ocl
::
add
(
gmat1
,
gmat2
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
s
[
1024
];
sprintf
(
s
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
s
);
Near
(
0
);
}
}
...
...
@@ -294,14 +268,10 @@ TEST_P(Add, Mat_Mask)
cv
::
add
(
mat1_roi
,
mat2_roi
,
dst_roi
,
mask_roi
);
cv
::
ocl
::
add
(
gmat1
,
gmat2
,
gdst
,
gmask
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
s
[
1024
];
sprintf
(
s
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
s
);
Near
(
0
);
}
}
TEST_P
(
Add
,
Scalar
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
...
...
@@ -310,12 +280,7 @@ TEST_P(Add, Scalar)
cv
::
add
(
mat1_roi
,
val
,
dst_roi
);
cv
::
ocl
::
add
(
gmat1
,
val
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
s
[
1024
];
sprintf
(
s
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
s
);
Near
(
1e-5
);
}
}
...
...
@@ -327,12 +292,7 @@ TEST_P(Add, Scalar_Mask)
cv
::
add
(
mat1_roi
,
val
,
dst_roi
,
mask_roi
);
cv
::
ocl
::
add
(
gmat1
,
val
,
gdst
,
gmask
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
s
[
1024
];
sprintf
(
s
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
s
);
Near
(
1e-5
);
}
}
...
...
@@ -349,12 +309,7 @@ TEST_P(Sub, Mat)
cv
::
subtract
(
mat1_roi
,
mat2_roi
,
dst_roi
);
cv
::
ocl
::
subtract
(
gmat1
,
gmat2
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
s
[
1024
];
sprintf
(
s
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
s
);
Near
(
0
);
}
}
...
...
@@ -366,14 +321,10 @@ TEST_P(Sub, Mat_Mask)
cv
::
subtract
(
mat1_roi
,
mat2_roi
,
dst_roi
,
mask_roi
);
cv
::
ocl
::
subtract
(
gmat1
,
gmat2
,
gdst
,
gmask
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
s
[
1024
];
sprintf
(
s
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
s
);
Near
(
0
);
}
}
TEST_P
(
Sub
,
Scalar
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
...
...
@@ -382,12 +333,7 @@ TEST_P(Sub, Scalar)
cv
::
subtract
(
mat1_roi
,
val
,
dst_roi
);
cv
::
ocl
::
subtract
(
gmat1
,
val
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
s
[
1024
];
sprintf
(
s
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
s
);
Near
(
1e-5
);
}
}
...
...
@@ -399,12 +345,7 @@ TEST_P(Sub, Scalar_Mask)
cv
::
subtract
(
mat1_roi
,
val
,
dst_roi
,
mask_roi
);
cv
::
ocl
::
subtract
(
gmat1
,
val
,
gdst
,
gmask
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
s
[
1024
];
sprintf
(
s
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
s
);
Near
(
1e-5
);
}
}
...
...
@@ -421,12 +362,7 @@ TEST_P(Mul, Mat)
cv
::
multiply
(
mat1_roi
,
mat2_roi
,
dst_roi
);
cv
::
ocl
::
multiply
(
gmat1
,
gmat2
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
s
[
1024
];
sprintf
(
s
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
s
);
Near
(
0
);
}
}
...
...
@@ -441,12 +377,7 @@ TEST_P(Mul, Mat_Scalar)
cv
::
multiply
(
mat1_roi
,
mat2_roi
,
dst_roi
,
s
);
cv
::
ocl
::
multiply
(
gmat1
,
gmat2
,
gdst
,
s
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.001
,
sss
);
Near
(
.001
);
}
}
...
...
@@ -462,13 +393,7 @@ TEST_P(Div, Mat)
cv
::
divide
(
mat1_roi
,
mat2_roi
,
dst_roi
);
cv
::
ocl
::
divide
(
gmat1
,
gmat2
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1
,
sss
);
Near
(
1
);
}
}
...
...
@@ -483,13 +408,7 @@ TEST_P(Div, Mat_Scalar)
cv
::
divide
(
mat1_roi
,
mat2_roi
,
dst_roi
,
s
);
cv
::
ocl
::
divide
(
gmat1
,
gmat2
,
gdst
,
s
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.001
,
sss
);
Near
(
.001
);
}
}
...
...
@@ -504,13 +423,7 @@ TEST_P(Absdiff, Mat)
cv
::
absdiff
(
mat1_roi
,
mat2_roi
,
dst_roi
);
cv
::
ocl
::
absdiff
(
gmat1
,
gmat2
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0
,
sss
);
Near
(
0
);
}
}
...
...
@@ -522,13 +435,7 @@ TEST_P(Absdiff, Mat_Scalar)
cv
::
absdiff
(
mat1_roi
,
val
,
dst_roi
);
cv
::
ocl
::
absdiff
(
gmat1
,
val
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
Near
(
1e-5
);
}
}
...
...
@@ -544,16 +451,8 @@ TEST_P(CartToPolar, angleInDegree)
cv
::
cartToPolar
(
mat1_roi
,
mat2_roi
,
dst_roi
,
dst1_roi
,
1
);
cv
::
ocl
::
cartToPolar
(
gmat1
,
gmat2
,
gdst
,
gdst1
,
1
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
cv
::
Mat
cpu_dst1
;
gdst1_whole
.
download
(
cpu_dst1
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.5
,
sss
);
EXPECT_MAT_NEAR
(
dst1
,
cpu_dst1
,
0.5
,
sss
);
Near
(
.5
);
Near1
(
.5
);
}
}
...
...
@@ -565,22 +464,12 @@ TEST_P(CartToPolar, angleInRadians)
cv
::
cartToPolar
(
mat1_roi
,
mat2_roi
,
dst_roi
,
dst1_roi
,
0
);
cv
::
ocl
::
cartToPolar
(
gmat1
,
gmat2
,
gdst
,
gdst1
,
0
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
cv
::
Mat
cpu_dst1
;
gdst1_whole
.
download
(
cpu_dst1
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.5
,
sss
);
EXPECT_MAT_NEAR
(
dst1
,
cpu_dst1
,
0.5
,
sss
);
Near
(
.5
);
Near1
(
.5
);
}
}
struct
PolarToCart
:
ArithmTestBase
{};
TEST_P
(
PolarToCart
,
angleInDegree
)
...
...
@@ -591,17 +480,8 @@ TEST_P(PolarToCart, angleInDegree)
cv
::
polarToCart
(
mat1_roi
,
mat2_roi
,
dst_roi
,
dst1_roi
,
1
);
cv
::
ocl
::
polarToCart
(
gmat1
,
gmat2
,
gdst
,
gdst1
,
1
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
cv
::
Mat
cpu_dst1
;
gdst1_whole
.
download
(
cpu_dst1
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.5
,
sss
);
EXPECT_MAT_NEAR
(
dst1
,
cpu_dst1
,
0.5
,
sss
);
Near
(
.5
);
Near1
(
.5
);
}
}
...
...
@@ -613,17 +493,8 @@ TEST_P(PolarToCart, angleInRadians)
cv
::
polarToCart
(
mat1_roi
,
mat2_roi
,
dst_roi
,
dst1_roi
,
0
);
cv
::
ocl
::
polarToCart
(
gmat1
,
gmat2
,
gdst
,
gdst1
,
0
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
cv
::
Mat
cpu_dst1
;
gdst1_whole
.
download
(
cpu_dst1
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.5
,
sss
);
EXPECT_MAT_NEAR
(
dst1
,
cpu_dst1
,
0.5
,
sss
);
Near
(
.5
);
Near1
(
.5
);
}
}
...
...
@@ -640,19 +511,11 @@ TEST_P(Magnitude, Mat)
cv
::
magnitude
(
mat1_roi
,
mat2_roi
,
dst_roi
);
cv
::
ocl
::
magnitude
(
gmat1
,
gmat2
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
Near
(
1e-5
);
}
}
struct
Transpose
:
ArithmTestBase
{};
TEST_P
(
Transpose
,
Mat
)
...
...
@@ -663,20 +526,11 @@ TEST_P(Transpose, Mat)
cv
::
transpose
(
mat1_roi
,
dst_roi
);
cv
::
ocl
::
transpose
(
gmat1
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
Near
(
1e-5
);
}
}
struct
Flip
:
ArithmTestBase
{};
TEST_P
(
Flip
,
X
)
...
...
@@ -687,13 +541,7 @@ TEST_P(Flip, X)
cv
::
flip
(
mat1_roi
,
dst_roi
,
0
);
cv
::
ocl
::
flip
(
gmat1
,
gdst
,
0
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
Near
(
1e-5
);
}
}
...
...
@@ -705,13 +553,7 @@ TEST_P(Flip, Y)
cv
::
flip
(
mat1_roi
,
dst_roi
,
1
);
cv
::
ocl
::
flip
(
gmat1
,
gdst
,
1
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
Near
(
1e-5
);
}
}
...
...
@@ -723,18 +565,11 @@ TEST_P(Flip, BOTH)
cv
::
flip
(
mat1_roi
,
dst_roi
,
-
1
);
cv
::
ocl
::
flip
(
gmat1
,
gdst
,
-
1
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
Near
(
1e-5
);
}
}
struct
MinMax
:
ArithmTestBase
{};
TEST_P
(
MinMax
,
MAT
)
...
...
@@ -765,12 +600,8 @@ TEST_P(MinMax, MAT)
double
minVal_
,
maxVal_
;
cv
::
ocl
::
minMax
(
gmat1
,
&
minVal_
,
&
maxVal_
);
//check results
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_DOUBLE_EQ
(
minVal_
,
minVal
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
maxVal_
,
maxVal
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
minVal_
,
minVal
);
EXPECT_DOUBLE_EQ
(
maxVal_
,
maxVal
);
}
}
...
...
@@ -803,12 +634,8 @@ TEST_P(MinMax, MASK)
double
minVal_
,
maxVal_
;
cv
::
ocl
::
minMax
(
gmat1
,
&
minVal_
,
&
maxVal_
,
gmask
);
//check results
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_DOUBLE_EQ
(
minVal_
,
minVal
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
maxVal_
,
maxVal
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
minVal_
,
minVal
);
EXPECT_DOUBLE_EQ
(
maxVal_
,
maxVal
);
}
}
...
...
@@ -919,17 +746,13 @@ TEST_P(MinMaxLoc, MAT)
error1
=
::
abs
(
mat1_roi
.
at
<
double
>
(
maxLoc_
)
-
mat1_roi
.
at
<
double
>
(
maxLoc
));
}
//check results
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_DOUBLE_EQ
(
minVal_
,
minVal
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
maxVal_
,
maxVal
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
minlocVal_
,
minlocVal
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
maxlocVal_
,
maxlocVal
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
minVal_
,
minVal
);
EXPECT_DOUBLE_EQ
(
maxVal_
,
maxVal
);
EXPECT_DOUBLE_EQ
(
minlocVal_
,
minlocVal
);
EXPECT_DOUBLE_EQ
(
maxlocVal_
,
maxlocVal
);
EXPECT_DOUBLE_EQ
(
error0
,
0.0
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
error1
,
0.0
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
error0
,
0.0
);
EXPECT_DOUBLE_EQ
(
error1
,
0.0
);
}
}
...
...
@@ -1040,17 +863,13 @@ TEST_P(MinMaxLoc, MASK)
error1
=
::
abs
(
mat1_roi
.
at
<
double
>
(
maxLoc_
)
-
mat1_roi
.
at
<
double
>
(
maxLoc
));
}
//check results
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_DOUBLE_EQ
(
minVal_
,
minVal
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
maxVal_
,
maxVal
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
minlocVal_
,
minlocVal
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
maxlocVal_
,
maxlocVal
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
minVal_
,
minVal
);
EXPECT_DOUBLE_EQ
(
maxVal_
,
maxVal
);
EXPECT_DOUBLE_EQ
(
minlocVal_
,
minlocVal
);
EXPECT_DOUBLE_EQ
(
maxlocVal_
,
maxlocVal
);
EXPECT_DOUBLE_EQ
(
error0
,
0.0
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
error1
,
0.0
)
<<
sss
;
EXPECT_DOUBLE_EQ
(
error0
,
0.0
);
EXPECT_DOUBLE_EQ
(
error1
,
0.0
);
}
}
...
...
@@ -1064,14 +883,12 @@ TEST_P(Sum, MAT)
random_roi
();
Scalar
cpures
=
cv
::
sum
(
mat1_roi
);
Scalar
gpures
=
cv
::
ocl
::
sum
(
gmat1
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
//check results
EXPECT_NEAR
(
cpures
[
0
],
gpures
[
0
],
0.1
)
<<
sss
;
EXPECT_NEAR
(
cpures
[
1
],
gpures
[
1
],
0.1
)
<<
sss
;
EXPECT_NEAR
(
cpures
[
2
],
gpures
[
2
],
0.1
)
<<
sss
;
EXPECT_NEAR
(
cpures
[
3
],
gpures
[
3
],
0.1
)
<<
sss
;
EXPECT_NEAR
(
cpures
[
0
],
gpures
[
0
],
0.1
);
EXPECT_NEAR
(
cpures
[
1
],
gpures
[
1
],
0.1
);
EXPECT_NEAR
(
cpures
[
2
],
gpures
[
2
],
0.1
);
EXPECT_NEAR
(
cpures
[
3
],
gpures
[
3
],
0.1
);
}
}
...
...
@@ -1086,11 +903,7 @@ TEST_P(CountNonZero, MAT)
int
cpures
=
cv
::
countNonZero
(
mat1_roi
);
int
gpures
=
cv
::
ocl
::
countNonZero
(
gmat1
);
//check results
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_DOUBLE_EQ
((
double
)
cpures
,
(
double
)
gpures
)
<<
sss
;
EXPECT_DOUBLE_EQ
((
double
)
cpures
,
(
double
)
gpures
);
}
}
...
...
@@ -1112,13 +925,7 @@ TEST_P(Phase, Mat)
random_roi
();
cv
::
phase
(
mat1_roi
,
mat2_roi
,
dst_roi
,
angelInDegrees
?
true
:
false
);
cv
::
ocl
::
phase
(
gmat1
,
gmat2
,
gdst
,
angelInDegrees
?
true
:
false
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-2
,
sss
);
Near
(
1e-2
);
}
}
}
...
...
@@ -1135,13 +942,7 @@ TEST_P(Bitwise_and, Mat)
cv
::
bitwise_and
(
mat1_roi
,
mat2_roi
,
dst_roi
);
cv
::
ocl
::
bitwise_and
(
gmat1
,
gmat2
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
sss
);
Near
(
0
);
}
}
...
...
@@ -1153,15 +954,10 @@ TEST_P(Bitwise_and, Mat_Mask)
cv
::
bitwise_and
(
mat1_roi
,
mat2_roi
,
dst_roi
,
mask_roi
);
cv
::
ocl
::
bitwise_and
(
gmat1
,
gmat2
,
gdst
,
gmask
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
sss
);
Near
(
0
);
}
}
TEST_P
(
Bitwise_and
,
Scalar
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
...
...
@@ -1170,14 +966,7 @@ TEST_P(Bitwise_and, Scalar)
cv
::
bitwise_and
(
mat1_roi
,
val
,
dst_roi
);
cv
::
ocl
::
bitwise_and
(
gmat1
,
val
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
Near
(
1e-5
);
}
}
...
...
@@ -1189,14 +978,7 @@ TEST_P(Bitwise_and, Scalar_Mask)
cv
::
bitwise_and
(
mat1_roi
,
val
,
dst_roi
,
mask_roi
);
cv
::
ocl
::
bitwise_and
(
gmat1
,
val
,
gdst
,
gmask
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
*
sss
=
new
char
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
delete
[]
sss
;
Near
(
1e-5
);
}
}
...
...
@@ -1214,13 +996,7 @@ TEST_P(Bitwise_or, Mat)
cv
::
bitwise_or
(
mat1_roi
,
mat2_roi
,
dst_roi
);
cv
::
ocl
::
bitwise_or
(
gmat1
,
gmat2
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
sss
);
Near
(
0
);
}
}
...
...
@@ -1232,15 +1008,10 @@ TEST_P(Bitwise_or, Mat_Mask)
cv
::
bitwise_or
(
mat1_roi
,
mat2_roi
,
dst_roi
,
mask_roi
);
cv
::
ocl
::
bitwise_or
(
gmat1
,
gmat2
,
gdst
,
gmask
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
sss
);
Near
(
0
);
}
}
TEST_P
(
Bitwise_or
,
Scalar
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
...
...
@@ -1249,13 +1020,7 @@ TEST_P(Bitwise_or, Scalar)
cv
::
bitwise_or
(
mat1_roi
,
val
,
dst_roi
);
cv
::
ocl
::
bitwise_or
(
gmat1
,
val
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
Near
(
1e-5
);
}
}
...
...
@@ -1267,13 +1032,7 @@ TEST_P(Bitwise_or, Scalar_Mask)
cv
::
bitwise_or
(
mat1_roi
,
val
,
dst_roi
,
mask_roi
);
cv
::
ocl
::
bitwise_or
(
gmat1
,
val
,
gdst
,
gmask
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
Near
(
1e-5
);
}
}
...
...
@@ -1291,13 +1050,7 @@ TEST_P(Bitwise_xor, Mat)
cv
::
bitwise_xor
(
mat1_roi
,
mat2_roi
,
dst_roi
);
cv
::
ocl
::
bitwise_xor
(
gmat1
,
gmat2
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
sss
);
Near
(
0
);
}
}
...
...
@@ -1309,15 +1062,10 @@ TEST_P(Bitwise_xor, Mat_Mask)
cv
::
bitwise_xor
(
mat1_roi
,
mat2_roi
,
dst_roi
,
mask_roi
);
cv
::
ocl
::
bitwise_xor
(
gmat1
,
gmat2
,
gdst
,
gmask
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
sss
);
Near
(
0
);
}
}
TEST_P
(
Bitwise_xor
,
Scalar
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
...
...
@@ -1326,13 +1074,7 @@ TEST_P(Bitwise_xor, Scalar)
cv
::
bitwise_xor
(
mat1_roi
,
val
,
dst_roi
);
cv
::
ocl
::
bitwise_xor
(
gmat1
,
val
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
Near
(
1e-5
);
}
}
...
...
@@ -1344,13 +1086,7 @@ TEST_P(Bitwise_xor, Scalar_Mask)
cv
::
bitwise_xor
(
mat1_roi
,
val
,
dst_roi
,
mask_roi
);
cv
::
ocl
::
bitwise_xor
(
gmat1
,
val
,
gdst
,
gmask
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
Near
(
1e-5
);
}
}
...
...
@@ -1367,13 +1103,7 @@ TEST_P(Bitwise_not, Mat)
cv
::
bitwise_not
(
mat1_roi
,
dst_roi
);
cv
::
ocl
::
bitwise_not
(
gmat1
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
sss
);
Near
(
0
);
}
}
...
...
@@ -1390,7 +1120,7 @@ TEST_P(Compare, Mat)
}
int
cmp_codes
[]
=
{
CMP_EQ
,
CMP_GT
,
CMP_GE
,
CMP_LT
,
CMP_LE
,
CMP_NE
};
const
char
*
cmp_str
[]
=
{
"CMP_EQ"
,
"CMP_GT"
,
"CMP_GE"
,
"CMP_LT"
,
"CMP_LE"
,
"CMP_NE"
};
//
const char *cmp_str[] = {"CMP_EQ", "CMP_GT", "CMP_GE", "CMP_LT", "CMP_LE", "CMP_NE"};
int
cmp_num
=
sizeof
(
cmp_codes
)
/
sizeof
(
int
);
for
(
int
i
=
0
;
i
<
cmp_num
;
++
i
)
...
...
@@ -1402,13 +1132,7 @@ TEST_P(Compare, Mat)
cv
::
compare
(
mat1_roi
,
mat2_roi
,
dst_roi
,
cmp_codes
[
i
]);
cv
::
ocl
::
compare
(
gmat1
,
gmat2
,
gdst
,
cmp_codes
[
i
]);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"cmptype=%s, roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
cmp_str
[
i
],
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
sss
);
Near
(
0
);
}
}
...
...
@@ -1430,14 +1154,7 @@ TEST_P(Pow, Mat)
double
p
=
4.5
;
cv
::
pow
(
mat1_roi
,
p
,
dst_roi
);
cv
::
ocl
::
pow
(
gmat1
,
p
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1
,
sss
);
Near
(
1
);
}
}
...
...
@@ -1448,36 +1165,18 @@ TEST_P(MagnitudeSqr, Mat)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
// random_roi();
// int64 start, end;
// start = cv::getTickCount();
random_roi
();
for
(
int
i
=
0
;
i
<
mat1
.
rows
;
++
i
)
for
(
int
j
=
0
;
j
<
mat1
.
cols
;
++
j
)
{
float
val1
=
mat1
.
at
<
float
>
(
i
,
j
);
float
val2
=
mat2
.
at
<
float
>
(
i
,
j
);
((
float
*
)(
dst
.
data
))[
i
*
dst
.
step
/
4
+
j
]
=
val1
*
val1
+
val2
*
val2
;
// float val1 =((float *)( mat1.data))[(i*mat1.step/8 +j)*2];
//
// float val2 =((float *)( mat1.data))[(i*mat1.step/8 +j)*2+ 1 ];
// ((float *)(dst.data))[i*dst.step/4 +j]= val1 * val1 +val2 * val2;
}
// end = cv::getTickCount();
cv
::
ocl
::
oclMat
clmat1
(
mat1
),
clmat2
(
mat2
),
cldst
;
cv
::
ocl
::
magnitudeSqr
(
clmat1
,
clmat2
,
cldst
);
cv
::
Mat
cpu_dst
;
cldst
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1
,
sss
);
cv
::
ocl
::
oclMat
clmat1
(
mat1
),
clmat2
(
mat2
);
cv
::
ocl
::
magnitudeSqr
(
clmat1
,
clmat2
,
gdst
);
Near
(
1
);
}
}
...
...
@@ -1498,21 +1197,13 @@ TEST_P(AddWeighted, Mat)
cv
::
ocl
::
addWeighted
(
gmat1
,
alpha
,
gmat2
,
beta
,
gama
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
Near
(
1e-5
);
}
}
//********test****************
INSTANTIATE_TEST_CASE_P
(
Arithm
,
Lut
,
Combine
(
...
...
modules/ocl/test/test_blend.cpp
View file @
6eb5a95a
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Nathan, liujun@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other oclMaterials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors as is and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
#include <iomanip>
...
...
@@ -33,20 +77,14 @@ void blendLinearGold(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &we
PARAM_TEST_CASE
(
Blend
,
cv
::
Size
,
MatType
/*, UseRoi*/
)
{
//std::vector<cv::ocl::Info> oclinfo;
cv
::
Size
size
;
int
type
;
bool
useRoi
;
virtual
void
SetUp
()
{
//devInfo = GET_PARAM(0);
size
=
GET_PARAM
(
0
);
type
=
GET_PARAM
(
1
);
/*useRoi = GET_PARAM(3);*/
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
}
};
...
...
@@ -59,12 +97,9 @@ TEST_P(Blend, Accuracy)
cv
::
Mat
weights1
=
randomMat
(
size
,
CV_32F
,
0
,
1
);
cv
::
Mat
weights2
=
randomMat
(
size
,
CV_32F
,
0
,
1
);
cv
::
ocl
::
oclMat
gimg1
(
size
,
type
),
gimg2
(
size
,
type
),
gweights1
(
size
,
CV_32F
),
gweights2
(
size
,
CV_32F
);
cv
::
ocl
::
oclMat
dst
(
size
,
type
);
gimg1
.
upload
(
img1
);
gimg2
.
upload
(
img2
);
gweights1
.
upload
(
weights1
);
gweights2
.
upload
(
weights2
);
cv
::
ocl
::
oclMat
gimg1
(
img1
),
gimg2
(
img2
),
gweights1
(
weights1
),
gweights2
(
weights2
);
cv
::
ocl
::
oclMat
dst
;
cv
::
ocl
::
blendLinear
(
gimg1
,
gimg2
,
gweights1
,
gweights2
,
dst
);
cv
::
Mat
result
;
cv
::
Mat
result_gold
;
...
...
@@ -74,10 +109,10 @@ TEST_P(Blend, Accuracy)
else
blendLinearGold
<
float
>
(
img1
,
img2
,
weights1
,
weights2
,
result_gold
);
EXPECT_MAT_NEAR
(
result_gold
,
result
,
CV_MAT_DEPTH
(
type
)
==
CV_8U
?
1.
f
:
1e-5
f
,
0
);
EXPECT_MAT_NEAR
(
result_gold
,
result
,
CV_MAT_DEPTH
(
type
)
==
CV_8U
?
1.
f
:
1e-5
f
);
}
INSTANTIATE_TEST_CASE_P
(
GPU
_ImgProc
,
Blend
,
Combine
(
INSTANTIATE_TEST_CASE_P
(
OCL
_ImgProc
,
Blend
,
Combine
(
DIFFERENT_SIZES
,
testing
::
Values
(
MatType
(
CV_8UC1
),
MatType
(
CV_8UC3
),
MatType
(
CV_8UC4
),
MatType
(
CV_32FC1
),
MatType
(
CV_32FC4
))
));
...
...
modules/ocl/test/test_brute_force_matcher.cpp
View file @
6eb5a95a
...
...
@@ -7,12 +7,16 @@
// copy or use the software.
//
//
//
Intel
License Agreement
//
License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2010-2012, Multicoreware inc., all rights reserved.
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
// Nathan, liujun@multicorewareinc.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
...
...
@@ -21,12 +25,12 @@
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other
m
aterials provided with the distribution.
// and/or other
oclM
aterials provided with the distribution.
//
// * The name of
Intel Corporation
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.
//
// This software is provided by the copyright holders and contributors
"as is"
and
// This software is provided by the copyright holders and contributors
as is
and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
...
...
modules/ocl/test/test_calib3d.cpp
View file @
6eb5a95a
...
...
@@ -129,7 +129,7 @@ TEST_P(StereoMatchBP, Regression)
bp
(
d_left
,
d_right
,
d_disp
);
d_disp
.
download
(
disp
);
disp
.
convertTo
(
disp
,
disp_gold
.
depth
());
EXPECT_MAT_NEAR
(
disp_gold
,
disp
,
0.0
,
""
);
EXPECT_MAT_NEAR
(
disp_gold
,
disp
,
0.0
);
}
INSTANTIATE_TEST_CASE_P
(
OCL_Calib3D
,
StereoMatchBP
,
testing
::
Combine
(
testing
::
Values
(
64
),
testing
::
Values
(
8
),
testing
::
Values
(
2
),
testing
::
Values
(
25.0
f
),
...
...
modules/ocl/test/test_color.cpp
View file @
6eb5a95a
...
...
@@ -100,7 +100,7 @@ PARAM_TEST_CASE(CvtColor, cv::Size, MatDepth)
cv::cvtColor(src, dst_gold, CVTCODE(name));\
cv::Mat dst_mat;\
dst.download(dst_mat);\
EXPECT_MAT_NEAR(dst_gold, dst_mat, 1e-5
, ""
);\
EXPECT_MAT_NEAR(dst_gold, dst_mat, 1e-5);\
}
//add new ones here using macro
...
...
@@ -141,7 +141,7 @@ TEST_P(CvtColor_Gray2RGB, Accuracy)
cv
::
cvtColor
(
src
,
dst_gold
,
code
);
cv
::
Mat
dst_mat
;
dst
.
download
(
dst_mat
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst_mat
,
1e-5
,
""
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst_mat
,
1e-5
);
}
...
...
@@ -171,7 +171,7 @@ TEST_P(CvtColor_YUV420, Accuracy)
cv
::
Mat
dst_mat
;
dst
.
download
(
dst_mat
);
MAT_DIFF
(
dst_mat
,
dst_gold
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst_mat
,
1e-5
,
""
);
EXPECT_MAT_NEAR
(
dst_gold
,
dst_mat
,
1e-5
);
}
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
CvtColor
,
testing
::
Combine
(
...
...
modules/ocl/test/test_columnsum.cpp
View file @
6eb5a95a
...
...
@@ -47,27 +47,16 @@
#include "precomp.hpp"
#include <iomanip>
///////////////////////////////////////////////////////////////////////////////
/// ColumnSum
#ifdef HAVE_OPENCL
////////////////////////////////////////////////////////////////////////
// ColumnSum
PARAM_TEST_CASE
(
ColumnSum
,
cv
::
Size
,
bool
)
PARAM_TEST_CASE
(
ColumnSum
,
cv
::
Size
)
{
cv
::
Size
size
;
cv
::
Mat
src
;
bool
useRoi
;
//std::vector<cv::ocl::Info> oclinfo;
virtual
void
SetUp
()
{
size
=
GET_PARAM
(
0
);
useRoi
=
GET_PARAM
(
1
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
}
};
...
...
@@ -99,8 +88,7 @@ TEST_P(ColumnSum, Accuracy)
}
}
INSTANTIATE_TEST_CASE_P
(
GPU_ImgProc
,
ColumnSum
,
testing
::
Combine
(
DIFFERENT_SIZES
,
testing
::
Values
(
Inverse
(
false
),
Inverse
(
true
))));
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
ColumnSum
,
DIFFERENT_SIZES
);
#endif
modules/ocl/test/test_fft.cpp
View file @
6eb5a95a
...
...
@@ -68,7 +68,7 @@ TEST_P(Dft, C2C)
cv
::
dft
(
a
,
b_gold
,
dft_flags
);
cv
::
ocl
::
dft
(
cv
::
ocl
::
oclMat
(
a
),
d_b
,
a
.
size
(),
dft_flags
);
EXPECT_MAT_NEAR
(
b_gold
,
cv
::
Mat
(
d_b
),
a
.
size
().
area
()
*
1e-4
,
""
);
EXPECT_MAT_NEAR
(
b_gold
,
cv
::
Mat
(
d_b
),
a
.
size
().
area
()
*
1e-4
);
}
TEST_P
(
Dft
,
R2C
)
...
...
@@ -81,11 +81,11 @@ TEST_P(Dft, R2C)
cv
::
dft
(
a
,
b_gold
,
cv
::
DFT_COMPLEX_OUTPUT
|
dft_flags
);
b_gold_roi
=
b_gold
(
cv
::
Rect
(
0
,
0
,
d_b
.
cols
,
d_b
.
rows
));
EXPECT_MAT_NEAR
(
b_gold_roi
,
cv
::
Mat
(
d_b
),
a
.
size
().
area
()
*
1e-4
,
""
);
EXPECT_MAT_NEAR
(
b_gold_roi
,
cv
::
Mat
(
d_b
),
a
.
size
().
area
()
*
1e-4
);
cv
::
Mat
c_gold
;
cv
::
dft
(
b_gold
,
c_gold
,
cv
::
DFT_INVERSE
|
cv
::
DFT_REAL_OUTPUT
|
cv
::
DFT_SCALE
);
EXPECT_MAT_NEAR
(
b_gold_roi
,
cv
::
Mat
(
d_b
),
a
.
size
().
area
()
*
1e-4
,
""
);
EXPECT_MAT_NEAR
(
b_gold_roi
,
cv
::
Mat
(
d_b
),
a
.
size
().
area
()
*
1e-4
);
}
TEST_P
(
Dft
,
R2CthenC2R
)
...
...
@@ -95,7 +95,7 @@ TEST_P(Dft, R2CthenC2R)
cv
::
ocl
::
oclMat
d_b
,
d_c
;
cv
::
ocl
::
dft
(
cv
::
ocl
::
oclMat
(
a
),
d_b
,
a
.
size
(),
0
);
cv
::
ocl
::
dft
(
d_b
,
d_c
,
a
.
size
(),
cv
::
DFT_SCALE
|
cv
::
DFT_INVERSE
|
cv
::
DFT_REAL_OUTPUT
);
EXPECT_MAT_NEAR
(
a
,
d_c
,
a
.
size
().
area
()
*
1e-4
,
""
);
EXPECT_MAT_NEAR
(
a
,
d_c
,
a
.
size
().
area
()
*
1e-4
);
}
...
...
modules/ocl/test/test_filters.cpp
View file @
6eb5a95a
...
...
@@ -12,6 +12,7 @@
//
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
...
...
@@ -19,6 +20,7 @@
// Jia Haipeng, jiahaipeng95@gmail.com
// Zero Lin, Zero.Lin@amd.com
// Zhang Ying, zhangying913@gmail.com
// Yao Wang, bitwangyaoyao@gmail.com
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
...
...
@@ -55,191 +57,93 @@ using namespace testing;
using
namespace
std
;
PARAM_TEST_CASE
(
FilterTestBase
,
MatType
,
bool
)
PARAM_TEST_CASE
(
FilterTestBase
,
MatType
,
cv
::
Size
,
// kernel size
cv
::
Size
,
// dx,dy
int
// border type, or iteration
)
{
int
type
;
cv
::
Scalar
val
;
//src mat
cv
::
Mat
mat1
;
cv
::
Mat
mat2
;
cv
::
Mat
mask
;
cv
::
Mat
dst
;
cv
::
Mat
dst1
;
//bak, for two outputs
// set up roi
int
roicols
;
int
roirows
;
int
src1x
;
int
src1y
;
int
src2x
;
int
src2y
;
int
dstx
;
int
dsty
;
int
maskx
;
int
masky
;
//src mat with roi
cv
::
Mat
mat1_roi
;
cv
::
Mat
mat2_roi
;
cv
::
Mat
mask_roi
;
cv
::
Mat
dst_roi
;
cv
::
Mat
dst1_roi
;
//bak
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
cv
::
ocl
::
oclMat
gdst1_whole
;
//bak
//ocl mat with roi
cv
::
ocl
::
oclMat
gmat1
;
cv
::
ocl
::
oclMat
gmat2
;
cv
::
ocl
::
oclMat
gdst
;
cv
::
ocl
::
oclMat
gdst1
;
//bak
cv
::
ocl
::
oclMat
gmask
;
virtual
void
SetUp
()
{
type
=
GET_PARAM
(
0
);
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
Size
size
(
MWIDTH
,
MHEIGHT
);
mat1
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
mat2
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dst
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dst1
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
mask
=
randomMat
(
rng
,
size
,
CV_8UC1
,
0
,
2
,
false
);
cv
::
threshold
(
mask
,
mask
,
0.5
,
255.
,
CV_8UC1
);
val
=
cv
::
Scalar
(
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
));
}
void
random_roi
()
{
#ifdef RANDOMROI
//randomize ROI
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
roicols
=
rng
.
uniform
(
1
,
mat1
.
cols
);
roirows
=
rng
.
uniform
(
1
,
mat1
.
rows
);
roicols
=
rng
.
uniform
(
2
,
mat1
.
cols
);
roirows
=
rng
.
uniform
(
2
,
mat1
.
rows
);
src1x
=
rng
.
uniform
(
0
,
mat1
.
cols
-
roicols
);
src1y
=
rng
.
uniform
(
0
,
mat1
.
rows
-
roirows
);
src2x
=
rng
.
uniform
(
0
,
mat2
.
cols
-
roicols
);
src2y
=
rng
.
uniform
(
0
,
mat2
.
rows
-
roirows
);
dstx
=
rng
.
uniform
(
0
,
dst
.
cols
-
roicols
);
dsty
=
rng
.
uniform
(
0
,
dst
.
rows
-
roirows
);
maskx
=
rng
.
uniform
(
0
,
mask
.
cols
-
roicols
);
masky
=
rng
.
uniform
(
0
,
mask
.
rows
-
roirows
);
#else
roicols
=
mat1
.
cols
;
roirows
=
mat1
.
rows
;
src1x
=
0
;
src1y
=
0
;
src2x
=
0
;
src2y
=
0
;
dstx
=
0
;
dsty
=
0
;
maskx
=
0
;
masky
=
0
;
#endif
mat1_roi
=
mat1
(
Rect
(
src1x
,
src1y
,
roicols
,
roirows
));
mat2_roi
=
mat2
(
Rect
(
src2x
,
src2y
,
roicols
,
roirows
));
mask_roi
=
mask
(
Rect
(
maskx
,
masky
,
roicols
,
roirows
));
dst_roi
=
dst
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
dst1_roi
=
dst1
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gdst_whole
=
dst
;
gdst
=
gdst_whole
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gdst1_whole
=
dst1
;
gdst1
=
gdst1_whole
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gmat1
=
mat1_roi
;
gmat2
=
mat2_roi
;
gmask
=
mask_roi
;
}
void
Init
(
int
mat_type
)
{
cv
::
Size
size
(
MWIDTH
,
MHEIGHT
);
mat1
=
randomMat
(
size
,
mat_type
,
5
,
16
);
dst
=
randomMat
(
size
,
mat_type
,
5
,
16
);
}
void
Near
(
double
threshold
)
{
EXPECT_MAT_NEAR
(
dst
,
Mat
(
gdst_whole
),
threshold
);
}
};
/////////////////////////////////////////////////////////////////////////////////////////////////
// blur
PARAM_TEST_CASE
(
Blur
,
MatType
,
cv
::
Size
,
int
)
struct
Blur
:
FilterTestBase
{
int
type
;
cv
::
Size
ksize
;
int
bordertype
;
//src mat
cv
::
Mat
mat1
;
cv
::
Mat
dst
;
// set up roi
int
roicols
;
int
roirows
;
int
src1x
;
int
src1y
;
int
dstx
;
int
dsty
;
//src mat with roi
cv
::
Mat
mat1_roi
;
cv
::
Mat
dst_roi
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
//ocl mat with roi
cv
::
ocl
::
oclMat
gmat1
;
cv
::
ocl
::
oclMat
gdst
;
virtual
void
SetUp
()
{
type
=
GET_PARAM
(
0
);
ksize
=
GET_PARAM
(
1
);
bordertype
=
GET_PARAM
(
2
);
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
Size
size
(
MWIDTH
,
MHEIGHT
);
mat1
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dst
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
random_roi
()
{
#ifdef RANDOMROI
//randomize ROI
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
roicols
=
rng
.
uniform
(
2
,
mat1
.
cols
);
roirows
=
rng
.
uniform
(
2
,
mat1
.
rows
);
src1x
=
rng
.
uniform
(
0
,
mat1
.
cols
-
roicols
);
src1y
=
rng
.
uniform
(
0
,
mat1
.
rows
-
roirows
);
dstx
=
rng
.
uniform
(
0
,
dst
.
cols
-
roicols
);
dsty
=
rng
.
uniform
(
0
,
dst
.
rows
-
roirows
);
#else
roicols
=
mat1
.
cols
;
roirows
=
mat1
.
rows
;
src1x
=
0
;
src1y
=
0
;
dstx
=
0
;
dsty
=
0
;
#endif
mat1_roi
=
mat1
(
Rect
(
src1x
,
src1y
,
roicols
,
roirows
));
dst_roi
=
dst
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gdst_whole
=
dst
;
gdst
=
gdst_whole
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gmat1
=
mat1_roi
;
bordertype
=
GET_PARAM
(
3
);
Init
(
type
);
}
};
TEST_P
(
Blur
,
Mat
)
...
...
@@ -247,116 +151,36 @@ TEST_P(Blur, Mat)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
random_roi
();
cv
::
blur
(
mat1_roi
,
dst_roi
,
ksize
,
Point
(
-
1
,
-
1
),
bordertype
);
cv
::
ocl
::
blur
(
gmat1
,
gdst
,
ksize
,
Point
(
-
1
,
-
1
),
bordertype
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1.0
,
sss
);
Near
(
1.0
);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////
//Laplacian
PARAM_TEST_CASE
(
LaplacianTestBase
,
MatType
,
int
)
struct
Laplacian
:
FilterTestBase
{
int
type
;
int
ksize
;
//src mat
cv
::
Mat
mat
;
cv
::
Mat
dst
;
// set up roi
int
roicols
;
int
roirows
;
int
srcx
;
int
srcy
;
int
dstx
;
int
dsty
;
//src mat with roi
cv
::
Mat
mat_roi
;
cv
::
Mat
dst_roi
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
//ocl mat with roi
cv
::
ocl
::
oclMat
gmat
;
cv
::
ocl
::
oclMat
gdst
;
cv
::
Size
ksize
;
virtual
void
SetUp
()
{
type
=
GET_PARAM
(
0
);
ksize
=
GET_PARAM
(
1
);
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
Size
size
(
MWIDTH
,
MHEIGHT
);
mat
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dst
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
random_roi
()
{
#ifdef RANDOMROI
//randomize ROI
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
roicols
=
rng
.
uniform
(
2
,
mat
.
cols
);
roirows
=
rng
.
uniform
(
2
,
mat
.
rows
);
srcx
=
rng
.
uniform
(
0
,
mat
.
cols
-
roicols
);
srcy
=
rng
.
uniform
(
0
,
mat
.
rows
-
roirows
);
dstx
=
rng
.
uniform
(
0
,
dst
.
cols
-
roicols
);
dsty
=
rng
.
uniform
(
0
,
dst
.
rows
-
roirows
);
#else
roicols
=
mat
.
cols
;
roirows
=
mat
.
rows
;
srcx
=
0
;
srcy
=
0
;
dstx
=
0
;
dsty
=
0
;
#endif
mat_roi
=
mat
(
Rect
(
srcx
,
srcy
,
roicols
,
roirows
));
dst_roi
=
dst
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gdst_whole
=
dst
;
gdst
=
gdst_whole
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gmat
=
mat_roi
;
Init
(
type
);
}
};
struct
Laplacian
:
LaplacianTestBase
{};
TEST_P
(
Laplacian
,
Accuracy
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
random_roi
();
cv
::
Laplacian
(
mat_roi
,
dst_roi
,
-
1
,
ksize
,
1
);
cv
::
ocl
::
Laplacian
(
gmat
,
gdst
,
-
1
,
ksize
,
1
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d"
,
roicols
,
roirows
,
srcx
,
srcy
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
cv
::
Laplacian
(
mat1_roi
,
dst_roi
,
-
1
,
ksize
.
width
,
1
);
cv
::
ocl
::
Laplacian
(
gmat1
,
gdst
,
-
1
,
ksize
.
width
,
1
);
Near
(
1e-5
);
}
}
...
...
@@ -364,8 +188,7 @@ TEST_P(Laplacian, Accuracy)
/////////////////////////////////////////////////////////////////////////////////////////////////
// erode & dilate
PARAM_TEST_CASE
(
ErodeDilateBase
,
MatType
,
int
)
struct
ErodeDilate
:
FilterTestBase
{
int
type
;
int
iterations
;
...
...
@@ -373,210 +196,54 @@ PARAM_TEST_CASE(ErodeDilateBase, MatType, int)
//erode or dilate kernel
cv
::
Mat
kernel
;
//src mat
cv
::
Mat
mat1
;
cv
::
Mat
dst
;
// set up roi
int
roicols
;
int
roirows
;
int
src1x
;
int
src1y
;
int
dstx
;
int
dsty
;
//src mat with roi
cv
::
Mat
mat1_roi
;
cv
::
Mat
dst_roi
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
//ocl mat with roi
cv
::
ocl
::
oclMat
gmat1
;
cv
::
ocl
::
oclMat
gdst
;
virtual
void
SetUp
()
{
type
=
GET_PARAM
(
0
);
iterations
=
GET_PARAM
(
1
);
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
Size
size
(
MWIDTH
,
MHEIGHT
);
mat1
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dst
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
iterations
=
GET_PARAM
(
3
);
Init
(
type
);
// rng.fill(kernel, cv::RNG::UNIFORM, cv::Scalar::all(0), cv::Scalar::all(3));
kernel
=
randomMat
(
rng
,
Size
(
3
,
3
),
CV_8UC1
,
0
,
3
,
false
);
}
void
random_roi
()
{
#ifdef RANDOMROI
//randomize ROI
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
roicols
=
rng
.
uniform
(
2
,
mat1
.
cols
);
roirows
=
rng
.
uniform
(
2
,
mat1
.
rows
);
src1x
=
rng
.
uniform
(
0
,
mat1
.
cols
-
roicols
);
src1y
=
rng
.
uniform
(
0
,
mat1
.
rows
-
roirows
);
dstx
=
rng
.
uniform
(
0
,
dst
.
cols
-
roicols
);
dsty
=
rng
.
uniform
(
0
,
dst
.
rows
-
roirows
);
#else
roicols
=
mat1
.
cols
;
roirows
=
mat1
.
rows
;
src1x
=
0
;
src1y
=
0
;
dstx
=
0
;
dsty
=
0
;
#endif
mat1_roi
=
mat1
(
Rect
(
src1x
,
src1y
,
roicols
,
roirows
));
dst_roi
=
dst
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gdst_whole
=
dst
;
gdst
=
gdst_whole
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gmat1
=
mat1_roi
;
kernel
=
randomMat
(
Size
(
3
,
3
),
CV_8UC1
,
0
,
3
);
}
};
// erode
struct
Erode
:
ErodeDilateBase
{};
TEST_P
(
Erode
,
Mat
)
TEST_P
(
ErodeDilate
,
Mat
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
random_roi
();
cv
::
erode
(
mat1_roi
,
dst_roi
,
kernel
,
Point
(
-
1
,
-
1
),
iterations
);
cv
::
ocl
::
erode
(
gmat1
,
gdst
,
kernel
,
Point
(
-
1
,
-
1
),
iterations
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
Near
(
1e-5
);
}
}
// dilate
struct
Dilate
:
ErodeDilateBase
{};
TEST_P
(
Dilate
,
Mat
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
random_roi
();
cv
::
erode
(
mat1_roi
,
dst_roi
,
kernel
,
Point
(
-
1
,
-
1
),
iterations
);
cv
::
ocl
::
erode
(
gmat1
,
gdst
,
kernel
,
Point
(
-
1
,
-
1
),
iterations
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-5
,
sss
);
cv
::
dilate
(
mat1_roi
,
dst_roi
,
kernel
,
Point
(
-
1
,
-
1
),
iterations
);
cv
::
ocl
::
dilate
(
gmat1
,
gdst
,
kernel
,
Point
(
-
1
,
-
1
),
iterations
);
Near
(
1e-5
);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// Sobel
PARAM_TEST_CASE
(
Sobel
,
MatType
,
int
,
int
,
int
,
int
)
struct
Sobel
:
FilterTestBase
{
int
type
;
int
dx
,
dy
,
ksize
,
bordertype
;
//src mat
cv
::
Mat
mat1
;
cv
::
Mat
dst
;
// set up roi
int
roicols
;
int
roirows
;
int
src1x
;
int
src1y
;
int
dstx
;
int
dsty
;
//src mat with roi
cv
::
Mat
mat1_roi
;
cv
::
Mat
dst_roi
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
//ocl mat with roi
cv
::
ocl
::
oclMat
gmat1
;
cv
::
ocl
::
oclMat
gdst
;
virtual
void
SetUp
()
{
type
=
GET_PARAM
(
0
);
dx
=
GET_PARAM
(
1
);
dy
=
GET_PARAM
(
2
);
ksize
=
GET_PARAM
(
3
);
bordertype
=
GET_PARAM
(
4
);
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
Size
size
(
MWIDTH
,
MHEIGHT
);
mat1
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dst
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
random_roi
()
{
#ifdef RANDOMROI
//randomize ROI
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
roicols
=
rng
.
uniform
(
2
,
mat1
.
cols
);
roirows
=
rng
.
uniform
(
2
,
mat1
.
rows
);
src1x
=
rng
.
uniform
(
0
,
mat1
.
cols
-
roicols
);
src1y
=
rng
.
uniform
(
0
,
mat1
.
rows
-
roirows
);
dstx
=
rng
.
uniform
(
0
,
dst
.
cols
-
roicols
);
dsty
=
rng
.
uniform
(
0
,
dst
.
rows
-
roirows
);
#else
roicols
=
mat1
.
cols
;
roirows
=
mat1
.
rows
;
src1x
=
0
;
src1y
=
0
;
dstx
=
0
;
dsty
=
0
;
#endif
mat1_roi
=
mat1
(
Rect
(
src1x
,
src1y
,
roicols
,
roirows
));
dst_roi
=
dst
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gdst_whole
=
dst
;
gdst
=
gdst_whole
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gmat1
=
mat1_roi
;
Size
s
=
GET_PARAM
(
1
);
ksize
=
s
.
width
;
s
=
GET_PARAM
(
2
);
dx
=
s
.
width
;
dy
=
s
.
height
;
bordertype
=
GET_PARAM
(
3
);
Init
(
type
);
}
};
TEST_P
(
Sobel
,
Mat
)
...
...
@@ -584,103 +251,29 @@ TEST_P(Sobel, Mat)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
random_roi
();
cv
::
Sobel
(
mat1_roi
,
dst_roi
,
-
1
,
dx
,
dy
,
ksize
,
/*scale*/
0.00001
,
/*delta*/
0
,
bordertype
);
cv
::
ocl
::
Sobel
(
gmat1
,
gdst
,
-
1
,
dx
,
dy
,
ksize
,
/*scale*/
0.00001
,
/*delta*/
0
,
bordertype
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1
,
sss
);
Near
(
1
);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// Scharr
PARAM_TEST_CASE
(
Scharr
,
MatType
,
int
,
int
,
int
)
struct
Scharr
:
FilterTestBase
{
int
type
;
int
dx
,
dy
,
bordertype
;
//src mat
cv
::
Mat
mat1
;
cv
::
Mat
dst
;
// set up roi
int
roicols
;
int
roirows
;
int
src1x
;
int
src1y
;
int
dstx
;
int
dsty
;
//src mat with roi
cv
::
Mat
mat1_roi
;
cv
::
Mat
dst_roi
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
//ocl mat with roi
cv
::
ocl
::
oclMat
gmat1
;
cv
::
ocl
::
oclMat
gdst
;
virtual
void
SetUp
()
{
type
=
GET_PARAM
(
0
);
dx
=
GET_PARAM
(
1
);
dy
=
GET_PARAM
(
2
);
Size
s
=
GET_PARAM
(
2
);
dx
=
s
.
width
;
dy
=
s
.
height
;
bordertype
=
GET_PARAM
(
3
);
dx
=
1
;
dy
=
0
;
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
Size
size
(
MWIDTH
,
MHEIGHT
);
mat1
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dst
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
Init
(
type
);
}
void
random_roi
()
{
#ifdef RANDOMROI
//randomize ROI
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
roicols
=
rng
.
uniform
(
2
,
mat1
.
cols
);
roirows
=
rng
.
uniform
(
2
,
mat1
.
rows
);
src1x
=
rng
.
uniform
(
0
,
mat1
.
cols
-
roicols
);
src1y
=
rng
.
uniform
(
0
,
mat1
.
rows
-
roirows
);
dstx
=
rng
.
uniform
(
0
,
dst
.
cols
-
roicols
);
dsty
=
rng
.
uniform
(
0
,
dst
.
rows
-
roirows
);
#else
roicols
=
mat1
.
cols
;
roirows
=
mat1
.
rows
;
src1x
=
0
;
src1y
=
0
;
dstx
=
0
;
dsty
=
0
;
#endif
mat1_roi
=
mat1
(
Rect
(
src1x
,
src1y
,
roicols
,
roirows
));
dst_roi
=
dst
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gdst_whole
=
dst
;
gdst
=
gdst_whole
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gmat1
=
mat1_roi
;
}
};
TEST_P
(
Scharr
,
Mat
)
...
...
@@ -688,16 +281,9 @@ TEST_P(Scharr, Mat)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
random_roi
();
cv
::
Scharr
(
mat1_roi
,
dst_roi
,
-
1
,
dx
,
dy
,
/*scale*/
1
,
/*delta*/
0
,
bordertype
);
cv
::
ocl
::
Scharr
(
gmat1
,
gdst
,
-
1
,
dx
,
dy
,
/*scale*/
1
,
/*delta*/
0
,
bordertype
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1
,
sss
);
Near
(
1
);
}
}
...
...
@@ -705,89 +291,23 @@ TEST_P(Scharr, Mat)
/////////////////////////////////////////////////////////////////////////////////////////////////
// GaussianBlur
PARAM_TEST_CASE
(
GaussianBlur
,
MatType
,
cv
::
Size
,
int
)
struct
GaussianBlur
:
FilterTestBase
{
int
type
;
cv
::
Size
ksize
;
int
bordertype
;
double
sigma1
,
sigma2
;
//src mat
cv
::
Mat
mat1
;
cv
::
Mat
dst
;
// set up roi
int
roicols
;
int
roirows
;
int
src1x
;
int
src1y
;
int
dstx
;
int
dsty
;
//src mat with roi
cv
::
Mat
mat1_roi
;
cv
::
Mat
dst_roi
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
//ocl mat with roi
cv
::
ocl
::
oclMat
gmat1
;
cv
::
ocl
::
oclMat
gdst
;
virtual
void
SetUp
()
{
type
=
GET_PARAM
(
0
);
ksize
=
GET_PARAM
(
1
);
bordertype
=
GET_PARAM
(
2
);
bordertype
=
GET_PARAM
(
3
);
Init
(
type
);
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
Size
size
(
MWIDTH
,
MHEIGHT
);
sigma1
=
rng
.
uniform
(
0.1
,
1.0
);
sigma2
=
rng
.
uniform
(
0.1
,
1.0
);
mat1
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dst
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
random_roi
()
{
#ifdef RANDOMROI
//randomize ROI
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
roicols
=
rng
.
uniform
(
2
,
mat1
.
cols
);
roirows
=
rng
.
uniform
(
2
,
mat1
.
rows
);
src1x
=
rng
.
uniform
(
0
,
mat1
.
cols
-
roicols
);
src1y
=
rng
.
uniform
(
0
,
mat1
.
rows
-
roirows
);
dstx
=
rng
.
uniform
(
0
,
dst
.
cols
-
roicols
);
dsty
=
rng
.
uniform
(
0
,
dst
.
rows
-
roirows
);
#else
roicols
=
mat1
.
cols
;
roirows
=
mat1
.
rows
;
src1x
=
0
;
src1y
=
0
;
dstx
=
0
;
dsty
=
0
;
#endif
mat1_roi
=
mat1
(
Rect
(
src1x
,
src1y
,
roicols
,
roirows
));
dst_roi
=
dst
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gdst_whole
=
dst
;
gdst
=
gdst_whole
(
Rect
(
dstx
,
dsty
,
roicols
,
roirows
));
gmat1
=
mat1_roi
;
}
};
TEST_P
(
GaussianBlur
,
Mat
)
...
...
@@ -795,53 +315,53 @@ TEST_P(GaussianBlur, Mat)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
random_roi
();
cv
::
GaussianBlur
(
mat1_roi
,
dst_roi
,
ksize
,
sigma1
,
sigma2
,
bordertype
);
cv
::
ocl
::
GaussianBlur
(
gmat1
,
gdst
,
ksize
,
sigma1
,
sigma2
,
bordertype
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1.0
,
sss
);
Near
(
1
);
}
}
INSTANTIATE_TEST_CASE_P
(
Filter
,
Blur
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC4
),
INSTANTIATE_TEST_CASE_P
(
Filter
,
Blur
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC4
),
Values
(
cv
::
Size
(
3
,
3
),
cv
::
Size
(
5
,
5
),
cv
::
Size
(
7
,
7
)),
Values
(
Size
(
0
,
0
)),
//not use
Values
((
MatType
)
cv
::
BORDER_CONSTANT
,
(
MatType
)
cv
::
BORDER_REPLICATE
,
(
MatType
)
cv
::
BORDER_REFLECT
,
(
MatType
)
cv
::
BORDER_REFLECT_101
)));
INSTANTIATE_TEST_CASE_P
(
Filters
,
Laplacian
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
1
,
3
)));
INSTANTIATE_TEST_CASE_P
(
Filter
,
Erode
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC4
,
CV_32FC1
,
CV_32FC4
),
Values
(
1
)));
//INSTANTIATE_TEST_CASE_P(Filter, Erode, Combine(Values(CV_8UC1, CV_8UC1), Values(false)));
INSTANTIATE_TEST_CASE_P
(
Filter
,
Dilate
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC4
,
CV_32FC1
,
CV_32FC4
),
Values
(
1
)));
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
Size
(
3
,
3
)),
Values
(
Size
(
0
,
0
)),
//not use
Values
(
0
)));
//not use
//INSTANTIATE_TEST_CASE_P(Filter, Dilate, Combine(Values(CV_8UC1, CV_8UC1), Values(false)));
INSTANTIATE_TEST_CASE_P
(
Filter
,
ErodeDilate
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC4
,
CV_32FC1
,
CV_32FC4
),
Values
(
Size
(
0
,
0
)),
//not use
Values
(
Size
(
0
,
0
)),
//not use
Values
(
1
)));
INSTANTIATE_TEST_CASE_P
(
Filter
,
Sobel
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
1
,
2
),
Values
(
0
,
1
),
Values
(
3
,
5
),
Values
((
MatType
)
cv
::
BORDER_CONSTANT
,
(
MatType
)
cv
::
BORDER_REPLICATE
)));
INSTANTIATE_TEST_CASE_P
(
Filter
,
Sobel
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC3
,
CV_32FC4
),
Values
(
Size
(
3
,
3
),
Size
(
5
,
5
)),
Values
(
Size
(
1
,
0
),
Size
(
1
,
1
),
Size
(
2
,
0
),
Size
(
2
,
1
)),
Values
((
MatType
)
cv
::
BORDER_CONSTANT
,
(
MatType
)
cv
::
BORDER_REPLICATE
)));
INSTANTIATE_TEST_CASE_P
(
Filter
,
Scharr
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC4
),
Values
(
0
,
1
),
Values
(
0
,
1
),
Values
((
MatType
)
cv
::
BORDER_CONSTANT
,
(
MatType
)
cv
::
BORDER_REPLICATE
)));
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC4
),
Values
(
Size
(
0
,
0
)),
//not use
Values
(
Size
(
0
,
1
),
Size
(
1
,
0
)),
Values
((
MatType
)
cv
::
BORDER_CONSTANT
,
(
MatType
)
cv
::
BORDER_REPLICATE
)));
INSTANTIATE_TEST_CASE_P
(
Filter
,
GaussianBlur
,
Combine
(
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC4
),
Values
(
cv
::
Size
(
3
,
3
),
cv
::
Size
(
5
,
5
)),
Values
((
MatType
)
cv
::
BORDER_CONSTANT
,
(
MatType
)
cv
::
BORDER_REPLICATE
)));
Values
(
CV_8UC1
,
CV_8UC3
,
CV_8UC4
,
CV_32FC1
,
CV_32FC4
),
Values
(
Size
(
3
,
3
),
Size
(
5
,
5
)),
Values
(
Size
(
0
,
0
)),
//not use
Values
((
MatType
)
cv
::
BORDER_CONSTANT
,
(
MatType
)
cv
::
BORDER_REPLICATE
)));
...
...
modules/ocl/test/test_gemm.cpp
View file @
6eb5a95a
...
...
@@ -53,13 +53,12 @@ PARAM_TEST_CASE(Gemm, int, cv::Size, int)
int
type
;
cv
::
Size
mat_size
;
int
flags
;
//vector<cv::ocl::Info> info;
virtual
void
SetUp
()
{
type
=
GET_PARAM
(
0
);
mat_size
=
GET_PARAM
(
1
);
flags
=
GET_PARAM
(
2
);
//cv::ocl::getDevice(info);
}
};
...
...
modules/ocl/test/test_haar.cpp
View file @
6eb5a95a
...
...
@@ -12,6 +12,7 @@
//
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
...
...
modules/ocl/test/test_hog.cpp
View file @
6eb5a95a
...
...
@@ -240,12 +240,11 @@ TEST_P(HOG, Detect)
}
}
char
s
[
100
]
=
{
0
};
EXPECT_MAT_NEAR
(
cv
::
Mat
(
d_comp
),
cv
::
Mat
(
comp
),
3
,
s
);
EXPECT_MAT_NEAR
(
cv
::
Mat
(
d_comp
),
cv
::
Mat
(
comp
),
3
);
}
INSTANTIATE_TEST_CASE_P
(
GPU_ImgProc
,
HOG
,
testing
::
Combine
(
INSTANTIATE_TEST_CASE_P
(
OCL_ObjDetect
,
HOG
,
testing
::
Combine
(
testing
::
Values
(
cv
::
Size
(
64
,
128
),
cv
::
Size
(
48
,
96
)),
testing
::
Values
(
MatType
(
CV_8UC1
),
MatType
(
CV_8UC4
))));
...
...
modules/ocl/test/test_imgproc.cpp
View file @
6eb5a95a
...
...
@@ -12,6 +12,7 @@
//
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
...
...
@@ -327,7 +328,7 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType, MatType, MatType, MatType, MatType, bo
cv
::
Mat
mask_roi
;
cv
::
Mat
dst_roi
;
cv
::
Mat
dst1_roi
;
//bak
//std::vector<cv::ocl::Info> oclinfo;
//ocl mat
cv
::
ocl
::
oclMat
clmat1
;
cv
::
ocl
::
oclMat
clmat2
;
...
...
@@ -352,10 +353,6 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType, MatType, MatType, MatType, MatType, bo
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
Size
size
(
MWIDTH
,
MHEIGHT
);
double
min
=
1
,
max
=
20
;
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
if
(
type1
!=
nulltype
)
{
...
...
@@ -445,6 +442,13 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType, MatType, MatType, MatType, MatType, bo
clmask_roi
=
clmask
(
Rect
(
maskx
,
masky
,
roicols
,
roirows
));
}
}
void
Near
(
double
threshold
)
{
cv
::
Mat
cpu_cldst
;
cldst
.
download
(
cpu_cldst
);
EXPECT_MAT_NEAR
(
dst
,
cpu_cldst
,
threshold
);
}
};
////////////////////////////////equalizeHist//////////////////////////////////////////
...
...
@@ -464,11 +468,7 @@ TEST_P(equalizeHist, Mat)
random_roi
();
cv
::
equalizeHist
(
mat1_roi
,
dst_roi
);
cv
::
ocl
::
equalizeHist
(
clmat1_roi
,
cldst_roi
);
cv
::
Mat
cpu_cldst
;
cldst
.
download
(
cpu_cldst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,dst1x=%d,dst1y=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
dst1x
,
dst1y
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_cldst
,
1.1
,
sss
);
Near
(
1.1
);
}
}
}
...
...
@@ -488,7 +488,7 @@ TEST_P(bilateralFilter, Mat)
int
d
=
2
*
radius
+
1
;
double
sigmaspace
=
20.0
;
int
bordertype
[]
=
{
cv
::
BORDER_CONSTANT
,
cv
::
BORDER_REPLICATE
,
cv
::
BORDER_REFLECT
,
cv
::
BORDER_WRAP
,
cv
::
BORDER_REFLECT_101
};
const
char
*
borderstr
[]
=
{
"BORDER_CONSTANT"
,
"BORDER_REPLICATE"
,
"BORDER_REFLECT"
,
"BORDER_WRAP"
,
"BORDER_REFLECT_101"
};
//
const char *borderstr[] = {"BORDER_CONSTANT", "BORDER_REPLICATE", "BORDER_REFLECT", "BORDER_WRAP", "BORDER_REFLECT_101"};
if
(
mat1
.
depth
()
!=
CV_8U
||
mat1
.
type
()
!=
dst
.
type
())
{
...
...
@@ -517,25 +517,7 @@ TEST_P(bilateralFilter, Mat)
cv
::
bilateralFilter
(
mat1_roi
,
dst_roi
,
d
,
sigmacolor
,
sigmaspace
,
bordertype
[
i
]
|
cv
::
BORDER_ISOLATED
);
cv
::
ocl
::
bilateralFilter
(
clmat1_roi
,
cldst_roi
,
d
,
sigmacolor
,
sigmaspace
,
bordertype
[
i
]
|
cv
::
BORDER_ISOLATED
);
cv
::
Mat
cpu_cldst
;
cldst
.
download
(
cpu_cldst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,radius=%d,boredertype=%s"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
radius
,
borderstr
[
i
]);
//for(int i=0;i<dst.rows;i++)
//{
// for(int j=0;j<dst.cols*dst.channels();j++)
// {
// if(dst.at<uchar>(i,j)!=cpu_cldst.at<uchar>(i,j))
// cout<< i <<" "<< j <<" "<< (int)dst.at<uchar>(i,j)<<" "<< (int)cpu_cldst.at<uchar>(i,j)<<" ";
// }
// cout<<endl;
//}
EXPECT_MAT_NEAR
(
dst
,
cpu_cldst
,
1.0
,
sss
);
Near
(
1.
);
}
}
}
...
...
@@ -549,7 +531,7 @@ struct CopyMakeBorder : ImgprocTestBase {};
TEST_P
(
CopyMakeBorder
,
Mat
)
{
int
bordertype
[]
=
{
cv
::
BORDER_CONSTANT
,
cv
::
BORDER_REPLICATE
,
cv
::
BORDER_REFLECT
,
cv
::
BORDER_WRAP
,
cv
::
BORDER_REFLECT_101
};
const
char
*
borderstr
[]
=
{
"BORDER_CONSTANT"
,
"BORDER_REPLICATE"
,
"BORDER_REFLECT"
,
"BORDER_WRAP"
,
"BORDER_REFLECT_101"
};
//
const char *borderstr[] = {"BORDER_CONSTANT", "BORDER_REPLICATE", "BORDER_REFLECT", "BORDER_WRAP", "BORDER_REFLECT_101"};
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
int
top
=
rng
.
uniform
(
0
,
10
);
int
bottom
=
rng
.
uniform
(
0
,
10
);
...
...
@@ -587,24 +569,12 @@ TEST_P(CopyMakeBorder, Mat)
cv
::
Mat
cpu_cldst
;
#ifndef RANDOMROI
cldst_roi
.
download
(
cpu_cldst
);
EXPECT_MAT_NEAR
(
dst_roi
,
cpu_cldst
,
0.0
);
#else
cldst
.
download
(
cpu_cldst
);
EXPECT_MAT_NEAR
(
dst
,
cpu_cldst
,
0.0
);
#endif
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,dst1x=%d,dst1y=%d,top=%d,bottom=%d,left=%d,right=%d, bordertype=%s"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
dst1x
,
dst1y
,
top
,
bottom
,
left
,
right
,
borderstr
[
i
]);
#ifndef RANDOMROI
EXPECT_MAT_NEAR
(
dst_roi
,
cpu_cldst
,
0.0
,
sss
);
#else
//for(int i=0;i<dst.rows;i++)
//{
//for(int j=0;j<dst.cols;j++)
//{
// cout<< (int)dst.at<uchar>(i,j)<<" ";
//}
//cout<<endl;
//}
EXPECT_MAT_NEAR
(
dst
,
cpu_cldst
,
0.0
,
sss
);
#endif
}
}
}
...
...
@@ -627,14 +597,7 @@ TEST_P(cornerMinEigenVal, Mat)
int
borderType
=
cv
::
BORDER_REFLECT
;
cv
::
cornerMinEigenVal
(
mat1_roi
,
dst_roi
,
blockSize
,
apertureSize
,
borderType
);
cv
::
ocl
::
cornerMinEigenVal
(
clmat1_roi
,
cldst_roi
,
blockSize
,
apertureSize
,
borderType
);
cv
::
Mat
cpu_cldst
;
cldst
.
download
(
cpu_cldst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,dst1x=%d,dst1y=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
dst1x
,
dst1y
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_cldst
,
1
,
sss
);
Near
(
1.
);
}
}
...
...
@@ -657,13 +620,7 @@ TEST_P(cornerHarris, Mat)
int
borderType
=
cv
::
BORDER_REFLECT
;
cv
::
cornerHarris
(
mat1_roi
,
dst_roi
,
blockSize
,
apertureSize
,
k
,
borderType
);
cv
::
ocl
::
cornerHarris
(
clmat1_roi
,
cldst_roi
,
blockSize
,
apertureSize
,
k
,
borderType
);
cv
::
Mat
cpu_cldst
;
cldst
.
download
(
cpu_cldst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,dst1x=%d,dst1y=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
dst1x
,
dst1y
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_cldst
,
1
,
sss
);
Near
(
1.
);
}
}
...
...
@@ -680,15 +637,11 @@ TEST_P(integral, Mat)
cv
::
ocl
::
integral
(
clmat1_roi
,
cldst_roi
,
cldst1_roi
);
cv
::
integral
(
mat1_roi
,
dst_roi
,
dst1_roi
);
Near
(
0
);
cv
::
Mat
cpu_cldst
,
cpu_cldst1
;
cldst
.
download
(
cpu_cldst
);
cv
::
Mat
cpu_cldst1
;
cldst1
.
download
(
cpu_cldst1
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,dst1x=%d,dst1y=%d,maskx=%d,masky=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
dst1x
,
dst1y
,
maskx
,
masky
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_cldst
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
dst1
,
cpu_cldst1
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
dst1
,
cpu_cldst1
,
0.0
);
}
}
...
...
@@ -720,7 +673,7 @@ PARAM_TEST_CASE(WarpTestBase, MatType, int)
//src mat with roi
cv
::
Mat
mat1_roi
;
cv
::
Mat
dst_roi
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
...
...
@@ -740,10 +693,6 @@ PARAM_TEST_CASE(WarpTestBase, MatType, int)
mat1
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dst
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
random_roi
()
...
...
@@ -805,10 +754,7 @@ TEST_P(WarpAffine, Mat)
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"src_roicols=%d,src_roirows=%d,dst_roicols=%d,dst_roirows=%d,src1x =%d,src1y=%d,dstx=%d,dsty=%d"
,
src_roicols
,
src_roirows
,
dst_roicols
,
dst_roirows
,
src1x
,
src1y
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1.0
,
sss
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1.0
);
}
}
...
...
@@ -837,10 +783,7 @@ TEST_P(WarpPerspective, Mat)
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"src_roicols=%d,src_roirows=%d,dst_roicols=%d,dst_roirows=%d,src1x =%d,src1y=%d,dstx=%d,dsty=%d"
,
src_roicols
,
src_roirows
,
dst_roicols
,
dst_roirows
,
src1x
,
src1y
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1.0
,
sss
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1.0
);
}
}
...
...
@@ -905,9 +848,6 @@ PARAM_TEST_CASE(Remap, MatType, MatType, MatType, int, int)
interpolation
=
GET_PARAM
(
3
);
bordertype
=
GET_PARAM
(
4
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
cv
::
RNG
&
rng
=
TS
::
ptr
()
->
get_rng
();
cv
::
Size
srcSize
=
cv
::
Size
(
MWIDTH
,
MHEIGHT
);
cv
::
Size
map1Size
=
cv
::
Size
(
MWIDTH
,
MHEIGHT
);
...
...
@@ -1004,7 +944,7 @@ TEST_P(Remap, Mat)
return
;
}
int
bordertype
[]
=
{
cv
::
BORDER_CONSTANT
,
cv
::
BORDER_REPLICATE
/*,BORDER_REFLECT,BORDER_WRAP,BORDER_REFLECT_101*/
};
const
char
*
borderstr
[]
=
{
"BORDER_CONSTANT"
,
"BORDER_REPLICATE"
/*, "BORDER_REFLECT","BORDER_WRAP","BORDER_REFLECT_101"*/
};
//
const char *borderstr[] = {"BORDER_CONSTANT", "BORDER_REPLICATE"/*, "BORDER_REFLECT","BORDER_WRAP","BORDER_REFLECT_101"*/};
// for(int i = 0; i < sizeof(bordertype)/sizeof(int); i++)
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
...
...
@@ -1014,13 +954,9 @@ TEST_P(Remap, Mat)
cv
::
Mat
cpu_dst
;
gdst
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"src_roicols=%d,src_roirows=%d,dst_roicols=%d,dst_roirows=%d,src1x =%d,src1y=%d,dstx=%d,dsty=%d bordertype=%s"
,
src_roicols
,
src_roirows
,
dst_roicols
,
dst_roirows
,
srcx
,
srcy
,
dstx
,
dsty
,
borderstr
[
0
]);
if
(
interpolation
==
0
)
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1.0
,
sss
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
2.0
,
sss
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1.0
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
2.0
);
}
}
...
...
@@ -1051,7 +987,6 @@ PARAM_TEST_CASE(Resize, MatType, cv::Size, double, double, int)
int
dstx
;
int
dsty
;
//std::vector<cv::ocl::Info> oclinfo;
//src mat with roi
cv
::
Mat
mat1_roi
;
cv
::
Mat
dst_roi
;
...
...
@@ -1090,10 +1025,6 @@ PARAM_TEST_CASE(Resize, MatType, cv::Size, double, double, int)
mat1
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dst
=
randomMat
(
rng
,
dsize
,
type
,
5
,
16
,
false
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
random_roi
()
...
...
@@ -1149,10 +1080,7 @@ TEST_P(Resize, Mat)
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"src_roicols=%d,src_roirows=%d,dst_roicols=%d,dst_roirows=%d,src1x =%d,src1y=%d,dstx=%d,dsty=%d"
,
src_roicols
,
src_roirows
,
dst_roicols
,
dst_roirows
,
src1x
,
src1y
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1.0
,
sss
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1.0
);
}
}
...
...
@@ -1181,7 +1109,7 @@ PARAM_TEST_CASE(Threshold, MatType, ThreshOp)
//src mat with roi
cv
::
Mat
mat1_roi
;
cv
::
Mat
dst_roi
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
...
...
@@ -1199,11 +1127,6 @@ PARAM_TEST_CASE(Threshold, MatType, ThreshOp)
mat1
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dst
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
random_roi
()
...
...
@@ -1251,12 +1174,7 @@ TEST_P(Threshold, Mat)
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
//EXPECT_MAT_NEAR(dst, cpu_dst, 1e-5)
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x =%d,src1y=%d,dstx=%d,dsty=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1
,
sss
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1
);
}
}
...
...
@@ -1288,7 +1206,6 @@ PARAM_TEST_CASE(meanShiftTestBase, MatType, MatType, int, int, cv::TermCriteria)
cv
::
ocl
::
oclMat
gdst
;
cv
::
ocl
::
oclMat
gdstCoor
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl mat with roi
cv
::
ocl
::
oclMat
gsrc_roi
;
cv
::
ocl
::
oclMat
gdst_roi
;
...
...
@@ -1311,10 +1228,6 @@ PARAM_TEST_CASE(meanShiftTestBase, MatType, MatType, int, int, cv::TermCriteria)
dst
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dstCoor
=
randomMat
(
rng
,
size
,
typeCoor
,
5
,
16
,
false
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
random_roi
()
...
...
@@ -1367,11 +1280,7 @@ TEST_P(meanShiftFiltering, Mat)
cv
::
ocl
::
meanShiftFiltering
(
gsrc_roi
,
gdst_roi
,
sp
,
sr
,
crit
);
gdst
.
download
(
cpu_gdst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,srcx=%d,srcy=%d,dstx=%d,dsty=%d
\n
"
,
roicols
,
roirows
,
srcx
,
srcy
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_gdst
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
dst
,
cpu_gdst
,
0.0
);
}
}
...
...
@@ -1393,11 +1302,8 @@ TEST_P(meanShiftProc, Mat)
gdst
.
download
(
cpu_gdst
);
gdstCoor
.
download
(
cpu_gdstCoor
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,srcx=%d,srcy=%d,dstx=%d,dsty=%d
\n
"
,
roicols
,
roirows
,
srcx
,
srcy
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_gdst
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
dstCoor
,
cpu_gdstCoor
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
dst
,
cpu_gdst
,
0.0
);
EXPECT_MAT_NEAR
(
dstCoor
,
cpu_gdstCoor
,
0.0
);
}
}
...
...
@@ -1436,7 +1342,6 @@ PARAM_TEST_CASE(histTestBase, MatType, MatType)
cv
::
ocl
::
oclMat
gdst_hist
;
//ocl mat with roi
cv
::
ocl
::
oclMat
gsrc_roi
;
// std::vector<cv::ocl::Info> oclinfo;
virtual
void
SetUp
()
{
...
...
@@ -1447,10 +1352,6 @@ PARAM_TEST_CASE(histTestBase, MatType, MatType)
src
=
randomMat
(
rng
,
size
,
type_src
,
0
,
256
,
false
);
// int devnums = getDevice(oclinfo);
// CV_Assert(devnums > 0);
//if you want to use undefault device, set it here
//setDevice(oclinfo[0]);
}
void
random_roi
()
...
...
@@ -1489,10 +1390,7 @@ TEST_P(calcHist, Mat)
cv
::
ocl
::
calcHist
(
gsrc_roi
,
gdst_hist
);
gdst_hist
.
download
(
cpu_hist
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,srcx=%d,srcy=%d
\n
"
,
roicols
,
roirows
,
srcx
,
srcy
);
EXPECT_MAT_NEAR
(
dst_hist
,
cpu_hist
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
dst_hist
,
cpu_hist
,
0.0
);
}
}
...
...
@@ -1629,11 +1527,7 @@ TEST_P(Convolve, Mat)
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x=%d,src1y=%d,dstx=%d,dsty=%d,src2x=%d,src2y=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
dstx
,
dsty
,
src2x
,
src2y
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
1e-1
,
sss
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
.1
);
}
}
...
...
modules/ocl/test/test_match_template.cpp
View file @
6eb5a95a
...
...
@@ -62,7 +62,6 @@ PARAM_TEST_CASE(MatchTemplate8U, cv::Size, TemplateSize, Channels, TemplateMetho
cv
::
Size
templ_size
;
int
cn
;
int
method
;
//std::vector<cv::ocl::Info> oclinfo;
virtual
void
SetUp
()
{
...
...
@@ -70,8 +69,6 @@ PARAM_TEST_CASE(MatchTemplate8U, cv::Size, TemplateSize, Channels, TemplateMetho
templ_size
=
GET_PARAM
(
1
);
cn
=
GET_PARAM
(
2
);
method
=
GET_PARAM
(
3
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
}
};
...
...
@@ -92,12 +89,10 @@ TEST_P(MatchTemplate8U, Accuracy)
cv
::
Mat
dst_gold
;
cv
::
matchTemplate
(
image
,
templ
,
dst_gold
,
method
);
char
sss
[
100
]
=
""
;
cv
::
Mat
mat_dst
;
dst
.
download
(
mat_dst
);
EXPECT_MAT_NEAR
(
dst_gold
,
mat_dst
,
templ_size
.
area
()
*
1e-1
,
sss
);
EXPECT_MAT_NEAR
(
dst_gold
,
mat_dst
,
templ_size
.
area
()
*
1e-1
);
}
PARAM_TEST_CASE
(
MatchTemplate32F
,
cv
::
Size
,
TemplateSize
,
Channels
,
TemplateMethod
)
...
...
@@ -114,8 +109,6 @@ PARAM_TEST_CASE(MatchTemplate32F, cv::Size, TemplateSize, Channels, TemplateMeth
templ_size
=
GET_PARAM
(
1
);
cn
=
GET_PARAM
(
2
);
method
=
GET_PARAM
(
3
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
}
};
...
...
@@ -130,12 +123,10 @@ TEST_P(MatchTemplate32F, Accuracy)
cv
::
Mat
dst_gold
;
cv
::
matchTemplate
(
image
,
templ
,
dst_gold
,
method
);
char
sss
[
100
]
=
""
;
cv
::
Mat
mat_dst
;
dst
.
download
(
mat_dst
);
EXPECT_MAT_NEAR
(
dst_gold
,
mat_dst
,
templ_size
.
area
()
*
1e-1
,
sss
);
EXPECT_MAT_NEAR
(
dst_gold
,
mat_dst
,
templ_size
.
area
()
*
1e-1
);
}
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
MatchTemplate8U
,
...
...
modules/ocl/test/test_matrix_operation.cpp
View file @
6eb5a95a
...
...
@@ -12,6 +12,7 @@
//
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
...
...
@@ -72,7 +73,7 @@ PARAM_TEST_CASE(ConvertToTestBase, MatType, MatType)
//src mat with roi
cv
::
Mat
mat_roi
;
cv
::
Mat
dst_roi
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
...
...
@@ -90,11 +91,6 @@ PARAM_TEST_CASE(ConvertToTestBase, MatType, MatType)
mat
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
dst
=
randomMat
(
rng
,
size
,
type
,
5
,
16
,
false
);
//std::vector<cv::ocl::Info> oclinfo;
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
random_roi
()
...
...
@@ -139,12 +135,7 @@ TEST_P(ConvertTo, Accuracy)
mat_roi
.
convertTo
(
dst_roi
,
dst_type
);
gmat
.
convertTo
(
gdst
,
dst_type
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,srcx =%d,srcy=%d,dstx=%d,dsty=%d"
,
roicols
,
roirows
,
srcx
,
srcy
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
dst
,
Mat
(
gdst_whole
),
0.0
);
}
}
...
...
@@ -175,7 +166,7 @@ PARAM_TEST_CASE(CopyToTestBase, MatType, bool)
cv
::
Mat
mat_roi
;
cv
::
Mat
mask_roi
;
cv
::
Mat
dst_roi
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
...
...
@@ -197,10 +188,6 @@ PARAM_TEST_CASE(CopyToTestBase, MatType, bool)
cv
::
threshold
(
mask
,
mask
,
0.5
,
255.
,
CV_8UC1
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
random_roi
()
...
...
@@ -250,12 +237,7 @@ TEST_P(CopyTo, Without_mask)
mat_roi
.
copyTo
(
dst_roi
);
gmat
.
copyTo
(
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,srcx =%d,srcy=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d"
,
roicols
,
roirows
,
srcx
,
srcy
,
dstx
,
dsty
,
maskx
,
masky
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
dst
,
Mat
(
gdst_whole
),
0.0
);
}
}
...
...
@@ -268,12 +250,7 @@ TEST_P(CopyTo, With_mask)
mat_roi
.
copyTo
(
dst_roi
,
mask_roi
);
gmat
.
copyTo
(
gdst
,
gmask
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,srcx =%d,srcy=%d,dstx=%d,dsty=%d,maskx=%d,masky=%d"
,
roicols
,
roirows
,
srcx
,
srcy
,
dstx
,
dsty
,
maskx
,
masky
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
dst
,
Mat
(
gdst_whole
),
0.0
);
}
}
...
...
@@ -301,7 +278,7 @@ PARAM_TEST_CASE(SetToTestBase, MatType, bool)
//src mat with roi
cv
::
Mat
mat_roi
;
cv
::
Mat
mask_roi
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gmat_whole
;
...
...
@@ -322,10 +299,6 @@ PARAM_TEST_CASE(SetToTestBase, MatType, bool)
cv
::
threshold
(
mask
,
mask
,
0.5
,
255.
,
CV_8UC1
);
val
=
cv
::
Scalar
(
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
),
rng
.
uniform
(
-
10.0
,
10.0
));
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
random_roi
()
...
...
@@ -369,12 +342,7 @@ TEST_P(SetTo, Without_mask)
mat_roi
.
setTo
(
val
);
gmat
.
setTo
(
val
);
cv
::
Mat
cpu_dst
;
gmat_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,srcx =%d,srcy=%d,maskx=%d,masky=%d"
,
roicols
,
roirows
,
srcx
,
srcy
,
maskx
,
masky
);
EXPECT_MAT_NEAR
(
mat
,
cpu_dst
,
1.
,
sss
);
EXPECT_MAT_NEAR
(
mat
,
Mat
(
gmat_whole
),
1.
);
}
}
...
...
@@ -387,12 +355,7 @@ TEST_P(SetTo, With_mask)
mat_roi
.
setTo
(
val
,
mask_roi
);
gmat
.
setTo
(
val
,
gmask
);
cv
::
Mat
cpu_dst
;
gmat_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,srcx =%d,srcy=%d,maskx=%d,masky=%d"
,
roicols
,
roirows
,
srcx
,
srcy
,
maskx
,
masky
);
EXPECT_MAT_NEAR
(
mat
,
cpu_dst
,
1.
,
sss
);
EXPECT_MAT_NEAR
(
mat
,
Mat
(
gmat_whole
),
1.
);
}
}
...
...
@@ -417,7 +380,7 @@ PARAM_TEST_CASE(convertC3C4, MatType, cv::Size)
//src mat with roi
cv
::
Mat
mat1_roi
;
cv
::
Mat
dst_roi
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
...
...
@@ -430,13 +393,6 @@ PARAM_TEST_CASE(convertC3C4, MatType, cv::Size)
type
=
GET_PARAM
(
0
);
ksize
=
GET_PARAM
(
1
);
//dst = randomMat(rng, size, type, 5, 16, false);
//int devnums = getDevice(oclinfo);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[1]);
}
void
random_roi
()
...
...
@@ -483,11 +439,8 @@ TEST_P(convertC3C4, Accuracy)
mat1
=
randomMat
(
rng
,
size
,
type
,
0
,
40
,
false
);
gmat1
=
mat1
;
cv
::
Mat
cpu_dst
;
gmat1
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"cols=%d,rows=%d"
,
mat1
.
cols
,
mat1
.
rows
);
EXPECT_MAT_NEAR
(
mat1
,
cpu_dst
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
mat1
,
Mat
(
gmat1
),
0.0
);
}
}
...
...
modules/ocl/test/test_moments.cpp
View file @
6eb5a95a
...
...
@@ -10,7 +10,7 @@ using namespace cvtest;
using
namespace
testing
;
using
namespace
std
;
extern
string
workdir
;
PARAM_TEST_CASE
(
MomentsTest
Base
,
MatType
,
bool
)
PARAM_TEST_CASE
(
MomentsTest
,
MatType
,
bool
)
{
int
type
;
cv
::
Mat
mat1
;
...
...
@@ -30,13 +30,13 @@ PARAM_TEST_CASE(MomentsTestBase, MatType, bool)
Mat
gpu_dst
,
cpu_dst
;
HuMoments
(
cpu
,
cpu_dst
);
HuMoments
(
gpu
,
gpu_dst
);
EXPECT_MAT_NEAR
(
gpu_dst
,
cpu_dst
,
.5
,
""
);
EXPECT_MAT_NEAR
(
gpu_dst
,
cpu_dst
,
.5
);
}
};
struct
ocl_Moments
:
MomentsTestBase
{};
TEST_P
(
ocl_Moments
,
Mat
)
TEST_P
(
MomentsTest
,
Mat
)
{
bool
binaryImage
=
0
;
SetUp
();
...
...
@@ -67,6 +67,6 @@ TEST_P(ocl_Moments, Mat)
}
}
INSTANTIATE_TEST_CASE_P
(
Moments
,
ocl_Moments
,
Combine
(
INSTANTIATE_TEST_CASE_P
(
OCL_ImgProc
,
MomentsTest
,
Combine
(
Values
(
CV_8UC1
,
CV_16UC1
,
CV_16SC1
,
CV_64FC1
),
Values
(
true
,
false
)));
#endif // HAVE_OPENCL
modules/ocl/test/test_pyrdown.cpp
View file @
6eb5a95a
...
...
@@ -65,15 +65,6 @@ PARAM_TEST_CASE(PyrDown, MatType, int)
{
type
=
GET_PARAM
(
0
);
channels
=
GET_PARAM
(
1
);
//int devnums = getDevice(oclinfo);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
Cleanup
()
{
}
};
...
...
@@ -92,17 +83,11 @@ TEST_P(PyrDown, Mat)
cv
::
pyrDown
(
src
,
dst_cpu
);
cv
::
ocl
::
pyrDown
(
gsrc
,
gdst
);
cv
::
Mat
dst
;
gdst
.
download
(
dst
);
char
s
[
1024
]
=
{
0
};
EXPECT_MAT_NEAR
(
dst
,
dst_cpu
,
dst
.
depth
()
==
CV_32F
?
1e-4
f
:
1.0
f
,
s
);
Cleanup
();
EXPECT_MAT_NEAR
(
dst_cpu
,
Mat
(
gdst
),
type
==
CV_32F
?
1e-4
f
:
1.0
f
);
}
}
INSTANTIATE_TEST_CASE_P
(
GPU
_ImgProc
,
PyrDown
,
Combine
(
INSTANTIATE_TEST_CASE_P
(
OCL
_ImgProc
,
PyrDown
,
Combine
(
Values
(
CV_8U
,
CV_32F
),
Values
(
1
,
3
,
4
)));
...
...
modules/ocl/test/test_pyrlk.cpp
View file @
6eb5a95a
...
...
@@ -50,19 +50,7 @@ using namespace cvtest;
using
namespace
testing
;
using
namespace
std
;
//#define DUMP
/////////////////////////////////////////////////////////////////////////////////////////////////
// BroxOpticalFlow
extern
string
workdir
;
#define BROX_OPTICAL_FLOW_DUMP_FILE "opticalflow/brox_optical_flow.bin"
#define BROX_OPTICAL_FLOW_DUMP_FILE_CC20 "opticalflow/brox_optical_flow_cc20.bin"
/////////////////////////////////////////////////////////////////////////////////////////////////
// PyrLKOpticalFlow
//IMPLEMENT_PARAM_CLASS(UseGray, bool)
PARAM_TEST_CASE
(
Sparse
,
bool
,
bool
)
{
...
...
modules/ocl/test/test_pyrup.cpp
View file @
6eb5a95a
...
...
@@ -58,12 +58,9 @@ PARAM_TEST_CASE(PyrUp, MatType, int)
{
int
type
;
int
channels
;
//std::vector<cv::ocl::Info> oclinfo;
virtual
void
SetUp
()
{
//int devnums = cv::ocl::getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
type
=
GET_PARAM
(
0
);
channels
=
GET_PARAM
(
1
);
}
...
...
@@ -80,17 +77,14 @@ TEST_P(PyrUp, Accuracy)
ocl
::
oclMat
dst
;
ocl
::
oclMat
srcMat
(
src
);
ocl
::
pyrUp
(
srcMat
,
dst
);
Mat
cpu_dst
;
dst
.
download
(
cpu_dst
);
char
s
[
100
]
=
{
0
};
EXPECT_MAT_NEAR
(
dst_gold
,
cpu_dst
,
(
src
.
depth
()
==
CV_32F
?
1e-4
f
:
1.0
),
s
);
EXPECT_MAT_NEAR
(
dst_gold
,
Mat
(
dst
),
(
type
==
CV_32F
?
1e-4
f
:
1.0
)
);
}
}
INSTANTIATE_TEST_CASE_P
(
GPU
_ImgProc
,
PyrUp
,
testing
::
Combine
(
INSTANTIATE_TEST_CASE_P
(
OCL
_ImgProc
,
PyrUp
,
testing
::
Combine
(
Values
(
CV_8U
,
CV_32F
),
Values
(
1
,
3
,
4
)));
...
...
modules/ocl/test/test_split_merge.cpp
View file @
6eb5a95a
...
...
@@ -12,6 +12,7 @@
//
// Copyright (C) 2010-2012, Institute Of Software Chinese Academy Of Science, all rights reserved.
// Copyright (C) 2010-2012, Advanced Micro Devices, Inc., all rights reserved.
// Copyright (C) 2010-2012, Multicoreware, Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// @Authors
...
...
@@ -87,7 +88,7 @@ PARAM_TEST_CASE(MergeTestBase, MatType, int)
//dst mat with roi
cv
::
Mat
dst_roi
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst_whole
;
...
...
@@ -112,10 +113,6 @@ PARAM_TEST_CASE(MergeTestBase, MatType, int)
mat4
=
randomMat
(
rng
,
size
,
CV_MAKETYPE
(
type
,
1
),
5
,
16
,
false
);
dst
=
randomMat
(
rng
,
size
,
CV_MAKETYPE
(
type
,
channels
),
5
,
16
,
false
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
random_roi
()
...
...
@@ -205,12 +202,7 @@ TEST_P(Merge, Accuracy)
cv
::
merge
(
dev_src
,
dst_roi
);
cv
::
ocl
::
merge
(
dev_gsrc
,
gdst
);
cv
::
Mat
cpu_dst
;
gdst_whole
.
download
(
cpu_dst
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,src1x =%d,src1y=%d,src2x =%d,src2y=%d,src3x =%d,src3y=%d,src4x =%d,src4y=%d,dstx=%d,dsty=%d"
,
roicols
,
roirows
,
src1x
,
src1y
,
src2x
,
src2y
,
src3x
,
src3y
,
src4x
,
src4y
,
dstx
,
dsty
);
EXPECT_MAT_NEAR
(
dst
,
cpu_dst
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
dst
,
Mat
(
gdst_whole
),
0.0
);
}
}
...
...
@@ -252,7 +244,7 @@ PARAM_TEST_CASE(SplitTestBase, MatType, int)
cv
::
Mat
dst2_roi
;
cv
::
Mat
dst3_roi
;
cv
::
Mat
dst4_roi
;
//std::vector<cv::ocl::Info> oclinfo;
//ocl dst mat for testing
cv
::
ocl
::
oclMat
gdst1_whole
;
cv
::
ocl
::
oclMat
gdst2_whole
;
...
...
@@ -280,10 +272,6 @@ PARAM_TEST_CASE(SplitTestBase, MatType, int)
dst3
=
randomMat
(
rng
,
size
,
CV_MAKETYPE
(
type
,
1
),
5
,
16
,
false
);
dst4
=
randomMat
(
rng
,
size
,
CV_MAKETYPE
(
type
,
1
),
5
,
16
,
false
);
//int devnums = getDevice(oclinfo, OPENCV_DEFAULT_OPENCL_DEVICE);
//CV_Assert(devnums > 0);
////if you want to use undefault device, set it here
////setDevice(oclinfo[0]);
}
void
random_roi
()
...
...
@@ -356,28 +344,17 @@ TEST_P(Split, Accuracy)
cv
::
split
(
mat_roi
,
dev_dst
);
cv
::
ocl
::
split
(
gmat
,
dev_gdst
);
cv
::
Mat
cpu_dst1
;
cv
::
Mat
cpu_dst2
;
cv
::
Mat
cpu_dst3
;
cv
::
Mat
cpu_dst4
;
gdst1_whole
.
download
(
cpu_dst1
);
gdst2_whole
.
download
(
cpu_dst2
);
gdst3_whole
.
download
(
cpu_dst3
);
gdst4_whole
.
download
(
cpu_dst4
);
char
sss
[
1024
];
sprintf
(
sss
,
"roicols=%d,roirows=%d,dst1x =%d,dsty=%d,dst2x =%d,dst2y=%d,dst3x =%d,dst3y=%d,dst4x =%d,dst4y=%d,srcx=%d,srcy=%d"
,
roicols
,
roirows
,
dst1x
,
dst1y
,
dst2x
,
dst2y
,
dst3x
,
dst3y
,
dst4x
,
dst4y
,
srcx
,
srcy
);
if
(
channels
>=
1
)
EXPECT_MAT_NEAR
(
dst1
,
cpu_dst1
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
dst1
,
Mat
(
gdst1_whole
),
0.0
);
if
(
channels
>=
2
)
EXPECT_MAT_NEAR
(
dst2
,
cpu_dst2
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
dst2
,
Mat
(
gdst2_whole
),
0.0
);
if
(
channels
>=
3
)
EXPECT_MAT_NEAR
(
dst3
,
cpu_dst3
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
dst3
,
Mat
(
gdst3_whole
),
0.0
);
if
(
channels
>=
4
)
EXPECT_MAT_NEAR
(
dst4
,
cpu_dst4
,
0.0
,
sss
);
EXPECT_MAT_NEAR
(
dst4
,
Mat
(
gdst4_whole
),
0.0
);
}
}
...
...
modules/ocl/test/utility.hpp
View file @
6eb5a95a
...
...
@@ -76,20 +76,20 @@ double checkSimilarity(const cv::Mat &m1, const cv::Mat &m2);
EXPECT_LE(checkNorm(cv::Mat(mat)), eps) \
}
/*
#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
#define EXPECT_MAT_NEAR(mat1, mat2, eps) \
{ \
ASSERT_EQ(mat1.type(), mat2.type()); \
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