vernier_core/lib.rs
1//! Pure-Rust core for vernier.
2//!
3//! This crate has **no Python dependencies** and is usable directly from Rust
4//! binaries, CLI tools, and embedded contexts.
5//!
6//! By design, the public API of this crate is the source of truth for vernier's
7//! evaluation semantics. The `vernier-ffi` crate is a thin data-conversion
8//! layer over this one; if you find yourself adding logic to `vernier-ffi`
9//! rather than here, that's a code smell worth resolving.
10//!
11//! See the project's `docs/explanation/` for the architecture overview and
12//! `docs/adr/` for the design decisions that shaped this crate.
13
14#![forbid(unsafe_code)]
15#![warn(missing_docs)]
16#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used, clippy::panic))]
17
18pub mod accumulate;
19pub mod boundary_parity;
20pub mod breakdown;
21pub mod dataset;
22pub mod distributed;
23pub mod error;
24pub mod evaluate;
25pub mod lvis_parity;
26pub mod matching;
27pub mod parity;
28pub mod segmentation;
29pub mod similarity;
30pub mod stream;
31pub mod summarize;
32pub mod tables;
33pub mod tide;
34
35// Each item lives at exactly one path — its home module. Adding a
36// re-export here widens the headline; treat it as a deliberate
37// decision keyed to the README minimal-usage example, not a default
38// for new pub items.
39pub use accumulate::Accumulated;
40pub use dataset::{CocoDataset, CocoDetections, EvalDataset};
41pub use error::EvalError;
42pub use evaluate::{
43 evaluate_bbox, evaluate_boundary, evaluate_keypoints, evaluate_segm, evaluate_with, AreaRange,
44 EvalGrid, EvaluateParams,
45};
46pub use parity::ParityMode;
47pub use summarize::Summary;
48
49/// Library version string. Useful for parity tracing in fixtures and for
50/// debugging mismatches between Rust and Python sides of the FFI boundary.
51pub const VERSION: &str = env!("CARGO_PKG_VERSION");
52
53/// Stage-0 instrumentation hook for the bbox-IoU optimization plan.
54///
55/// Writes the `(kind, g, d, wall_ns)` records accumulated across every
56/// `BboxIou::compute` and `BboxIou::compute_overlap_mask` call to
57/// `path` as CSV (header `kind,g,d,wall_ns`; `kind` is the variant
58/// label `FullIou` or `OverlapMask`), then clears the in-process
59/// buffer. Returns the number of records written.
60///
61/// Only present when the crate is compiled with `--features
62/// bench-histogram`. Bench harness builds set this; the shipped wheel
63/// never does, so production runs carry zero recording overhead.
64#[cfg(feature = "bench-histogram")]
65pub fn dump_bbox_iou_histogram_csv(path: &std::path::Path) -> std::io::Result<usize> {
66 similarity::bbox::histogram::dump_csv(path)
67}
68
69#[cfg(test)]
70mod tests {
71 use super::*;
72
73 #[test]
74 fn version_is_set() {
75 assert!(!VERSION.is_empty());
76 }
77}