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

picamera2: Allow setting of stride #892

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion picamera2/picamera2.py
Original file line number Diff line number Diff line change
Expand Up @@ -641,7 +641,7 @@ def _make_initial_stream_config(stream_config: dict, updates: dict, ignore_list=
"""
if updates is None:
return None
valid = ("format", "size")
valid = ("format", "size", "stride")
for key, value in updates.items():
if isinstance(value, SensorFormat):
value = str(value)
Expand Down Expand Up @@ -839,6 +839,11 @@ def _update_libcamera_stream_config(libcamera_stream_config, stream_config, buff
libcamera_stream_config.size = libcamera.Size(stream_config["size"][0], stream_config["size"][1])
libcamera_stream_config.pixel_format = libcamera.PixelFormat(stream_config["format"])
libcamera_stream_config.buffer_count = buffer_count
# Stride is sometimes set to None in the stream_config, so need to guard against that case
if stream_config.get("stride") is not None:
libcamera_stream_config.stride = stream_config["stride"]
else:
libcamera_stream_config.stride = 0
Copy link
Collaborator

Choose a reason for hiding this comment

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

Would libcamera_stream_config.stride = stream_config.get("stride", 0) be the same?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh yes, that'll be cleaner, I'll change that and push a new commit


def _make_libcamera_config(self, camera_config):
# Make a libcamera configuration object from our Python configuration.
Expand Down
Loading