From a3910eba737513def99b0ec0b404a94c2c1db63f Mon Sep 17 00:00:00 2001 From: John Ingve Olsen Date: Thu, 5 Dec 2024 11:17:10 +0100 Subject: [PATCH] Samples: make use of the new capture functions --- samples/sample_calibrate_eye_to_hand.py | 2 +- samples/sample_capture.py | 11 +++++++++-- samples/sample_capture_2d.py | 2 +- samples/sample_capture_assistant.py | 2 +- samples/sample_capture_async.py | 2 +- samples/sample_capture_from_file.py | 9 ++++++--- samples/sample_capture_hdr.py | 14 ++++++++++++-- samples/sample_presets.py | 2 +- samples/sample_project_on_checkerboard.py | 4 +++- 9 files changed, 35 insertions(+), 13 deletions(-) diff --git a/samples/sample_calibrate_eye_to_hand.py b/samples/sample_calibrate_eye_to_hand.py index fb57df41..84937381 100644 --- a/samples/sample_calibrate_eye_to_hand.py +++ b/samples/sample_calibrate_eye_to_hand.py @@ -19,7 +19,7 @@ def _acquire_checkerboard_frame(camera): settings = zivid.capture_assistant.suggest_settings( camera, suggest_settings_parameters ) - return camera.capture(settings) + return camera.capture_2d_3d(settings) def _enter_robot_pose(index): diff --git a/samples/sample_capture.py b/samples/sample_capture.py index 16366283..bb5abe5a 100644 --- a/samples/sample_capture.py +++ b/samples/sample_capture.py @@ -1,7 +1,7 @@ """Capture sample.""" import datetime -from zivid import Application, Settings +from zivid import Application, Settings, Settings2D def _main(): @@ -14,7 +14,14 @@ def _main(): settings.processing.filters.outlier.removal.enabled = True settings.processing.filters.outlier.removal.threshold = 5.0 - with camera.capture(settings) as frame: + settings.color = Settings2D() + settings.color.acquisitions.append(Settings2D.Acquisition()) + settings.color.acquisitions[0].aperture = 5.6 + settings.color.acquisitions[0].exposure_time = datetime.timedelta( + microseconds=8333 + ) + + with camera.capture_2d_3d(settings) as frame: frame.save("result.zdf") diff --git a/samples/sample_capture_2d.py b/samples/sample_capture_2d.py index 6e94c37c..2142e30d 100644 --- a/samples/sample_capture_2d.py +++ b/samples/sample_capture_2d.py @@ -14,7 +14,7 @@ def _main(): microseconds=10000 ) - with camera.capture(settings_2d) as frame_2d: + with camera.capture_2d(settings_2d) as frame_2d: image = frame_2d.image_rgba() image.save("result.png") diff --git a/samples/sample_capture_assistant.py b/samples/sample_capture_assistant.py index 17f9c3ad..8bcd9f15 100644 --- a/samples/sample_capture_assistant.py +++ b/samples/sample_capture_assistant.py @@ -17,7 +17,7 @@ def _main(): camera, suggest_settings_parameters ) - with camera.capture(settings) as frame: + with camera.capture_2d_3d(settings) as frame: frame.save("result.zdf") diff --git a/samples/sample_capture_async.py b/samples/sample_capture_async.py index c60f74e1..765f7415 100644 --- a/samples/sample_capture_async.py +++ b/samples/sample_capture_async.py @@ -9,7 +9,7 @@ def _capture_sync(cameras: list[zivid.Camera]) -> list[zivid.Frame]: return [ - camera.capture( + camera.capture_3d( zivid.Settings( acquisitions=[ zivid.Settings.Acquisition( diff --git a/samples/sample_capture_from_file.py b/samples/sample_capture_from_file.py index 4c47e325..344587fe 100644 --- a/samples/sample_capture_from_file.py +++ b/samples/sample_capture_from_file.py @@ -1,14 +1,17 @@ """File camera capture sample.""" -from zivid import Application, Settings +from zivid import Application, Settings, Settings2D def _main(): app = Application() with app.create_file_camera("FileCameraZivid2M70.zfc") as camera: - settings = Settings(acquisitions=[Settings.Acquisition()]) + settings = Settings( + acquisitions=[Settings.Acquisition()], + color=Settings2D(acquisitions=[Settings2D.Acquisition()]), + ) - with camera.capture(settings) as frame: + with camera.capture_2d_3d(settings) as frame: frame.save("result.zdf") diff --git a/samples/sample_capture_hdr.py b/samples/sample_capture_hdr.py index e9ff7500..820819a1 100644 --- a/samples/sample_capture_hdr.py +++ b/samples/sample_capture_hdr.py @@ -1,6 +1,8 @@ """HDR capture sample.""" -from zivid import Application, Settings +import datetime + +from zivid import Application, Settings, Settings2D def _main(): @@ -10,7 +12,15 @@ def _main(): acquisitions=[ Settings.Acquisition(aperture=aperture) for aperture in (10.90, 5.80, 2.83) - ] + ], + color=Settings2D( + acquisitions=[ + Settings2D.Acquisition( + exposure_time=datetime.timedelta(microseconds=exposure_time) + ) + for exposure_time in (1677, 5000, 10000) + ] + ), ) with camera.capture(settings) as hdr_frame: hdr_frame.save("result.zdf") diff --git a/samples/sample_presets.py b/samples/sample_presets.py index e829d332..82fd6384 100644 --- a/samples/sample_presets.py +++ b/samples/sample_presets.py @@ -28,7 +28,7 @@ def _main(): ] print("Capturing point cloud with preset '{}' ...".format(chosen_preset.name)) - with camera.capture(chosen_preset.settings) as frame: + with camera.capture_2d_3d(chosen_preset.settings) as frame: frame.save("result.zdf") settings_file = chosen_preset.name + ".yml" diff --git a/samples/sample_project_on_checkerboard.py b/samples/sample_project_on_checkerboard.py index aea83b13..835036c6 100644 --- a/samples/sample_project_on_checkerboard.py +++ b/samples/sample_project_on_checkerboard.py @@ -17,7 +17,9 @@ def _detect_checkerboard(camera): print("Detecting checkerboard...") settings = Settings() settings.acquisitions.append(Settings.Acquisition()) - with camera.capture(settings) as frame: + settings.color = Settings2D() + settings.color.acquisitions.append(Settings2D.Acquisition()) + with camera.capture_2d_3d(settings) as frame: detection_result = detect_feature_points(frame.point_cloud()) if not detection_result.valid(): raise RuntimeError("Failed to detect checkerboard")