From 031c4bb7c899b537b45614f53fad254d1d72ac45 Mon Sep 17 00:00:00 2001 From: conglinyizhi <cslbyivi@outlook.com> Date: Sat, 7 Dec 2024 13:43:09 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(main):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=9B=BE=E5=83=8F=E5=A4=84=E7=90=86=E5=92=8C=E6=98=BE=E7=A4=BA?= =?UTF-8?q?=E9=80=BB=E8=BE=91,=20=E5=B0=86=E9=83=A8=E5=88=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E7=A7=BB=E5=87=BA=E7=BA=BF=E7=A8=8B,=20=E6=8F=90?= =?UTF-8?q?=E5=8D=87=E6=80=A7=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/main.rs b/src/main.rs index b6b17dc..8dfbfe9 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,9 @@ extern crate rscam; -use std::{env, time::Instant}; +use std::{default, env, time::Instant}; use fltk::{ app::App, - enums::ColorDepth, + enums::{Align, ColorDepth}, frame::Frame, image::RgbImage, prelude::{GroupExt, WidgetBase, WidgetExt}, @@ -23,10 +23,12 @@ fn main() { let app = App::default(); let mut camera_window = Window::new(0, 0, 400, 400, "Camera Video Output Window"); let mut camera_frame = Frame::default_fill(); + camera_frame.set_align(Align::LeftTop); camera_window.end(); camera_window.show(); - let mut color_window = Window::new(0, 400, 400, 400, "Video Output Window"); + let mut color_window = Window::new(0, 450, 400, 400, "Video Output Window"); let mut color_frame = Frame::default_fill(); + color_frame.set_align(Align::LeftTop); color_window.end(); color_window.show(); // app.run().unwrap(); @@ -77,13 +79,16 @@ fn main() { println!("L8 Frame Draw use time: {:?}", duration); }) .unwrap(); - // 尝试将部分功能移出线程 - let fltk_l_image = - RgbImage::new(l_data.as_raw(), w, h, ColorDepth::L8).unwrap(); - camera_frame.set_image(Some(fltk_l_image)); - camera_frame.redraw(); - let duration = start.elapsed(); - println!("RGB8 Frame Draw use time: {:?}", duration); + crossbeam::scope(|_| { + let fltk_l_image = + RgbImage::new(l_data.as_raw(), w, h, ColorDepth::L8).unwrap(); + camera_frame.set_image(Some(fltk_l_image)); + camera_frame.set_size(w, h); + camera_frame.redraw(); + let duration = start.elapsed(); + println!("RGB8 Frame Draw use time: {:?}", duration); + }) + .unwrap(); } Err(e) => { eprintln!("捕获错误: {}", e);