From 7d645e907d032e2cf9404d19b38dc35042f17ee0 Mon Sep 17 00:00:00 2001 From: David PAGNON Date: Fri, 10 Jun 2022 13:03:51 +0200 Subject: [PATCH] fix leading zeros issue --- Pose2Sim/Utilities/calib_yml_to_toml.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/Pose2Sim/Utilities/calib_yml_to_toml.py b/Pose2Sim/Utilities/calib_yml_to_toml.py index e2d5def..188227f 100644 --- a/Pose2Sim/Utilities/calib_yml_to_toml.py +++ b/Pose2Sim/Utilities/calib_yml_to_toml.py @@ -14,7 +14,7 @@ Please correct in the resulting .toml file if needed. Take your image size as a reference. Usage: - from Pose2Sim.Utilities import calib_yml_to_toml; calib_yml_to_toml.calib_yml_to_toml_func(r'', r'') + import calib_yml_to_toml; calib_yml_to_toml.calib_yml_to_toml_func(r'', r'') OR python -m calib_yml_to_toml -i -e OR python -m calib_yml_to_toml -i -e -o "" ''' @@ -53,8 +53,9 @@ def read_intrinsic_yml(intrinsic_path): N = intrinsic_yml.getNode('names').size() S, D, K = [], [], [] for i in range(N): - K.append(intrinsic_yml.getNode(f'K_{i+1}').mat()) - D.append(intrinsic_yml.getNode(f'dist_{i+1}').mat().flatten()[:-1]) + name = intrinsic_yml.getNode('names').at(i).string() + K.append(intrinsic_yml.getNode(f'K_{name}').mat()) + D.append(intrinsic_yml.getNode(f'dist_{name}').mat().flatten()[:-1]) S.append([K[i][0,2]*2, K[i][1,2]*2]) return S, K, D @@ -70,8 +71,9 @@ def read_extrinsic_yml(extrinsic_path): N = extrinsic_yml.getNode('names').size() R, T = [], [] for i in range(N): - R.append(extrinsic_yml.getNode(f'R_{i+1}').mat().flatten()) # R_1 pour Rodrigues, Rot_1 pour matrice - T.append(extrinsic_yml.getNode(f'T_{i+1}').mat().flatten()) + name = extrinsic_yml.getNode('names').at(i).string() + R.append(extrinsic_yml.getNode(f'R_{name}').mat().flatten()) # R_1 pour Rodrigues, Rot_1 pour matrice + T.append(extrinsic_yml.getNode(f'T_{name}').mat().flatten()) return R, T @@ -150,4 +152,4 @@ if __name__ == '__main__': args = vars(parser.parse_args()) calib_yml_to_toml_func(args) - \ No newline at end of file +