✨ feat(main): 添加图像处理功能,修改RGB数据并更新FLTK图像显示
This commit is contained in:
parent
563a54303f
commit
07c8591bfc
12
src/main.rs
12
src/main.rs
|
@ -9,6 +9,7 @@ use fltk::{
|
||||||
prelude::{GroupExt, WidgetBase, WidgetExt},
|
prelude::{GroupExt, WidgetBase, WidgetExt},
|
||||||
window::Window,
|
window::Window,
|
||||||
};
|
};
|
||||||
|
use image::Rgb;
|
||||||
use rscam::{Camera, Config};
|
use rscam::{Camera, Config};
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
@ -55,15 +56,20 @@ fn main() {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
let img = image::load_from_memory(&data).unwrap();
|
let img = image::load_from_memory(&data).unwrap();
|
||||||
let l_data = img.to_luma8();
|
let l_data = img.to_luma8();
|
||||||
let rgb_data = img.to_rgb8();
|
let mut rgb_data = img.to_rgb8();
|
||||||
if w == 0 {
|
if w == 0 {
|
||||||
w = l_data.width() as i32;
|
w = l_data.width() as i32;
|
||||||
h = l_data.height() as i32;
|
h = l_data.height() as i32;
|
||||||
}
|
}
|
||||||
|
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_l_image =
|
let fltk_l_image =
|
||||||
RgbImage::new(&l_data.as_raw(), w, h, ColorDepth::L8).unwrap();
|
RgbImage::new(l_data.as_raw(), w, h, ColorDepth::L8).unwrap();
|
||||||
let fltk_rgb_image =
|
let fltk_rgb_image =
|
||||||
RgbImage::new(&rgb_data.as_raw(), w, h, ColorDepth::Rgb8).unwrap();
|
RgbImage::new(rgb_data.as_raw(), w, h, ColorDepth::Rgb8).unwrap();
|
||||||
camera_frame.set_image(Some(fltk_l_image));
|
camera_frame.set_image(Some(fltk_l_image));
|
||||||
color_frame.set_image(Some(fltk_rgb_image));
|
color_frame.set_image(Some(fltk_rgb_image));
|
||||||
camera_frame.redraw();
|
camera_frame.redraw();
|
||||||
|
|
Loading…
Reference in New Issue