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
8b57893e
Commit
8b57893e
authored
Nov 08, 2013
by
Ilya Lavrenov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added an accuracy test for ocl::buildWarpPerspectiveMaps
parent
4248f822
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
110 additions
and
0 deletions
+110
-0
test_warp.cpp
modules/ocl/test/test_warp.cpp
+110
-0
No files found.
modules/ocl/test/test_warp.cpp
View file @
8b57893e
...
...
@@ -156,6 +156,114 @@ OCL_TEST_P(WarpPerspective, Mat)
}
}
// buildWarpPerspectiveMaps
PARAM_TEST_CASE
(
BuildWarpPerspectiveMaps
,
bool
,
bool
)
{
bool
useRoi
,
mapInverse
;
Size
dsize
;
Mat
xmap_whole
,
ymap_whole
,
xmap_roi
,
ymap_roi
;
ocl
::
oclMat
gxmap_whole
,
gymap_whole
,
gxmap_roi
,
gymap_roi
;
void
SetUp
()
{
mapInverse
=
GET_PARAM
(
0
);
useRoi
=
GET_PARAM
(
1
);
}
void
random_roi
()
{
dsize
=
randomSize
(
1
,
MAX_VALUE
);
Border
xmapBorder
=
randomBorder
(
0
,
useRoi
?
MAX_VALUE
:
0
);
randomSubMat
(
xmap_whole
,
xmap_roi
,
dsize
,
xmapBorder
,
CV_32FC1
,
-
MAX_VALUE
,
MAX_VALUE
);
Border
ymapBorder
=
randomBorder
(
0
,
useRoi
?
MAX_VALUE
:
0
);
randomSubMat
(
ymap_whole
,
ymap_roi
,
dsize
,
ymapBorder
,
CV_32FC1
,
-
MAX_VALUE
,
MAX_VALUE
);
generateOclMat
(
gxmap_whole
,
gxmap_roi
,
xmap_whole
,
dsize
,
xmapBorder
);
generateOclMat
(
gymap_whole
,
gymap_roi
,
ymap_whole
,
dsize
,
ymapBorder
);
}
void
Near
(
double
threshold
=
0.0
)
{
Mat
whole
,
roi
;
gxmap_whole
.
download
(
whole
);
gxmap_roi
.
download
(
roi
);
EXPECT_MAT_NEAR
(
xmap_whole
,
whole
,
threshold
);
EXPECT_MAT_NEAR
(
xmap_roi
,
roi
,
threshold
);
}
void
Near1
(
double
threshold
=
0.0
)
{
Mat
whole
,
roi
;
gymap_whole
.
download
(
whole
);
gymap_roi
.
download
(
roi
);
EXPECT_MAT_NEAR
(
ymap_whole
,
whole
,
threshold
);
EXPECT_MAT_NEAR
(
ymap_roi
,
roi
,
threshold
);
}
};
static
void
buildWarpPerspectiveMaps
(
const
Mat
&
M
,
bool
inverse
,
Size
dsize
,
Mat
&
xmap
,
Mat
&
ymap
)
{
CV_Assert
(
M
.
rows
==
3
&&
M
.
cols
==
3
);
CV_Assert
(
dsize
.
area
()
>
0
);
xmap
.
create
(
dsize
,
CV_32FC1
);
ymap
.
create
(
dsize
,
CV_32FC1
);
float
coeffs
[
3
*
3
];
Mat
coeffsMat
(
3
,
3
,
CV_32F
,
(
void
*
)
coeffs
);
if
(
inverse
)
M
.
convertTo
(
coeffsMat
,
coeffsMat
.
type
());
else
{
cv
::
Mat
iM
;
invert
(
M
,
iM
);
iM
.
convertTo
(
coeffsMat
,
coeffsMat
.
type
());
}
for
(
int
y
=
0
;
y
<
dsize
.
height
;
++
y
)
{
float
*
const
xmap_ptr
=
xmap
.
ptr
<
float
>
(
y
);
float
*
const
ymap_ptr
=
ymap
.
ptr
<
float
>
(
y
);
for
(
int
x
=
0
;
x
<
dsize
.
width
;
++
x
)
{
float
coeff
=
1.0
f
/
(
x
*
coeffs
[
6
]
+
y
*
coeffs
[
7
]
+
coeffs
[
8
]);
xmap_ptr
[
x
]
=
(
x
*
coeffs
[
0
]
+
y
*
coeffs
[
1
]
+
coeffs
[
2
])
*
coeff
;
ymap_ptr
[
x
]
=
(
x
*
coeffs
[
3
]
+
y
*
coeffs
[
4
]
+
coeffs
[
5
])
*
coeff
;
}
}
}
OCL_TEST_P
(
BuildWarpPerspectiveMaps
,
Mat
)
{
for
(
int
j
=
0
;
j
<
LOOP_TIMES
;
j
++
)
{
random_roi
();
float
cols
=
static_cast
<
float
>
(
MAX_VALUE
),
rows
=
static_cast
<
float
>
(
MAX_VALUE
);
float
cols2
=
cols
/
2.0
f
,
rows2
=
rows
/
2.0
f
;
Point2f
sp
[]
=
{
Point2f
(
0.0
f
,
0.0
f
),
Point2f
(
cols
,
0.0
f
),
Point2f
(
0.0
f
,
rows
),
Point2f
(
cols
,
rows
)
};
Point2f
dp
[]
=
{
Point2f
(
rng
.
uniform
(
0.0
f
,
cols2
),
rng
.
uniform
(
0.0
f
,
rows2
)),
Point2f
(
rng
.
uniform
(
cols2
,
cols
),
rng
.
uniform
(
0.0
f
,
rows2
)),
Point2f
(
rng
.
uniform
(
0.0
f
,
cols2
),
rng
.
uniform
(
rows2
,
rows
)),
Point2f
(
rng
.
uniform
(
cols2
,
cols
),
rng
.
uniform
(
rows2
,
rows
))
};
Mat
M
=
getPerspectiveTransform
(
sp
,
dp
);
buildWarpPerspectiveMaps
(
M
,
mapInverse
,
dsize
,
xmap_roi
,
ymap_roi
);
ocl
::
buildWarpPerspectiveMaps
(
M
,
mapInverse
,
dsize
,
gxmap_roi
,
gymap_roi
);
Near
(
1e-6
);
Near1
(
1e-6
);
}
}
/////////////////////////////////////////////////////////////////////////////////////////////////
// remap
...
...
@@ -338,6 +446,8 @@ INSTANTIATE_TEST_CASE_P(ImgprocWarp, WarpPerspective, Combine(
Bool
(),
Bool
()));
INSTANTIATE_TEST_CASE_P
(
ImgprocWarp
,
BuildWarpPerspectiveMaps
,
Combine
(
Bool
(),
Bool
()));
INSTANTIATE_TEST_CASE_P
(
ImgprocWarp
,
Remap_INTER_LINEAR
,
Combine
(
Values
(
CV_8U
,
CV_16U
,
CV_16S
,
CV_32F
,
CV_64F
),
Values
(
1
,
2
,
3
,
4
),
...
...
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