waveform80 / picamera

A pure Python interface to the Raspberry Pi camera module
https://picamera.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.57k stars 355 forks source link

Question : weird result with camera.rotation #609

Open mfr-panda opened 4 years ago

mfr-panda commented 4 years ago

Hi, I have some troubles with camera.rotation

if i do this , with V1 camera turned at 90°:

camera = picamera.PiCamera()
camera.resolution = (2592,1944)
camera.rotation = 90
camera.framerate = 15
camera.start_preview(resolution=(972,1296), rotation = 0)
time.sleep(5)
camera.capture('test_rot.jpg')
camera.close()

I obtain a good ratio on the Preview (3:4) with full FoV, but the captured image is 4:3 (2592x1944) and severely cropped.

BTW, I can achieve getting full FoV from the rotated camera by doing this :

camera.resolution = (2592,1944)
camera.framerate = 15
camera.start_preview(resolution=(1296,972), rotation = 90)
time.sleep(5)
camera.capture('test_rot_OK.jpg')
# then rotate file with PIL
im = Image.open('test_rot_OK.jpg')
im.rotate(-90,expand=1)

Incorrect Capture: NOT_OK Correct Capture : OK

Maybe i missed something as i don't understand what camera.resolution do and why the results differs between the 2 methods.

best regards,

6by9 commented 4 years ago

camera.resolution is the resolution of the output JPEG, and you've asked for and got 2592,1944.

If you want the full field of view and rotated 90degrees, then ask for 1944x2592, in exactly the same way as you've already rotated your preview resolution.