Using it to automate a microscope setup and need to preset the zoom level before I click an image. I know the camera has 10x digital zoom. I referred to this link that allows me to control the zoom factor
RPi 4 Git_Link
This is the zoom control code:
# Or play around with digital zoom:
libcamera-still -t 0 --viewfinder-width 2312 --viewfinder-height 1736 -k
# While preview is showing, go back to terminal and press:
# W: Zoom in
# S: Zoom out
# I: Move upward
# K: Move downward
# J: Move left
# L: Move right
# R: Reset
# M: 10x Zoom
# You have to press the character, then press 'Enter' for it to register.
My challenge is that I want to pre-set the zooming factor to 5x zoom and then click an image. I am not able to find any resources to do this.
std::optional<Rectangle> sensor_area = props.get(libcamera::properties::ScalerCropMaximum);
qDebug() <<"sensor "<<sensor_area->width<<" "<<sensor_area->height;
int x = 0.25 * sensor_area->width;
int y = 0.25 * sensor_area->height;
int w = 0.5 * sensor_area->width;
int h = 0.5 * sensor_area->height;
Rectangle crop(x, y, w, h);
crop.translateBy(sensor_area->topLeft());
controls_.set(libcamera::controls::ScalerCrop, crop);