Compare commits

...

2 Commits

1 changed files with 25 additions and 26 deletions

View File

@ -23,12 +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_frame.set_align(Align::Center);
camera_window.end();
camera_window.show();
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_frame.set_align(Align::Center);
color_window.end();
color_window.show();
// app.run().unwrap();
@ -51,6 +51,7 @@ fn main() {
let mut w = 0;
let mut h = 0;
if camera_open {
crossbeam::scope(|_| {
loop {
// 捕获一帧图像
match camera.capture() {
@ -63,7 +64,7 @@ fn main() {
w = l_data.width() as i32;
h = l_data.height() as i32;
}
crossbeam::scope(|_| {
for tmp_x in 0..30 {
for tmp_y in 0..60 {
rgb_data.put_pixel(tmp_x, tmp_y, Rgb([102, 204, 255]));
@ -77,9 +78,7 @@ fn main() {
color_frame.redraw();
let duration = start.elapsed();
println!("L8 Frame Draw use time: {:?}", duration);
})
.unwrap();
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));
@ -87,8 +86,6 @@ fn main() {
camera_frame.redraw();
let duration = start.elapsed();
println!("RGB8 Frame Draw use time: {:?}", duration);
})
.unwrap();
}
Err(e) => {
eprintln!("捕获错误: {}", e);
@ -97,6 +94,8 @@ fn main() {
}
app.wait();
}
})
.unwrap();
}
}