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 calibration;
22pub mod dataset;
23pub mod distributed;
24pub mod error;
25pub mod evaluate;
26pub mod lrp;
27pub mod lvis_parity;
28pub mod manifest;
29pub mod manifest_csv;
30pub mod matching;
31pub mod parity;
32pub mod partition;
33pub mod segmentation;
34pub mod similarity;
35pub mod stream;
36pub mod summarize;
37pub mod tables;
38pub mod tide;
39
40// Each item lives at exactly one path — its home module. Adding a
41// re-export here widens the headline; treat it as a deliberate
42// decision keyed to the README minimal-usage example, not a default
43// for new pub items.
44pub use accumulate::Accumulated;
45pub use dataset::{CocoDataset, CocoDetections, EvalDataset};
46pub use error::EvalError;
47pub use evaluate::{
48 evaluate_bbox, evaluate_boundary, evaluate_keypoints, evaluate_segm, evaluate_with, AreaRange,
49 EvalGrid, EvaluateParams,
50};
51pub use parity::ParityMode;
52pub use summarize::Summary;
53
54/// Library version string. Useful for parity tracing in fixtures and for
55/// debugging mismatches between Rust and Python sides of the FFI boundary.
56pub const VERSION: &str = env!("CARGO_PKG_VERSION");
57
58/// Stage-0 instrumentation hook for the bbox-IoU optimization plan.
59///
60/// Writes the `(kind, g, d, wall_ns)` records accumulated across every
61/// `BboxIou::compute` and `BboxIou::compute_overlap_mask` call to
62/// `path` as CSV (header `kind,g,d,wall_ns`; `kind` is the variant
63/// label `FullIou` or `OverlapMask`), then clears the in-process
64/// buffer. Returns the number of records written.
65///
66/// Only present when the crate is compiled with `--features
67/// bench-histogram`. Bench harness builds set this; the shipped wheel
68/// never does, so production runs carry zero recording overhead.
69#[cfg(feature = "bench-histogram")]
70pub fn dump_bbox_iou_histogram_csv(path: &std::path::Path) -> std::io::Result<usize> {
71 similarity::bbox::histogram::dump_csv(path)
72}
73
74#[cfg(test)]
75mod tests {
76 use super::*;
77
78 #[test]
79 fn version_is_set() {
80 assert!(!VERSION.is_empty());
81 }
82}