File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed
Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -186,7 +186,7 @@ from the camera can be used.
186186 - [ save\_ load\_ transformation\_ matrix] ( https://github.com/zivid/zivid-python-samples/tree/master/modules/zividsamples/save_load_transformation_matrix.py ) -
187187 assert\_ affine\_ matrix\_ and\_ save(transformation\_ matrix.as\_ matrix(),
188188 yaml\_ path)
189- - [ settings\_ utils] ( https://github.com/zivid/zivid-python-samples/tree/master/modules/zividsamples/settings_utils.py ) - categories = zivid.presets.categories2d(camera.info.model)
189+ - [ save \_ residuals ] ( https://github.com/zivid/zivid-python-samples/tree/master/modules/zividsamples/save_residuals.py ) - per \_ pose \_ residuals = \[ - [ settings\_ utils] ( https://github.com/zivid/zivid-python-samples/tree/master/modules/zividsamples/settings_utils.py ) - categories = zivid.presets.categories2d(camera.info.model)
190190 - [ transformation\_ matrix] ( https://github.com/zivid/zivid-python-samples/tree/master/modules/zividsamples/transformation_matrix.py ) - Convenience functions and a class for 4x4 transformation
191191 matrices.
192192 - [ white\_ balance\_ calibration] ( https://github.com/zivid/zivid-python-samples/tree/master/modules/zividsamples/white_balance_calibration.py ) - Balance color for 2D capture using white surface as
Original file line number Diff line number Diff line change 3131from zividsamples .gui .show_yaml_dialog import show_yaml_dialog
3232from zividsamples .gui .tab_with_robot_support import TabWidgetWithRobotSupport
3333from zividsamples .save_load_transformation_matrix import load_transformation_matrix , save_transformation_matrix
34+ from zividsamples .save_residuals import save_residuals
3435from zividsamples .transformation_matrix import TransformationMatrix
3536
3637
@@ -325,6 +326,10 @@ def on_calibrate_button_clicked(self):
325326 hand_eye_transformation_matrix = TransformationMatrix .from_matrix (calibration_result .transform ())
326327 hand_eye_transform_path = self .data_directory / "hand_eye_transform.yaml"
327328 save_transformation_matrix (hand_eye_transformation_matrix , hand_eye_transform_path )
329+
330+ hand_eye_residuals_path = self .data_directory / "hand_eye_residuals.yaml"
331+ save_residuals (calibration_result .residuals (), hand_eye_residuals_path )
332+
328333 self .pose_pair_selection_widget .set_residuals (calibration_result .residuals ())
329334 show_yaml_dialog (hand_eye_transform_path , "Hand Eye Calibration Transform" )
330335 self .update_instructions (
Original file line number Diff line number Diff line change 1+ from pathlib import Path
2+ from typing import Iterable
3+
4+ import yaml
5+
6+
7+ def save_residuals (residuals : Iterable , yaml_path : Path ) -> None :
8+ """Save per-pose hand-eye residuals to a YAML file.
9+
10+ Args:
11+ residuals: Iterable of residual objects with `rotation()` and `translation()` methods.
12+ yaml_path: Destination YAML file path.
13+
14+ """
15+ per_pose_residuals = [
16+ {
17+ "rotation_deg" : float (r .rotation ()),
18+ "translation_mm" : float (r .translation ()),
19+ }
20+ for r in residuals
21+ ]
22+
23+ data = {"per_pose_residuals" : per_pose_residuals }
24+
25+ with open (yaml_path , "w" , encoding = "utf-8" ) as file :
26+ yaml .safe_dump (data , file , sort_keys = False )
You can’t perform that action at this time.
0 commit comments