fix: use default camera, first element in query result might not be a camera (#12010)

This commit is contained in:
lichon 2025-06-12 13:35:42 +08:00 committed by GitHub
parent 645cfd3b3d
commit 05a812247a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -49,7 +49,7 @@ impl Cameras {
let Some(info) = cameras.first() else {
bail!("No camera found")
};
let camera = Self::create_camera(info.index())?;
let camera = Self::create_camera(&CameraIndex::Index(0))?;
let resolution = camera.resolution();
let (width, height) = (resolution.width() as i32, resolution.height() as i32);
camera_displays.push(DisplayInfo {
@ -112,7 +112,7 @@ impl Cameras {
fn create_camera(index: &CameraIndex) -> ResultType<Camera> {
let result = Camera::new(
index.clone(),
RequestedFormat::new::<RgbAFormat>(RequestedFormatType::AbsoluteHighestResolution),
RequestedFormat::new::<RgbAFormat>(RequestedFormatType::None),
);
match result {
Ok(camera) => Ok(camera),