raspberrypi / picamera2

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

[HOW-TO]use afwindow to focus #966

Open feiwenxiong opened 7 months ago

feiwenxiong commented 7 months ago

please help me understand the meaning of AfWindows and how to use it when i want to mannually focus! Thanks ahead

davidplowman commented 7 months ago

Hi, the AfWindows control gets described briefly in appendix C of the manual. You need to use something like

picam2.set_controls({'AfWindows': rectangles})

where rectangles is a list of rectangles, and a single rectangle is a tuple of 4 values (x_offset, y_offset, width, height). The coordinate frame for these rectangles is the same as the maximum scaler crop (returned by picam2.camera_properties['ScalerCropMaximum']).

Once you've tried this, please do get back to us if you have more specific questions.

feiwenxiong commented 7 months ago

Thanks! I got it !