LoginSignup
0
0

ZED SDK のステレオカメラで欠損値の扱いを調査する。

Posted at

この記事で述べること

  • 3Dカメラのdepthデータは計測点によって信頼度が異なる。
  • そのため、信頼度の低い計測点を除外することが必要になる。
  • 除外した点は欠損点となる。
  • 欠損点の頻度を調整するパラメータがZED SDKに何があるか
  • 欠損点を生じたときのデータはどのようになるか

想定する読者

stereolabsのzed2, zed mini, zed z などのステレオカメラの利用者
いまどきのステレオカメラは何ができるのかを知りたい人

前提

ZED SDK 4.1
Ubuntu 20.04
ZED2i
Python 版のAPI

ZED SDKでの設定パラメータ

runtime_parameters = sl.RuntimeParameters()
(中略)
# 値を100にすると欠損値が少なくなる方向。値を小さくすると、欠損値が増える。
runtime_parameters.confidence_threshold = 1 ~ 100 の数値
runtime_parameters.enable_fill_mode = True or False
# 値を100にすると欠損値が少なくなる方向。値を小さくすると、欠損値が増える。
runtime_parameters.texture_confidence_threshold = 1 ~ 100の数値
runtime_parameters.remove_saturated_areas = True or False
(中略)
zed.grab(runtime_parameters)

他にも影響するパラメータ

init_params.depth_mode = depthの計算方式です。
init_params.depth_stabilization
init_params.enable_right_side_measure = 物体の右側のエッジでのdepthを計算するかどうか

欠損値はどのように含まれるか

depth_map

zed = sl.Camera()
err = zed.open(init_params)
depth_map = sl.Mat()

zed.retrieve_measure(depth_map, sl.MEASURE.DEPTH)  # Retrieve depth
depth_map_data = depth_map.get_data()
H, W = depth_map_data.shape[:2]
count_isfinite = np.count_nonzero(np.isfinite(depth_map_data))
count_isnan = np.count_nonzero(np.isnan(depth_map_data))
count_isneginf = np.count_nonzero(np.isneginf(depth_map_data))
count_isposinf = np.count_nonzero(np.isposinf(depth_map_data))

このようにすることで、isfinte以外のデータである欠損値がどの程度の頻度で存在するのかを確認できます。

点群のZ成分

zed.retrieve_measure(point_cloud, sl.MEASURE.XYZRGBA)
points = point_cloud.get_data()
print(f"{points.shape=}")

points_z = points[:, :, 2]
count_isfinite_points_z = np.count_nonzero(np.isfinite(points_z))
count_isnan_points_z = np.count_nonzero(np.isnan(points_z))
count_isneginf_points_z = np.count_nonzero(np.isneginf(points_z))
count_isposinf_points_z = np.count_nonzero(np.isposinf(points_z))

点群の色成分

zed.retrieve_measure(point_cloud, sl.MEASURE.XYZRGBA)
points = point_cloud.get_data()
print(f"{points.shape=}")
assert depth_map_data.shape == points.shape[:2]
# 点群の最後の成分は色情報をfloat32にしたもの。
points_color = points[:, :, 3]
count_isfinite_points = np.count_nonzero(np.isfinite(points_color))
count_isnan_points = np.count_nonzero(np.isnan(points_color))
count_isneginf_points = np.count_nonzero(np.isneginf(points_color))
count_isposinf_points = np.count_nonzero(np.isposinf(points_color))

このような手法で、欠損値の状況を知ることができます。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0