Pure Rust port of OpenCV's core and imgproc modules. Memory-safe, zero-FFI,
high-performance. See .agents/instructions.md for the full architectural mandate.
- Zero-FFI: No
bindgen,cc, or C++ linking. Every algorithm must be rewritten in idiomatic Rust. - Memory Safety: Use Rust's ownership model. Prefer
Vec<T>orBox<[T]>for buffers. Avoidunsafe— if you must use it, justify whypulporstd::archis required and why safe iterators failed. - Data Layout: Row-major contiguous memory (
Matrix<T>) matchingcv::Mat. - Concurrency: Use Rayon (
parallelfeature) for pixel-parallel tasks; always provide a sequential fallback. - SIMD: Use
pulp(simdfeature) for manual SIMD. Prefer.chunks_exact(n)over.chunks(n)for LLVM auto-vectorization. - OpenCV Parity: Match OpenCV default border types and naming (e.g.
cvt_colornotconvert_color). - Error handling: Use
Result<T, PureCvError>— neverpanic!in library code.
cargo fmt
cargo clippy # fix ALL warnings
cargo test # all unit + doc tests must passCI rejects any PR that fails cargo fmt --check or cargo clippy.
Every new Rust source file must start with the LGPL-3.0 license header.
Template: .agents/skills/license-header-adder/resources/HEADER.txt
Replace {{FILENAME}} with the actual filename.
Format: <type>(<scope>): <description>
| Type | When |
|---|---|
feat |
new feature or algorithm |
fix |
bug fix |
perf |
performance improvement |
doc |
documentation only |
refactor |
neither fix nor feature |
test |
adding or fixing tests |
chore |
build, deps, tooling |
Preferred scopes: (core) (imgproc) (simd) (wasm) (parallel)
- PRs start from and target the
devbranch (notmain). - Keep PRs focused; one feature or fix per PR.
Each top-level module (core/, imgproc/, features2d/, etc.) must contain its own:
tests.rs— unit tests for that module (#[cfg(test)] mod tests;)simd.rs— SIMD-accelerated helpers specific to that module (pub(crate) mod simd;)
Keep SIMD kernels co-located with the module that uses them. The core SimdElement
trait and element-wise operations stay in src/core/simd.rs; domain-specific kernels
(e.g. color conversion, derivatives) belong in their respective module's simd.rs.
src/core/ — Matrix<T>, Scalar, arithmetic, stats, linear algebra
src/imgproc/ — color conversion, filtering, edge detection, threshold
crates/wasm/ — wasm-bindgen wrappers and wasm-pack build
benches/ — Criterion benchmarks
.agents/ — reference docs, roadmap, skills (shared with other agents)
Matrix<T>— main n-channel image/matrix typeScalar<T>— 4-channel per-pixel constant (channels beyond 4 default toT::default())MatType/Depth— OpenCV-style type constants (CV_8UC3,CV_32FC1, …)PureCvError— library error type; useResult<T, PureCvError>everywhere
- SIMD + Parallel benchmarks target 1024×1024 matrices.
- Full benchmark results:
benches/benchmark_results.md. - Best speedup achieved: 22× (
sobel_3x3_f32with Parallel + SIMD).