diff --git a/AGENTS.md b/AGENTS.md index 59f95d4..4867d59 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -11,3 +11,4 @@ - The monitor provides room lighting: keep the translucent white overlay on throughout the countdown and until photo capture returns; do not fade it out early. - Display the countdown as a large semi-transparent number directly over the lighting overlay, without a box or supporting text. - The primary kiosk monitor is a 19-inch 1907FPVT LCD at 1280×1024 (5:4). Check overlays at that resolution; constrain scaling by width as well as height, keep instructions in two columns, and leave the central camera area clear. +- Always mirror camera frames horizontally for a selfie view, including the initial preview. Run palm detection in the same mirrored coordinates so overlays remain aligned. diff --git a/src/main.rs b/src/main.rs index 7a3631e..ae71f0e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,11 @@ use std::{ time::{Duration, Instant}, }; -use opencv::{core::Mat, imgproc, prelude::*}; +use opencv::{ + core::{self, Mat}, + imgproc, + prelude::*, +}; use slint::{Rgb8Pixel, SharedPixelBuffer}; slint::include_modules!(); @@ -38,6 +42,7 @@ fn main() -> Result<(), Box> { "Check camera passthrough and camera frame rate.", ); let (mut cam, mut frame) = camera::wait_until_ready(&mut camera_log)?; + mirror_frame(&mut frame)?; let mut detector = palm::Detector::new()?; let ui = AppWindow::new()?; @@ -103,6 +108,8 @@ fn main() -> Result<(), Box> { } let now = Instant::now(); + // Use the same selfie coordinates for detection and the preview. + mirror_frame(&mut frame)?; if now.duration_since(last_detection) >= palm::DETECTION_INTERVAL { let _ = detection_tx.try_send(frame.try_clone()?); last_detection = now; @@ -172,6 +179,13 @@ fn main() -> Result<(), Box> { Ok(()) } +fn mirror_frame(frame: &mut Mat) -> opencv::Result<()> { + let mut mirrored = Mat::default(); + core::flip(frame, &mut mirrored, 1)?; + *frame = mirrored; + Ok(()) +} + fn frame_to_buffer(frame: &Mat) -> opencv::Result> { let mut rgb = Mat::default();