Skip to content

Commit

Permalink
picamera2: Allow setting of stride
Browse files Browse the repository at this point in the history
Allow setting of the stride in stream configuration, and default to 0 if
not set to allow libcamera to set the correct stride.

Signed-off-by: William Vinnicombe <[email protected]>
  • Loading branch information
will-v-pi authored and davidplowman committed Dec 13, 2023
1 parent 6d72d09 commit fb1aa19
Showing 1 changed file with 6 additions and 1 deletion.
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

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

0 comments on commit fb1aa19

Please sign in to comment.