raspberrypi / picamera2

New libcamera based python library
BSD 2-Clause "Simplified" License
852 stars 181 forks source link

[BUG] Preview configuration for size overrides still configuration #1033

Closed pjbRPF closed 4 months ago

pjbRPF commented 4 months ago

Please only report one bug per issue!

Describe the bug When I set a still configuration size and a preview configuration size, the preview size is always used.

To Reproduce from picamera2 import Picamera2 picam2 = Picamera2() import time

picam2.still_configuration.size = (800, 640) picam2.preview_configuration.size = (3280, 2464)

picam2.start(show_preview=True)

time.sleep(2) picam2.capture_file("car.jpg") picam2.stop_preview()

Expected behaviour Preview is at 3280, 2464 but still is at 800, 640.

Hardware : Pi 5, Camera v2

sandyol55 commented 4 months ago

The picamera2.still_configuration, the .preview_configuration and the .video_configuration objects all influence the same properties of the picamera2 object, just with differing default settings, so multiple _configuration objects will likely result in the last one being the one to take effect. To set up a preview configuration that overrides some of the defaults and uses the sensor's full-format full-resolution but has a reduced resolution "main" stream ready for capture, one method would be as below, (one method among many that achieve the same result!)

picam2.preview_configuration.sensor.output_size = (3280,2464)
picam2.preview_configuration.main.size = (800,600)
picam2.configure("preview")
picam2.start(show_preview=True)

HTH Also hope it is accurate ;-) (Long term Picamera2 beginner)