Initial commit

This commit is contained in:
2024-11-20 21:22:00 +00:00
commit ff378888a3
3 changed files with 61 additions and 0 deletions

16
.gitignore vendored Normal file
View File

@@ -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

12
Cargo.toml Normal file
View File

@@ -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"

33
src/main.rs Normal file
View File

@@ -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::<RgbFormat>(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::<RgbFormat>().unwrap();
for pxl in decoded.iter() {
}
DynamicImage::from(decoded).save("test.png");
}