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
ace6eaef
Commit
ace6eaef
authored
Feb 06, 2012
by
Alexander Shishkov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added one more test for undistort
parent
014577b4
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
98 additions
and
0 deletions
+98
-0
test_undistort_points.cpp
modules/calib3d/test/test_undistort_points.cpp
+98
-0
No files found.
modules/calib3d/test/test_undistort_points.cpp
0 → 100644
View file @
ace6eaef
#include "test_precomp.hpp"
#include <string>
using
namespace
cv
;
using
namespace
std
;
class
CV_UndistortTest
:
public
cvtest
::
BaseTest
{
public
:
CV_UndistortTest
();
~
CV_UndistortTest
();
protected
:
void
run
(
int
);
private
:
void
generate3DPointCloud
(
vector
<
Point3f
>&
points
,
Point3f
pmin
=
Point3f
(
-
1
,
-
1
,
5
),
Point3f
pmax
=
Point3f
(
1
,
1
,
10
));
void
generateCameraMatrix
(
Mat
&
cameraMatrix
);
void
generateDistCoeffs
(
Mat
&
distCoeffs
,
int
count
);
double
thresh
;
RNG
rng
;
};
CV_UndistortTest
::
CV_UndistortTest
()
{
thresh
=
1.0e-2
;
}
CV_UndistortTest
::~
CV_UndistortTest
()
{}
void
CV_UndistortTest
::
generate3DPointCloud
(
vector
<
Point3f
>&
points
,
Point3f
pmin
,
Point3f
pmax
)
{
const
Point3f
delta
=
pmax
-
pmin
;
for
(
size_t
i
=
0
;
i
<
points
.
size
();
i
++
)
{
Point3f
p
(
float
(
rand
())
/
RAND_MAX
,
float
(
rand
())
/
RAND_MAX
,
float
(
rand
())
/
RAND_MAX
);
p
.
x
*=
delta
.
x
;
p
.
y
*=
delta
.
y
;
p
.
z
*=
delta
.
z
;
p
=
p
+
pmin
;
points
[
i
]
=
p
;
}
}
void
CV_UndistortTest
::
generateCameraMatrix
(
Mat
&
cameraMatrix
)
{
const
double
fcMinVal
=
1e-3
;
const
double
fcMaxVal
=
100
;
cameraMatrix
.
create
(
3
,
3
,
CV_64FC1
);
cameraMatrix
.
setTo
(
Scalar
(
0
));
cameraMatrix
.
at
<
double
>
(
0
,
0
)
=
rng
.
uniform
(
fcMinVal
,
fcMaxVal
);
cameraMatrix
.
at
<
double
>
(
1
,
1
)
=
rng
.
uniform
(
fcMinVal
,
fcMaxVal
);
cameraMatrix
.
at
<
double
>
(
0
,
2
)
=
rng
.
uniform
(
fcMinVal
,
fcMaxVal
);
cameraMatrix
.
at
<
double
>
(
1
,
2
)
=
rng
.
uniform
(
fcMinVal
,
fcMaxVal
);
cameraMatrix
.
at
<
double
>
(
2
,
2
)
=
1
;
}
void
CV_UndistortTest
::
generateDistCoeffs
(
Mat
&
distCoeffs
,
int
count
)
{
distCoeffs
=
Mat
::
zeros
(
count
,
1
,
CV_64FC1
);
for
(
int
i
=
0
;
i
<
count
;
i
++
)
distCoeffs
.
at
<
double
>
(
i
,
0
)
=
rng
.
uniform
(
0.0
,
1.0e-3
);
}
void
CV_UndistortTest
::
run
(
int
/* start_from */
)
{
Mat
intrinsics
,
distCoeffs
;
generateCameraMatrix
(
intrinsics
);
vector
<
Point3f
>
points
(
500
);
generate3DPointCloud
(
points
);
vector
<
Point2f
>
projectedPoints
;
projectedPoints
.
resize
(
points
.
size
());
int
modelMembersCount
[]
=
{
4
,
5
,
8
};
for
(
int
idx
=
0
;
idx
<
3
;
idx
++
)
{
generateDistCoeffs
(
distCoeffs
,
modelMembersCount
[
idx
]);
projectPoints
(
Mat
(
points
),
Mat
::
zeros
(
3
,
1
,
CV_64FC1
),
Mat
::
zeros
(
3
,
1
,
CV_64FC1
),
intrinsics
,
distCoeffs
,
projectedPoints
);
vector
<
Point2f
>
realUndistortedPoints
;
projectPoints
(
Mat
(
points
),
Mat
::
zeros
(
3
,
1
,
CV_64FC1
),
Mat
::
zeros
(
3
,
1
,
CV_64FC1
),
intrinsics
,
Mat
::
zeros
(
4
,
1
,
CV_64FC1
),
realUndistortedPoints
);
Mat
undistortedPoints
;
undistortPoints
(
Mat
(
projectedPoints
),
undistortedPoints
,
intrinsics
,
distCoeffs
);
Mat
p
;
perspectiveTransform
(
undistortedPoints
,
p
,
intrinsics
);
undistortedPoints
=
p
;
double
diff
=
norm
(
Mat
(
realUndistortedPoints
),
undistortedPoints
);
if
(
diff
>
thresh
)
{
ts
->
set_failed_test_info
(
cvtest
::
TS
::
FAIL_BAD_ACCURACY
);
return
;
}
ts
->
set_failed_test_info
(
cvtest
::
TS
::
OK
);
}
}
TEST
(
Calib3d_Undistort
,
accuracy
)
{
CV_UndistortTest
test
;
test
.
safe_run
();
}
\ No newline at end of file
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