opencv_rs/lib.rs
1//! Hexagonal Rust wrapper over OpenCV primitives.
2//!
3//! Convenience facade re-exporting the ports defined in
4//! `opencv-rs-core`. When the `opencv` feature is enabled, the production
5//! adapters from `opencv-rs-ffi` are also re-exported.
6//!
7//! ```text
8//! opencv-rs-core ← traits + DTOs, zero FFI
9//! ↑
10//! ├── opencv-rs-fake ← deterministic in-memory impls for tests
11//! └── opencv-rs-ffi ← production impls wrapping the `opencv` crate
12//! ↑
13//! opencv-rs ← this facade
14//! ```
15//!
16//! End users should depend on this crate. Downstream tests depend on
17//! `opencv-rs-fake` as a dev-dependency.
18
19pub use opencv_rs_core as core;
20
21pub use opencv_rs_core::{
22 Backend, CapturedFrame, ColorConversion, EncodingKind, ImageEncoderPort, ImageEncodingError,
23 ImageOpsError, ImageOpsPort, MatView, MinMaxResult, OpenCvError, OwnedMatView, PixelFormat,
24 PureRustImageOps, Result, ThresholdKind, VideoCaptureError, VideoCapturePort, VideoStream,
25};
26
27#[cfg(feature = "opencv")]
28pub use opencv_rs_ffi as ffi;
29
30/// Production [`VideoCapturePort`] implementation backed by the `opencv` crate.
31#[cfg(feature = "opencv")]
32pub type RealVideoCapture = opencv_rs_ffi::OpenCvVideoCapture;
33
34/// Production [`ImageEncoderPort`] implementation backed by the `opencv` crate.
35#[cfg(feature = "opencv")]
36pub type RealImageEncoder = opencv_rs_ffi::OpenCvImageEncoder;
37
38/// Production [`ImageOpsPort`] implementation backed by the `opencv` crate.
39#[cfg(feature = "opencv")]
40pub type RealImageOps = opencv_rs_ffi::OpenCvImageOps;
41
42#[cfg(test)]
43mod tests {
44 use super::*;
45 use opencv_rs_fake::ScriptedVideoCapture;
46
47 #[test]
48 fn facade_types_compose() {
49 let capture = ScriptedVideoCapture::new();
50 let _port: &dyn VideoCapturePort = &capture;
51 }
52}