Compare commits

..

No commits in common. "06709c9fa52767fd407bcfdbab1ad563d8c4ec5f" and "8e3a43173f48e87d6bb83ddf279953850f1ee708" have entirely different histories.

3 changed files with 18 additions and 52 deletions

24
Cargo.lock generated
View File

@ -183,19 +183,6 @@ dependencies = [
"cfg-if",
]
[[package]]
name = "crossbeam"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8"
dependencies = [
"crossbeam-channel",
"crossbeam-deque",
"crossbeam-epoch",
"crossbeam-queue",
"crossbeam-utils",
]
[[package]]
name = "crossbeam-channel"
version = "0.5.13"
@ -224,15 +211,6 @@ dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-queue"
version = "0.3.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df0346b5d5e76ac2fe4e327c5fd1118d6be7c51dfb18f9b7922923f287471e35"
dependencies = [
"crossbeam-utils",
]
[[package]]
name = "crossbeam-utils"
version = "0.8.20"
@ -794,8 +772,6 @@ dependencies = [
name = "rust_v4l2"
version = "0.1.0"
dependencies = [
"crossbeam",
"crossbeam-channel",
"fltk",
"image",
"rscam",

View File

@ -4,8 +4,6 @@ version = "0.1.0"
edition = "2021"
[dependencies]
crossbeam = "0.8.4"
crossbeam-channel = "0.5.13"
fltk = "1.4.36"
image = "0.25.5"
rscam = "0.5.5"

View File

@ -46,8 +46,8 @@ fn main() {
eprint!("Open Camera Error:{}", e)
}
}
let mut w = 0;
let mut h = 0;
let mut w = 0 as i32;
let mut h = 0 as i32;
if camera_open {
loop {
// 捕获一帧图像
@ -61,31 +61,23 @@ 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]));
}
}
let fltk_rgb_image =
RgbImage::new(rgb_data.as_raw(), w, h, ColorDepth::Rgb8).unwrap();
color_frame.set_image(Some(fltk_rgb_image));
color_frame.set_size(w, h);
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();
let fltk_rgb_image =
RgbImage::new(rgb_data.as_raw(), w, h, ColorDepth::Rgb8).unwrap();
camera_frame.set_image(Some(fltk_l_image));
color_frame.set_image(Some(fltk_rgb_image));
// 通过重新调整尺寸从而刷新图像
color_frame.set_size(w, h);
camera_frame.redraw();
color_frame.redraw();
let duration = start.elapsed();
println!("RGB8 Frame Draw use time: {:?}", duration);
})
.unwrap();
println!("Time elapsed in DrawImage is: {:?}", duration);
}
Err(e) => {
eprintln!("捕获错误: {}", e);