Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new capture methods capture_2d/capture_3d/capture_2d_3d #296

Merged
merged 4 commits into from
Dec 9, 2024

Conversation

johningve
Copy link
Contributor

These methods are intended to replace capture which is now deprecated.

@johningve johningve requested a review from a team as a code owner November 28, 2024 08:24
@@ -47,9 +47,127 @@ def __str__(self):
def __eq__(self, other):
return self.__impl == other._Camera__impl

def capture2d3d(self, settings):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we change the "samples" directory and README snippets to use these new functions?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@johningve johningve force-pushed the ZIVID-9207-wrap-new-capture-methods branch 2 times, most recently from 4943a0f to e08ec7d Compare December 6, 2024 09:37
vawale
vawale previously approved these changes Dec 6, 2024
@johningve johningve force-pushed the ZIVID-9207-wrap-new-capture-methods branch 2 times, most recently from d1baa82 to d32bde4 Compare December 6, 2024 11:33
TypeError: If the settings argument is not a Settings2D or a Settings
"""
if isinstance(settings, Settings2D):
return Frame2D(self.__impl.capture2D(_to_internal_settings2d(settings)))
Copy link
Contributor

@apartridge apartridge Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why using different casing (2D) in the impl method?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I'll change it

@johningve johningve force-pushed the ZIVID-9207-wrap-new-capture-methods branch 3 times, most recently from 20957a5 to 9bb6f87 Compare December 9, 2024 13:28
@johningve johningve changed the title Add new capture methods capture2d/capture3d/capture2d3d Add new capture methods capture_2d/capture_3d/capture_2d_3d Dec 9, 2024
@johningve johningve force-pushed the ZIVID-9207-wrap-new-capture-methods branch from 9bb6f87 to b3cf317 Compare December 9, 2024 13:32
Comment on lines 139 to 142
This overload is provided for convenience. Note that only the Settings2D part under `Settings.color` will be
used for the capture. The other parts of the settings will be ignored.

This method will throw if `Settings.color` is not set.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is used for capture_2d(settings) and capture_2d(settings_2d) it seems, this part of the docstring applies only for the former and not the latter. This could be clarified a bit in the docstring?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Comment on lines +17 to +22
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
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you check that we dont have same bug here as we had in .NET where we didnt mutate the actual settings.color but instead a copy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah. Added a commit to test this


with shared_file_camera.capture_2d_3d(settings) as frame:
assert frame
assert isinstance(frame, zivid.frame.Frame)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could in this file test a bit more, such that the frame.settings matches what is set above, which would reduce chances of bugs in this code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@johningve johningve force-pushed the ZIVID-9207-wrap-new-capture-methods branch 3 times, most recently from bc01afb to 558b397 Compare December 9, 2024 14:11
This commit adds the capture methods `capture_2d`, `capture_3d`, and
`capture_2d_3d`. These methods are intended to replace `capture` which
is now deprecated.
@johningve johningve force-pushed the ZIVID-9207-wrap-new-capture-methods branch 2 times, most recently from 3f0a119 to fc5cf96 Compare December 9, 2024 14:34
This extends test_settings to convert to the internal (C++) settings and
back, ensuring that the settings are propagated correctly to C++.
@johningve johningve force-pushed the ZIVID-9207-wrap-new-capture-methods branch from fc5cf96 to 22ee714 Compare December 9, 2024 14:36
@johningve johningve merged commit 5673aef into master Dec 9, 2024
23 checks passed
@johningve johningve deleted the ZIVID-9207-wrap-new-capture-methods branch December 9, 2024 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

4 participants