Skip to content

Commit

Permalink
Samples: make use of the new capture functions
Browse files Browse the repository at this point in the history
  • Loading branch information
johningve committed Dec 9, 2024
1 parent 96bdca2 commit a3910eb
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion samples/sample_calibrate_eye_to_hand.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
11 changes: 9 additions & 2 deletions samples/sample_capture.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Capture sample."""

import datetime
from zivid import Application, Settings
from zivid import Application, Settings, Settings2D


def _main():
Expand All @@ -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")


Expand Down
2 changes: 1 addition & 1 deletion samples/sample_capture_2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion samples/sample_capture_assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")


Expand Down
2 changes: 1 addition & 1 deletion samples/sample_capture_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
9 changes: 6 additions & 3 deletions samples/sample_capture_from_file.py
Original file line number Diff line number Diff line change
@@ -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")


Expand Down
14 changes: 12 additions & 2 deletions samples/sample_capture_hdr.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""HDR capture sample."""

from zivid import Application, Settings
import datetime

from zivid import Application, Settings, Settings2D


def _main():
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion samples/sample_presets.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 3 additions & 1 deletion samples/sample_project_on_checkerboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit a3910eb

Please sign in to comment.