opencv-rs-fake 0.1.1

In-memory opencv-rs port implementations for unit testing
Documentation
  • Coverage
  • 100%
    18 out of 18 items documented0 out of 14 items with examples
  • Size
  • Source code size: 26.4 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 2.75 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 42s Average build duration of successful builds.
  • all releases: 52s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • GoCleverOrg/opencv-rs
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • vasco

opencv-rs-fake

Scripted in-memory implementations of every opencv-rs-core port, for use as a dev-dependency in code that depends on the ports.

These fakes let tests script deterministic frame sequences, inject errors at specific call sites, and record invocations for later assertion — without linking against the opencv crate. This crate depends only on opencv-rs-core; it must never depend on opencv-rs-ffi or on opencv.

Types

  • ScriptedVideoCapture / ScriptedVideoStream
  • ScriptedImageEncoder
  • PassthroughImageOps

Example

use opencv_rs_core::{Backend, CapturedFrame, PixelFormat, VideoCapturePort};
use opencv_rs_fake::ScriptedVideoCapture;
use std::path::Path;
use std::sync::Arc;

let frames = vec![
    CapturedFrame {
        width: 1,
        height: 1,
        pixel_format: PixelFormat::Bgr8,
        data: Arc::from([0u8, 0, 255].as_slice()),
    },
    CapturedFrame {
        width: 1,
        height: 1,
        pixel_format: PixelFormat::Bgr8,
        data: Arc::from([255u8, 0, 0].as_slice()),
    },
];

let capture = ScriptedVideoCapture::with_frames(frames);
let mut stream = capture.open(Path::new("ignored"), Backend::Auto).unwrap();

assert!(stream.read_frame().is_ok());
assert!(stream.read_frame().is_ok());
assert!(stream.read_frame().is_err()); // EndOfStream

License

MIT OR Apache-2.0.