Skip to content

Commit

Permalink
Merge pull request #178 from zivid/2024-04-27-update-python-samples
Browse files Browse the repository at this point in the history
Samples: Minor updates
  • Loading branch information
andersfagerli authored Jun 14, 2024
2 parents 73465bc + 04e296b commit 19cae6b
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 27 deletions.
4 changes: 2 additions & 2 deletions source/camera/advanced/capture_2d_and_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ def _main() -> None:

print("Configuring 3D settings")
settings = zivid.Settings()
settings.engine = "phase"
settings.engine = zivid.Settings.Engine.phase
settings.acquisitions.append(zivid.Settings.Acquisition())
settings.sampling.pixel = zivid.Settings.Sampling.Pixel.blueSubsample4x4
settings.sampling.color = zivid.Settings.Sampling.Color.disabled
settings.processing.resampling = zivid.Settings.Processing.Resampling.Mode.upsample2x2
settings.processing.resampling.mode = zivid.Settings.Processing.Resampling.Mode.upsample2x2

if camera.info.model in [zivid.CameraInfo.Model.zividTwo, zivid.CameraInfo.Model.zividTwoL100]:
print(
Expand Down
10 changes: 1 addition & 9 deletions source/camera/basic/capture_2d_with_settings_from_yml.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,7 @@ def _options() -> argparse.Namespace:
Arguments from user
"""
parser = argparse.ArgumentParser(
description=(
"Balance the color of a 2D image\n"
"Example:\n"
"\t $ python color_balance.py path/to/settings.yml\n\n"
"where path/to/settings.yml is the path to the 2D acquisition settings you want to find color balance for."
),
formatter_class=argparse.RawTextHelpFormatter,
)
parser = argparse.ArgumentParser(description=__doc__)

parser.add_argument(
dest="path",
Expand Down
12 changes: 7 additions & 5 deletions source/camera/basic/capture_hdr_complete_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ def _main() -> None:

print("Configuring settings for capture:")
settings = zivid.Settings()
settings.engine = "phase"
settings.sampling.color = "rgb"
settings.sampling.pixel = "all"
settings.engine = zivid.Settings.Engine.phase
settings.sampling.color = zivid.Settings.Sampling.Color.rgb
settings.sampling.pixel = zivid.Settings.Sampling.Pixel.blueSubsample2x2
settings.region_of_interest.box.enabled = True
settings.region_of_interest.box.point_o = [1000, 1000, 1000]
settings.region_of_interest.box.point_a = [1000, -1000, 1000]
Expand All @@ -80,7 +80,7 @@ def _main() -> None:
filters.outlier.removal.enabled = True
filters.outlier.removal.threshold = 5.0
filters.reflection.removal.enabled = True
filters.reflection.removal.mode = "global"
filters.reflection.removal.mode = zivid.Settings.Processing.Filters.Reflection.Removal.Mode.global_
filters.cluster.removal.enabled = True
filters.cluster.removal.max_neighbor_distance = 10
filters.cluster.removal.min_area = 100
Expand All @@ -91,12 +91,14 @@ def _main() -> None:
filters.hole.repair.enabled = True
filters.hole.repair.hole_size = 0.2
filters.hole.repair.strictness = 1
resampling = settings.processing.resampling
resampling.mode = zivid.Settings.Processing.Resampling.Mode.upsample2x2
color = settings.processing.color
color.balance.red = 1.0
color.balance.blue = 1.0
color.balance.green = 1.0
color.gamma = 1.0
settings.processing.color.experimental.mode = "automatic"
settings.processing.color.experimental.mode = zivid.Settings.Processing.Color.Experimental.Mode.automatic
print(settings)

print("Configuring acquisition settings different for all HDR acquisitions")
Expand Down
18 changes: 10 additions & 8 deletions source/camera/basic/capture_tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -238,14 +238,14 @@ settings = zivid.Settings(acquisitions=[zivid.Settings.Acquisition(aperture=fnum
Fully configured settings are demonstrated below.

([go to
source](https://github.com/zivid/zivid-python-samples/tree/master//source/camera/basic/capture_hdr_complete_settings.py#L61-L112))
source](https://github.com/zivid/zivid-python-samples/tree/master//source/camera/basic/capture_hdr_complete_settings.py#L61-L114))

``` sourceCode python
print("Configuring settings for capture:")
settings = zivid.Settings()
settings.engine = "phase"
settings.sampling.color = "rgb"
settings.sampling.pixel = "all"
settings.engine = zivid.Settings.Engine.phase
settings.sampling.color = zivid.Settings.Sampling.Color.rgb
settings.sampling.pixel = zivid.Settings.Sampling.Pixel.blueSubsample2x2
settings.region_of_interest.box.enabled = True
settings.region_of_interest.box.point_o = [1000, 1000, 1000]
settings.region_of_interest.box.point_a = [1000, -1000, 1000]
Expand All @@ -263,7 +263,7 @@ filters.noise.repair.enabled = True
filters.outlier.removal.enabled = True
filters.outlier.removal.threshold = 5.0
filters.reflection.removal.enabled = True
filters.reflection.removal.mode = "global"
filters.reflection.removal.mode = zivid.Settings.Processing.Filters.Reflection.Removal.Mode.global_
filters.cluster.removal.enabled = True
filters.cluster.removal.max_neighbor_distance = 10
filters.cluster.removal.min_area = 100
Expand All @@ -274,12 +274,14 @@ filters.experimental.contrast_distortion.removal.threshold = 0.5
filters.hole.repair.enabled = True
filters.hole.repair.hole_size = 0.2
filters.hole.repair.strictness = 1
resampling = settings.processing.resampling
resampling.mode = zivid.Settings.Processing.Resampling.Mode.upsample2x2
color = settings.processing.color
color.balance.red = 1.0
color.balance.blue = 1.0
color.balance.green = 1.0
color.gamma = 1.0
settings.processing.color.experimental.mode = "automatic"
settings.processing.color.experimental.mode = zivid.Settings.Processing.Color.Experimental.Mode.automatic
print(settings)
print("Configuring acquisition settings different for all HDR acquisitions")
exposure_values = _get_exposure_values(camera)
Expand Down Expand Up @@ -325,7 +327,7 @@ Check out
for recommended .yml files tuned for your application.

([go to
source](https://github.com/zivid/zivid-python-samples/tree/master//source/camera/basic/capture_hdr_complete_settings.py#L124-L129))
source](https://github.com/zivid/zivid-python-samples/tree/master//source/camera/basic/capture_hdr_complete_settings.py#L126-L131))

``` sourceCode python
settings_file = "Settings.yml"
Expand All @@ -338,7 +340,7 @@ settings_from_file = zivid.Settings.load(settings_file)
You can also save settings to .yml file.

([go to
source](https://github.com/zivid/zivid-python-samples/tree/master//source/camera/basic/capture_hdr_complete_settings.py#L124-L126))
source](https://github.com/zivid/zivid-python-samples/tree/master//source/camera/basic/capture_hdr_complete_settings.py#L126-L128))

``` sourceCode python
settings_file = "Settings.yml"
Expand Down
2 changes: 1 addition & 1 deletion source/camera/info_util_other/camera_user_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ def _options() -> argparse.Namespace:
"""
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest="mode", help="Select mode")
subparsers = parser.add_subparsers(dest="mode", help="Select mode", required=True)
subparsers.add_parser(
"read",
help="read",
Expand Down
4 changes: 2 additions & 2 deletions source/camera/maintenance/correct_camera_in_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def _main() -> None:
accuracy_estimate = correction.accuracy_estimate()

print(
"If written to the camera, this correction can be expected to yield a dimension accuracy error of ",
f"{accuracy_estimate.dimension_accuracy()*100:.3f} or better in the range of z=[{accuracy_estimate.z_min():.3f}, {accuracy_estimate.z_max():.3f}] across the full FOV.",
"If written to the camera, this correction can be expected to yield a dimension accuracy error of",
f"{accuracy_estimate.dimension_accuracy()*100:.3f}% or better in the range of z=[{accuracy_estimate.z_min():.3f}, {accuracy_estimate.z_max():.3f}] across the full FOV.",
"Accuracy close to where the correction data was collected is likely better.",
)

Expand Down

0 comments on commit 19cae6b

Please sign in to comment.