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
50b29199
Commit
50b29199
authored
May 05, 2014
by
Ilya Krylov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for stereoCalibrate
parent
c2341fd4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
238 additions
and
3 deletions
+238
-3
calib3d.hpp
modules/calib3d/include/opencv2/calib3d/calib3d.hpp
+3
-3
fisheye.cpp
modules/calib3d/src/fisheye.cpp
+0
-0
test_fisheye.cpp
modules/calib3d/test/test_fisheye.cpp
+235
-0
No files found.
modules/calib3d/include/opencv2/calib3d/calib3d.hpp
View file @
50b29199
...
...
@@ -806,10 +806,10 @@ public:
//! performs stereo calibaration
static
double
stereoCalibrate
(
InputArrayOfArrays
objectPoints
,
InputArrayOfArrays
imagePoints1
,
InputArrayOfArrays
imagePoints2
,
InputOutputArray
K1
,
InputOutputArray
D1
,
InputOutputArray
K2
,
InputOutputArray
D2
,
InputOutputArrayOfArrays
rvecs1
,
InputOutputArrayOfArrays
tvecs1
,
InputOutputArrayOfArrays
rvecs2
,
InputOutputArrayOfArrays
tvecs2
,
InputOutputArray
K1
,
InputOutputArray
D1
,
InputOutputArray
K2
,
InputOutputArray
D2
,
Size
imageSize
,
OutputArray
R
,
OutputArray
T
,
int
flags
,
TermCriteria
criteria
=
TermCriteria
(
3
,
100
,
1e-10
));
};
}
...
...
modules/calib3d/src/fisheye.cpp
View file @
50b29199
This diff is collapsed.
Click to expand it.
modules/calib3d/test/test_fisheye.cpp
View file @
50b29199
...
...
@@ -368,6 +368,241 @@ TEST_F(FisheyeTest, rectify)
}
}
TEST_F
(
FisheyeTest
,
stereoCalibrate
)
{
const
int
n_images
=
34
;
const
std
::
string
folder
=
combine
(
datasets_repository_path
,
"calib-3_stereo_from_JY"
);
std
::
vector
<
std
::
vector
<
cv
::
Point2d
>
>
leftPoints
(
n_images
);
std
::
vector
<
std
::
vector
<
cv
::
Point2d
>
>
rightPoints
(
n_images
);
std
::
vector
<
std
::
vector
<
cv
::
Point3d
>
>
objectPoints
(
n_images
);
cv
::
FileStorage
fs_left
(
combine
(
folder
,
"left.xml"
),
cv
::
FileStorage
::
READ
);
CV_Assert
(
fs_left
.
isOpened
());
for
(
int
i
=
0
;
i
<
n_images
;
++
i
)
fs_left
[
cv
::
format
(
"image_%d"
,
i
)]
>>
leftPoints
[
i
];
fs_left
.
release
();
cv
::
FileStorage
fs_right
(
combine
(
folder
,
"right.xml"
),
cv
::
FileStorage
::
READ
);
CV_Assert
(
fs_right
.
isOpened
());
for
(
int
i
=
0
;
i
<
n_images
;
++
i
)
fs_right
[
cv
::
format
(
"image_%d"
,
i
)]
>>
rightPoints
[
i
];
fs_right
.
release
();
cv
::
FileStorage
fs_object
(
combine
(
folder
,
"object.xml"
),
cv
::
FileStorage
::
READ
);
CV_Assert
(
fs_object
.
isOpened
());
for
(
int
i
=
0
;
i
<
n_images
;
++
i
)
fs_object
[
cv
::
format
(
"image_%d"
,
i
)]
>>
objectPoints
[
i
];
fs_object
.
release
();
std
::
ofstream
fs
;
for
(
size_t
i
=
0
;
i
<
leftPoints
.
size
();
i
++
)
{
std
::
string
ss
=
combine
(
folder
,
"left"
);
ss
=
combine_format
(
ss
,
"%d"
,
i
);
fs
.
open
(
ss
.
c_str
());
CV_Assert
(
fs
.
is_open
());
for
(
size_t
j
=
0
;
j
<
leftPoints
[
i
].
size
();
j
++
)
{
double
x
=
leftPoints
[
i
][
j
].
x
;
double
y
=
leftPoints
[
i
][
j
].
y
;
fs
<<
std
::
setprecision
(
15
)
<<
x
<<
"; "
<<
y
;
fs
<<
std
::
endl
;
}
fs
.
close
();
}
for
(
size_t
i
=
0
;
i
<
rightPoints
.
size
();
i
++
)
{
std
::
string
ss
=
combine
(
folder
,
"right"
);
ss
=
combine_format
(
ss
,
"%d"
,
i
);
fs
.
open
(
ss
.
c_str
());
CV_Assert
(
fs
.
is_open
());
for
(
size_t
j
=
0
;
j
<
rightPoints
[
i
].
size
();
j
++
)
{
double
x
=
rightPoints
[
i
][
j
].
x
;
double
y
=
rightPoints
[
i
][
j
].
y
;
fs
<<
std
::
setprecision
(
15
)
<<
x
<<
"; "
<<
y
;
fs
<<
std
::
endl
;
}
fs
.
close
();
}
for
(
size_t
i
=
0
;
i
<
objectPoints
.
size
();
i
++
)
{
std
::
string
ss
=
combine
(
folder
,
"object"
);
ss
=
combine_format
(
ss
,
"%d"
,
i
);
fs
.
open
(
ss
.
c_str
());
CV_Assert
(
fs
.
is_open
());
for
(
size_t
j
=
0
;
j
<
objectPoints
[
i
].
size
();
j
++
)
{
double
x
=
objectPoints
[
i
][
j
].
x
;
double
y
=
objectPoints
[
i
][
j
].
y
;
double
z
=
objectPoints
[
i
][
j
].
z
;
fs
<<
std
::
setprecision
(
15
)
<<
x
<<
"; "
<<
y
;
fs
<<
std
::
setprecision
(
15
)
<<
"; "
<<
z
;
fs
<<
std
::
endl
;
}
fs
.
close
();
}
cv
::
Matx33d
K1
,
K2
,
R
;
cv
::
Vec3d
T
;
cv
::
Vec4d
D1
,
D2
;
int
flag
=
0
;
flag
|=
cv
::
Fisheye
::
CALIB_RECOMPUTE_EXTRINSIC
;
flag
|=
cv
::
Fisheye
::
CALIB_CHECK_COND
;
flag
|=
cv
::
Fisheye
::
CALIB_FIX_SKEW
;
// flag |= cv::Fisheye::CALIB_FIX_INTRINSIC;
cv
::
Fisheye
::
stereoCalibrate
(
objectPoints
,
leftPoints
,
rightPoints
,
K1
,
D1
,
K2
,
D2
,
imageSize
,
R
,
T
,
flag
,
cv
::
TermCriteria
(
3
,
12
,
0
));
cv
::
Matx33d
R_correct
(
0.9975587205950972
,
0.06953016383322372
,
0.006492709911733523
,
-
0.06956823121068059
,
0.9975601387249519
,
0.005833595226966235
,
-
0.006071257768382089
,
-
0.006271040135405457
,
0.9999619062167968
);
cv
::
Vec3d
T_correct
(
-
0.099402724724121
,
0.00270812139265413
,
0.00129330292472699
);
cv
::
Matx33d
K1_correct
(
561.195925927249
,
0
,
621.282400272412
,
0
,
562.849402029712
,
380.555455380889
,
0
,
0
,
1
);
cv
::
Matx33d
K2_correct
(
560.395452535348
,
0
,
678.971652040359
,
0
,
561.90171021422
,
380.401340535339
,
0
,
0
,
1
);
cv
::
Vec4d
D1_correct
(
-
7.44253716539556e-05
,
-
0.00702662033932424
,
0.00737569823650885
,
-
0.00342230256441771
);
cv
::
Vec4d
D2_correct
(
-
0.0130785435677431
,
0.0284434505383497
,
-
0.0360333869900506
,
0.0144724062347222
);
EXPECT_MAT_NEAR
(
R
,
R_correct
,
1e-10
);
EXPECT_MAT_NEAR
(
T
,
T_correct
,
1e-10
);
EXPECT_MAT_NEAR
(
K1
,
K1_correct
,
1e-10
);
EXPECT_MAT_NEAR
(
K2
,
K2_correct
,
1e-10
);
EXPECT_MAT_NEAR
(
D1
,
D1_correct
,
1e-10
);
EXPECT_MAT_NEAR
(
D2
,
D2_correct
,
1e-10
);
}
TEST_F
(
FisheyeTest
,
stereoCalibrateFixIntrinsic
)
{
const
int
n_images
=
34
;
const
std
::
string
folder
=
combine
(
datasets_repository_path
,
"calib-3_stereo_from_JY"
);
std
::
vector
<
std
::
vector
<
cv
::
Point2d
>
>
leftPoints
(
n_images
);
std
::
vector
<
std
::
vector
<
cv
::
Point2d
>
>
rightPoints
(
n_images
);
std
::
vector
<
std
::
vector
<
cv
::
Point3d
>
>
objectPoints
(
n_images
);
cv
::
FileStorage
fs_left
(
combine
(
folder
,
"left.xml"
),
cv
::
FileStorage
::
READ
);
CV_Assert
(
fs_left
.
isOpened
());
for
(
int
i
=
0
;
i
<
n_images
;
++
i
)
fs_left
[
cv
::
format
(
"image_%d"
,
i
)]
>>
leftPoints
[
i
];
fs_left
.
release
();
cv
::
FileStorage
fs_right
(
combine
(
folder
,
"right.xml"
),
cv
::
FileStorage
::
READ
);
CV_Assert
(
fs_right
.
isOpened
());
for
(
int
i
=
0
;
i
<
n_images
;
++
i
)
fs_right
[
cv
::
format
(
"image_%d"
,
i
)]
>>
rightPoints
[
i
];
fs_right
.
release
();
cv
::
FileStorage
fs_object
(
combine
(
folder
,
"object.xml"
),
cv
::
FileStorage
::
READ
);
CV_Assert
(
fs_object
.
isOpened
());
for
(
int
i
=
0
;
i
<
n_images
;
++
i
)
fs_object
[
cv
::
format
(
"image_%d"
,
i
)]
>>
objectPoints
[
i
];
fs_object
.
release
();
std
::
ofstream
fs
;
for
(
size_t
i
=
0
;
i
<
leftPoints
.
size
();
i
++
)
{
std
::
string
ss
=
combine
(
folder
,
"left"
);
ss
=
combine_format
(
ss
,
"%d"
,
i
);
fs
.
open
(
ss
.
c_str
());
CV_Assert
(
fs
.
is_open
());
for
(
size_t
j
=
0
;
j
<
leftPoints
[
i
].
size
();
j
++
)
{
double
x
=
leftPoints
[
i
][
j
].
x
;
double
y
=
leftPoints
[
i
][
j
].
y
;
fs
<<
std
::
setprecision
(
15
)
<<
x
<<
"; "
<<
y
;
fs
<<
std
::
endl
;
}
fs
.
close
();
}
for
(
size_t
i
=
0
;
i
<
rightPoints
.
size
();
i
++
)
{
std
::
string
ss
=
combine
(
folder
,
"right"
);
ss
=
combine_format
(
ss
,
"%d"
,
i
);
fs
.
open
(
ss
.
c_str
());
CV_Assert
(
fs
.
is_open
());
for
(
size_t
j
=
0
;
j
<
rightPoints
[
i
].
size
();
j
++
)
{
double
x
=
rightPoints
[
i
][
j
].
x
;
double
y
=
rightPoints
[
i
][
j
].
y
;
fs
<<
std
::
setprecision
(
15
)
<<
x
<<
"; "
<<
y
;
fs
<<
std
::
endl
;
}
fs
.
close
();
}
for
(
size_t
i
=
0
;
i
<
objectPoints
.
size
();
i
++
)
{
std
::
string
ss
=
combine
(
folder
,
"object"
);
ss
=
combine_format
(
ss
,
"%d"
,
i
);
fs
.
open
(
ss
.
c_str
());
CV_Assert
(
fs
.
is_open
());
for
(
size_t
j
=
0
;
j
<
objectPoints
[
i
].
size
();
j
++
)
{
double
x
=
objectPoints
[
i
][
j
].
x
;
double
y
=
objectPoints
[
i
][
j
].
y
;
double
z
=
objectPoints
[
i
][
j
].
z
;
fs
<<
std
::
setprecision
(
15
)
<<
x
<<
"; "
<<
y
;
fs
<<
std
::
setprecision
(
15
)
<<
"; "
<<
z
;
fs
<<
std
::
endl
;
}
fs
.
close
();
}
cv
::
Matx33d
R
;
cv
::
Vec3d
T
;
int
flag
=
0
;
flag
|=
cv
::
Fisheye
::
CALIB_RECOMPUTE_EXTRINSIC
;
flag
|=
cv
::
Fisheye
::
CALIB_CHECK_COND
;
flag
|=
cv
::
Fisheye
::
CALIB_FIX_SKEW
;
flag
|=
cv
::
Fisheye
::
CALIB_FIX_INTRINSIC
;
cv
::
Matx33d
K1
(
561.195925927249
,
0
,
621.282400272412
,
0
,
562.849402029712
,
380.555455380889
,
0
,
0
,
1
);
cv
::
Matx33d
K2
(
560.395452535348
,
0
,
678.971652040359
,
0
,
561.90171021422
,
380.401340535339
,
0
,
0
,
1
);
cv
::
Vec4d
D1
(
-
7.44253716539556e-05
,
-
0.00702662033932424
,
0.00737569823650885
,
-
0.00342230256441771
);
cv
::
Vec4d
D2
(
-
0.0130785435677431
,
0.0284434505383497
,
-
0.0360333869900506
,
0.0144724062347222
);
cv
::
Fisheye
::
stereoCalibrate
(
objectPoints
,
leftPoints
,
rightPoints
,
K1
,
D1
,
K2
,
D2
,
imageSize
,
R
,
T
,
flag
,
cv
::
TermCriteria
(
3
,
12
,
0
));
cv
::
Matx33d
R_correct
(
0.9975587205950972
,
0.06953016383322372
,
0.006492709911733523
,
-
0.06956823121068059
,
0.9975601387249519
,
0.005833595226966235
,
-
0.006071257768382089
,
-
0.006271040135405457
,
0.9999619062167968
);
cv
::
Vec3d
T_correct
(
-
0.099402724724121
,
0.00270812139265413
,
0.00129330292472699
);
EXPECT_MAT_NEAR
(
R
,
R_correct
,
1e-10
);
EXPECT_MAT_NEAR
(
T
,
T_correct
,
1e-10
);
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/// FisheyeTest::
...
...
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