-
Notifications
You must be signed in to change notification settings - Fork 196
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a test to check the stride is being set correctly when provided in the stream configuration Signed-off-by: William Vinnicombe <[email protected]>
- Loading branch information
1 parent
4235b12
commit 87b709f
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/python3 | ||
|
||
import time | ||
|
||
from picamera2 import MappedArray, Picamera2, libcamera | ||
|
||
|
||
def pre_callback(request): | ||
# Set the size, to make preview window and MappedArray remapping work | ||
assert request.config["main"]["stride"] == stride | ||
request.config["main"]["size"] = full_size | ||
request.stream_map["main"].configuration.size = libcamera.Size(*full_size) | ||
|
||
|
||
def post_callback(request): | ||
# Make right side grey | ||
with MappedArray(request, "main") as m1: | ||
a1 = m1.array | ||
a1[:, -a1.shape[1] // 2:] = 70 | ||
|
||
|
||
picam2 = Picamera2(0) | ||
|
||
full_size = (1920, 1080) | ||
half_size = (full_size[0] // 2, full_size[1]) | ||
# Calculate stride for full frame | ||
full_config = picam2.create_preview_configuration({"size": full_size}) | ||
picam2.configure(full_config) | ||
stride = picam2.camera_config["main"]["stride"] | ||
|
||
# Configure as half frame, with full frame stride so right side is blank | ||
picam2.pre_callback = pre_callback | ||
picam2.post_callback = post_callback | ||
main_config = picam2.create_preview_configuration( | ||
main={"size": half_size, "stride": stride} | ||
) | ||
picam2.configure(main_config) | ||
picam2.start_preview(True) | ||
|
||
picam2.start() | ||
time.sleep(2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters