From 5a9874fe671ea5c1ad5f30a70c69620400bb6046 Mon Sep 17 00:00:00 2001 From: l1npengtul Date: Tue, 3 Dec 2024 20:38:47 +0900 Subject: [PATCH] fix features --- Cargo.toml | 7 ++----- examples/captesting/Cargo.toml | 14 ++++++++++++++ examples/captesting/src/main.rs | 15 +++++++++++++++ nokhwa-decoder/Cargo.toml | 22 ++++++++++++++++++++++ nokhwa-decoder/src/lib.rs | 14 ++++++++++++++ 5 files changed, 67 insertions(+), 5 deletions(-) create mode 100644 examples/captesting/Cargo.toml create mode 100644 examples/captesting/src/main.rs create mode 100644 nokhwa-decoder/Cargo.toml create mode 100644 nokhwa-decoder/src/lib.rs diff --git a/Cargo.toml b/Cargo.toml index 49088a7..dc98b81 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ exclude = ["examples/jscam"] crate-type = ["cdylib", "rlib"] [features] -default = ["flume", "decoding"] +default = ["decoding"] serialize = ["serde", "nokhwa-core/serialize"] decoding = ["nokhwa-core/mjpeg"] input-avfoundation = ["nokhwa-bindings-macos"] @@ -48,6 +48,7 @@ test-fail-warning = [] [dependencies] thiserror = "1.0" paste = "1.0" +flume = "0.11" [dependencies.nokhwa-core] version = "0.1" @@ -57,10 +58,6 @@ path = "nokhwa-core" version = "1.0" optional = true -[dependencies.flume] -version = "0.11" -optional = true - [dependencies.image] version = "0.25" default-features = false diff --git a/examples/captesting/Cargo.toml b/examples/captesting/Cargo.toml new file mode 100644 index 0000000..7bf5b00 --- /dev/null +++ b/examples/captesting/Cargo.toml @@ -0,0 +1,14 @@ +[package] +name = "captesting" +version = "0.1.0" +edition = "2021" + +[dependencies] + +[dependencies.image] +version = "0.25" + +[dependencies.nokhwa] +path = "../.." +# EDIT THIS! +features = ["input-native"] diff --git a/examples/captesting/src/main.rs b/examples/captesting/src/main.rs new file mode 100644 index 0000000..29004fe --- /dev/null +++ b/examples/captesting/src/main.rs @@ -0,0 +1,15 @@ +use nokhwa::Camera; +use nokhwa::pixel_format::RgbFormat; +use nokhwa::utils::{CameraIndex, RequestedFormat, RequestedFormatType}; + +fn main() { + let index: CameraIndex = CameraIndex::Index(50); + let requested: RequestedFormat<'_> = RequestedFormat::new::(RequestedFormatType::AbsoluteHighestResolution); + let mut camera = Camera::new(index, requested).unwrap(); + println!("{}", camera.camera_format()); + camera.open_stream().unwrap(); + let frame = camera.frame().unwrap(); + camera.stop_stream().unwrap(); + let decoded = frame.decode_image::().unwrap(); + decoded.save_with_format("turtle.jpeg", image::ImageFormat::Jpeg).unwrap() +} diff --git a/nokhwa-decoder/Cargo.toml b/nokhwa-decoder/Cargo.toml new file mode 100644 index 0000000..c828313 --- /dev/null +++ b/nokhwa-decoder/Cargo.toml @@ -0,0 +1,22 @@ +[package] +name = "nokhwa-decoder" +version = "0.1.0" +edition = "2021" + +[dependencies] + +[dependencies.nokhwa-core] +version = "0.2" +path = "../nokhwa-core" + +[dependencies.dcv-color-primitives] +version = "0.6" +optional = true + +[dependencies.yuvutils-rs] +version = "0.5" +optional = true + +[dependencies.mozjpeg] +version = "0.10" +optional = true diff --git a/nokhwa-decoder/src/lib.rs b/nokhwa-decoder/src/lib.rs new file mode 100644 index 0000000..b93cf3f --- /dev/null +++ b/nokhwa-decoder/src/lib.rs @@ -0,0 +1,14 @@ +pub fn add(left: u64, right: u64) -> u64 { + left + right +} + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn it_works() { + let result = add(2, 2); + assert_eq!(result, 4); + } +}