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
The crop attribute should be renamed zoom #146
Comments
I'm probably not understanding exactly what you're trying to achieve here, but if you want the camera to have an output resolution of 197x488 you can simply set the resolution to that value: import picamera
import time
with picamera.PiCamera():
camera.resolution = (197, 488)
camera.start_preview()
time.sleep(10) What the camera will do in this case is set its mode to 1296x972@30fps (because that's the closest mode it has given the requested resolution and framerate), and crop the result to 197x488. What's slightly tricky to understand about the import picamera
with picamera.PiCamera():
camera.resolution = (197, 488)
camera.start_preview()
camera.crop = (0.25, 0.25, 0.5, 0.5)
time.sleep(10) Unfortunately the |
Thank your for your answer. I think I understand it better now. Basically I tried to select a small region out of FOV but I confused "resolution" with "camera mode". When I set resolution = (1296,972), I was hoping that I forced the camera mode to 1296x972, but that was not the case. Am I correct to say that "camera mode" is chosen not only from frame rate and resolution, but also crop width & height? Setting frame rate aside, considering 2 cases below, in case1, camera mode should be 640x480 while in case 2, camera mode should be 1276x972. Am I right? case1: camera.resolution = (640,480)
camera.crop = (0,0,1.0,1.0)
camera.start_preview() case2: camera.resolution = (640,480)
camera.crop = (0.25,0.25,0.5,0.5)
camera.start_preview() |
Unfortunately no, there's a few misconceptions there:
|
Hi Dave, Thanks for help clearing up things for me. I guess one more thing that add to my confusion is how crop works more like zoom when it still keep the resolution of the cropped image the same as original image, not smaller. Here's my final code that's try to capture and crop a small portion in the top left (or anywhere other than the central area) of the FOV and obtain a smaller resolution image using resize parameter during capturing. Hope I'm doing it right this time :-) camera.resolution = (1296,972)
camera.framerate = 42
# force camera mode to 1296 x 972, capturing full FOV
camera.crop = (0,0,0.3,0.2)
# Need only 389 x 194 pixel (30% x 20% of FOV) on the top left of the FOV
camera.capture('test.jpg',use_video_port=True,resize=(389,194)) By doing so, I was able to achieve my desired goal. In this case, preview of cropped image still be in 4:3 ratio, which is in a wrong portion. But the test.jpg come out correctly. |
Yup ... as mentioned, |
Hello,
I guess this may just be a quick question rather than an issue report. I have been playing around with picamera for a week now. One thing I notice is that when I crop an image and try to preview it, either by fullscreen or using preview_window, the display image always shown with wrong aspect ratio. For example: if I set resolution to 1972x976 and set crop=(0.0, 0.0, 0.1, 0.5), I can't find a way to make preview to properly display it at 197x488 pixel, instead, the preview images seems to always resize/scale the cropped image into 4:3 aspect ratio.
Do you know how to fix this? Or am I doing anything wrong?
Thanks for the great work!
Kanawat.
The text was updated successfully, but these errors were encountered: