diff --git a/.idea/nokhwa.iml b/.idea/nokhwa.iml index 37b508e..30d2d88 100644 --- a/.idea/nokhwa.iml +++ b/.idea/nokhwa.iml @@ -24,6 +24,8 @@ + + diff --git a/Cargo.toml b/Cargo.toml index 2fb4668..cd857bb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -15,7 +15,7 @@ input_uvc = ["uvc"] input_opencv = ["opencv", "opencv/clang-runtime"] input_msmf = ["windows"] input_v4l = ["v4l"] -input_ffmpeg = ["rusty_ffmpeg"] +input_ffmpeg = ["ffav"] input_gstreamer = ["gstreamer"] [dependencies] @@ -28,15 +28,15 @@ version = "0.53.0" optional = true [dependencies.v4l] -version = "0.12.0" +version = "0.12.1" optional = true [dependencies.uvc] version = "0.2.0" optional = true -[dependencies.rusty_ffmpeg] -version = "0.7.0" +[dependencies.ffav] +version = "4.3.12" optional = true [dependencies.gstreamer] diff --git a/src/backends/capture/mod.rs b/src/backends/capture/mod.rs new file mode 100644 index 0000000..c033e8f --- /dev/null +++ b/src/backends/capture/mod.rs @@ -0,0 +1,2 @@ +#[cfg(feature = "input_v4l")] +pub mod v4l_capture; \ No newline at end of file diff --git a/src/backends/capture/v4l_capture.rs b/src/backends/capture/v4l_capture.rs new file mode 100644 index 0000000..1059b13 --- /dev/null +++ b/src/backends/capture/v4l_capture.rs @@ -0,0 +1,10 @@ +use crate::utils::CameraFormat; + +pub struct V4LCaptureDevice<'a> { + camera_format: CameraFormat, + +} + +impl V4LCaptureDevice { + +} diff --git a/src/backends/mod.rs b/src/backends/mod.rs index e69de29..5b6da50 100644 --- a/src/backends/mod.rs +++ b/src/backends/mod.rs @@ -0,0 +1 @@ +pub mod capture; \ No newline at end of file diff --git a/src/camera.rs b/src/camera.rs new file mode 100644 index 0000000..bf8867c --- /dev/null +++ b/src/camera.rs @@ -0,0 +1,3 @@ +pub struct CaptureCamera { + +} \ No newline at end of file diff --git a/src/traits.rs b/src/camera_traits.rs similarity index 100% rename from src/traits.rs rename to src/camera_traits.rs diff --git a/src/error.rs b/src/error.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/lib.rs b/src/lib.rs index b19b4c8..3a81d50 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,10 @@ #![deny(clippy::pedantic)] +#![warn(clippy::all)] #![allow(clippy::upper_case_acronyms)] -mod traits; +mod camera_traits; pub mod backends; -mod utils; \ No newline at end of file +mod utils; +mod camera; +mod error; +mod query; \ No newline at end of file diff --git a/src/query.rs b/src/query.rs new file mode 100644 index 0000000..e69de29 diff --git a/src/utils.rs b/src/utils.rs index f5483f0..9001f7e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,10 +1,10 @@ use std::fmt::Display; use std::cmp::Ordering; -#[derive(Copy, Clone, Debug, PartialEq)] +#[derive(Copy, Clone, Debug, PartialEq, Hash)] pub enum FrameFormat { - MJPEG = 0, - YUYV = 1, + MJPEG, + YUYV, } #[derive(Copy, Clone, Debug, Eq, PartialEq, Hash)] @@ -40,7 +40,7 @@ impl Resolution { impl Display for Resolution { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}x{}", self.x, self.y) + write!(f, "{}x{}", self.x(), self.y()) } } @@ -54,15 +54,15 @@ impl Ord for Resolution { // Flip around the order to make it seem the way the user would expect. // The user would expect a descending list of resolutions (aka highest -> lowest) fn cmp(&self, other: &Self) -> Ordering { - match self.x.cmp(&other.x) { + match self.x().cmp(&other.x()) { Ordering::Less => Ordering::Less, - Ordering::Equal => self.y.cmp(&other.y), + Ordering::Equal => self.y().cmp(&other.y()), Ordering::Greater => Ordering::Greater, } } } -#[derive(Copy, Clone, Debug, Hash, Eq, PartialEq)] +#[derive(Copy, Clone, Debug, Hash, PartialEq)] pub struct CameraFormat { resolution: Resolution, format: FrameFormat, @@ -93,11 +93,11 @@ impl CameraFormat { self.resolution } - pub fn width(&self) -> Resolution { + pub fn width(&self) -> u32 { self.resolution.width() } - pub fn height(&self) -> Resolution { + pub fn height(&self) -> u32 { self.resolution.height() } @@ -108,4 +108,14 @@ impl CameraFormat { pub fn framerate(&self) -> u32 { self.framerate } -} \ No newline at end of file +} + +#[derive(Clone, Copy, Debug, PartialEq)] +pub enum CaptureAPIBackend { + AUTO, + V4L2, + UVC, + MSMF, + OPENCV, + FFMPEG, +}