Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.ip.stereo
Commits
08c619ff
Commit
08c619ff
authored
May 07, 2021
by
Guillaume CLIVAZ
Browse files
[calibration] Calibration for all pair of camera + update visualization
parent
a78dbbb0
Pipeline
#50611
failed with stage
in 3 minutes and 59 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
bob/ip/stereo/calibration.py
View file @
08c619ff
...
...
@@ -48,6 +48,8 @@ def detect_charuco_corners(image, prep_im, charuco_board, verbosity):
"""
"""
corners
,
ids
=
None
,
None
image
=
np
.
flip
(
image
,
0
)
prep_im
=
np
.
flip
(
prep_im
,
0
)
if
prep_im
is
None
:
markers
,
ids
,
rejected_points
=
cv2
.
aruco
.
detectMarkers
(
image
,
charuco_board
.
dictionary
)
else
:
...
...
@@ -235,8 +237,8 @@ def detect_patterns(directory_path, data_config_path,
.
format
(
capture_name
,
stream
.
name
))
elif
pattern_type
==
"charuco"
:
image
=
np
.
flip
(
image
,
0
)
prep_image
=
np
.
flip
(
prep_image
,
0
)
#
image = np.flip(image, 0)
#
prep_image = np.flip(prep_image, 0)
ret
,
ptrn_pts
,
ids
=
detect_charuco_corners
(
image
,
prep_image
,
charuco_board
,
verbosity
)
if
ids
is
not
None
:
capture_dict
[
stream
.
name
][
capture_name
]
=
(
ids
,
ptrn_pts
)
...
...
@@ -433,8 +435,11 @@ def main():
print
(
"Camera matrix
\n
{}
\n
Distortion coeffs
\n
{}
\n
"
.
format
(
cam_mat
,
dist_coefs
))
print
(
"Reprojection error
\n
{}
\n
"
.
format
(
err
))
if
not
intrinsics_only
:
for
camera_2
in
stream
[
idx
+
1
:]:
if
not
intrinsics_only
:
for
idx
,
camera
in
enumerate
(
stream
):
for
camera_2
in
stream
:
if
camera_2
==
camera
:
continue
df_extrinsics
=
get_valid_frames_for_extrinsic_calibration
(
pts
,
camera
,
camera_2
,
pattern_type
)
calibration
[
camera
][
"df_extrinsics_{}"
.
format
(
camera_2
)]
=
df_extrinsics
if
verbosity
>
1
:
...
...
@@ -447,7 +452,10 @@ def main():
stream
=
[
k
for
k
,
v
in
calibration
.
items
()
if
v
is
not
None
]
for
idx
,
camera
in
enumerate
(
stream
):
image_size
=
image_data
[
camera
]
for
camera_2
in
stream
[
idx
+
1
:]:
# or with itertools.tee()
for
camera_2
in
stream
:
# or with itertools.tee()
if
camera_2
==
camera
:
continue
if
image_data
[
camera_2
]
!=
image_size
:
raise
ValueError
(
"Image size between {} and {} does not match."
.
format
(
camera
,
camera_2
))
if
not
"df_extrinsics_{}"
.
format
(
camera_2
)
in
calibration
[
camera
].
keys
():
...
...
@@ -477,16 +485,6 @@ def main():
print
(
"Rotation
\n
{}
\n
Translation
\n
{}
\n
"
.
format
(
R
,
T
.
T
))
print
(
"Reprojection error
\n
{}
\n
"
.
format
(
err
))
# Visualize with color as reference
poses
=
{}
reference
=
"left"
for
camera
in
stream
:
if
camera
==
reference
:
poses
[
reference
]
=
np
.
eye
(
4
)
else
:
poses
[
camera
]
=
calibration
[
reference
][
"extrinsics_{}"
.
format
(
camera
)]
display_cameras_poses
(
poses
,
config
[
'display'
])
if
args
.
output_file
is
not
None
:
data
=
{}
for
camera
in
stream
:
...
...
@@ -496,5 +494,16 @@ def main():
json
.
dump
(
data
,
f
,
indent
=
4
,
sort_keys
=
True
)
print
(
"{} written."
.
format
(
args
.
output_file
))
for
reference
in
config
[
"display"
][
"references"
]:
poses
=
{}
#reference = "left"
for
camera
in
stream
:
if
camera
==
reference
:
poses
[
reference
]
=
np
.
eye
(
4
)
else
:
poses
[
camera
]
=
calibration
[
reference
][
"extrinsics_{}"
.
format
(
camera
)]
display_cameras_poses
(
poses
,
config
[
'display'
])
if
__name__
==
"__main__"
:
main
()
bob/ip/stereo/config/candy_charuco.json
View file @
08c619ff
...
...
@@ -47,6 +47,7 @@
},
"display"
:
{
"references"
:
[
"left"
],
"axe_x"
:
[
-25
,
25
],
"axe_y"
:
[
-25
,
25
],
"axe_z"
:
[
-10
,
10
]
...
...
bob/ip/stereo/config/charuco_calib_config.json
View file @
08c619ff
...
...
@@ -48,6 +48,7 @@
},
"display"
:
{
"references"
:
[
"color"
,
"nir_left"
,
"nir_right"
],
"axe_x"
:
[
-25
,
25
],
"axe_y"
:
[
-25
,
25
],
"axe_z"
:
[
-10
,
10
]
...
...
bob/ip/stereo/config/chessboard_calib_config.json
View file @
08c619ff
...
...
@@ -38,6 +38,7 @@
},
"display"
:
{
"references"
:
[
"color"
,
"nir_left"
,
"nir_right"
],
"axe_x"
:
[
-25
,
25
],
"axe_y"
:
[
-25
,
25
],
"axe_z"
:
[
-10
,
10
]
...
...
Write
Preview
Supports
Markdown
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