-
Notifications
You must be signed in to change notification settings - Fork 181
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
ScalerCrops handling #1087
base: next
Are you sure you want to change the base?
ScalerCrops handling #1087
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/python3 | ||
|
||
# Test setting the "preserve_ar" stream configuration flag | ||
|
||
import cv2 | ||
|
||
from picamera2 import Picamera2 | ||
|
||
picam2 = Picamera2() | ||
|
||
for m, l in [(False, False), (False, True), (True, False), (True, True)]: | ||
cfg = picam2.create_video_configuration(main={"size": (1920, 1080), "format": 'XRGB8888', "preserve_ar": m}, | ||
lores={"size": (640, 640), "format": 'XRGB8888', "preserve_ar": l}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just wondering what this does on a Pi 4 where you can't have RGB on the lores? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question - I assumed the validate() would change this to YUV and everything would be good. But I've not explicitly tried it... Actually, there's no reason lores needs to be RGB, perhaps I should just change it to YUV. |
||
display="main") | ||
picam2.configure(cfg) | ||
picam2.start(show_preview=True) | ||
|
||
for _ in range(100): | ||
im = picam2.capture_array("lores") | ||
cv2.imshow("lores", im) | ||
cv2.resizeWindow("lores", (640, 640)) | ||
cv2.waitKey(1) | ||
|
||
picam2.stop() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I'm guessing
par_crop
meanspreserve_ar_crop
? Actually, for my curiosity, how does this work? Presumably libcamera is calculating the AR-preserving crop for each of the cameras - except I thought asking for camera controls was supposed to give us min/max/default triple. So I think I'm a bit confused!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a bit of a hack where the controlinfo for rpi::ScalerCrops actually gives us the default (i.e. preserved ar) crop for output 0 and output 1 in the min/max fields. Unfortunately there is no other mechanism that can be used to get this out for span controls.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, yes, that's a bit sneaky! Maybe worth a comment as it was a bit head-scratchy?