commit ff378888a34a1467950ef4d7b6cba6b812b18a45 Author: Joe Date: Wed Nov 20 21:22:00 2024 +0000 Initial commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..54f365e --- /dev/null +++ b/.gitignore @@ -0,0 +1,16 @@ +# Generated by Cargo +# will have compiled files and executables +debug/ +target/ + +# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries +# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html +Cargo.lock + +# These are backup files generated by rustfmt +**/*.rs.bk + +# MSVC Windows builds of rustc generate these, which store debugging information +*.pdb + +*.png \ No newline at end of file diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..98e2fdc --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "pixel_maping" +version = "0.1.0" +edition = "2021" + +[dependencies] +eframe = "0.29.1" +egui = "0.29.1" +egui_extras = "0.29.1" +image = "0.25.5" +nokhwa = {version = "0.10.5", features = ["input-v4l"]} +sacn = "0.4.4" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..5698f29 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,33 @@ +use nokhwa::{ + pixel_format::RgbFormat, + utils::{CameraIndex, RequestedFormat, RequestedFormatType}, + Camera, +}; + +use image::DynamicImage; + +use eframe::egui; + +fn main() { + // first camera in system + let index = CameraIndex::Index(0); + // request the absolute highest resolution CameraFormat that can be decoded to RGB. + let requested = + RequestedFormat::new::(RequestedFormatType::AbsoluteHighestFrameRate); + // make the camera + let mut camera = Camera::new(index, requested).unwrap(); + + camera.open_stream(); + + // get a frame + let frame = camera.frame().unwrap(); + println!("Captured Single Frame of {}", frame.buffer().len()); + // decode into an ImageBuffer + let decoded = frame.decode_image::().unwrap(); + + for pxl in decoded.iter() { + + } + + DynamicImage::from(decoded).save("test.png"); +}