Skip to content

Commit 6f2cb4f

Browse files
committed
Samples: Automatic updates to public repository
Remember to do the following: 1. Ensure that modified/deleted/new files are correct 2. Make this commit message relevant for the changes 3. Force push 4. Delete branch after PR is merged If this commit is an update from one SDK version to another, make sure to create a release tag for previous version.
1 parent 946169f commit 6f2cb4f

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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

modules/zividsamples/gui/hand_eye_calibration_gui.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
from zividsamples.gui.show_yaml_dialog import show_yaml_dialog
3232
from zividsamples.gui.tab_with_robot_support import TabWidgetWithRobotSupport
3333
from zividsamples.save_load_transformation_matrix import load_transformation_matrix, save_transformation_matrix
34+
from zividsamples.save_residuals import save_residuals
3435
from 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(
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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)

0 commit comments

Comments
 (0)