Skip to content

Commit be9125c

Browse files
committed
Document detect module + live-video detection benchmark in README
1 parent 9318bad commit be9125c

1 file changed

Lines changed: 31 additions & 0 deletions

File tree

README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,37 @@ assert_eq!(decoded.text().as_deref(), Some("HELLO WORLD"));
114114
assert_eq!(encoder.encode(&decoded).unwrap(), encoding);
115115
```
116116

117+
## Live-video detection & performance
118+
119+
For a camera feed you rarely want to fully decode every frame. The `detect` module
120+
provides a fast, symbology-agnostic **locator** that returns the *position* of every
121+
code (a bounding quad + coarse family guess) in a single downscaled pass, **without
122+
decoding** — the cheap stage of the two-stage `Detect``Analyze` pipeline:
123+
124+
```rust
125+
use anyd::detect::{locate, LocateOptions};
126+
127+
let candidates = locate(&frame, &LocateOptions::default());
128+
for c in &candidates {
129+
// c.location — where the code is; c.symbology — family guess.
130+
// Hand off to the matching sampler/decoder only for new regions.
131+
}
132+
```
133+
134+
Benchmark (`cargo bench --bench detect`, dependency-free, `std::time::Instant`),
135+
locating **all** codes of all families per frame vs. a full QR decode:
136+
137+
| resolution | locate median | locate FPS | full-decode FPS | detect speedup |
138+
|-----------:|--------------:|-----------:|----------------:|---------------:|
139+
| 640×480 | 0.30 ms | ~3350 | ~1725 | 1.9× |
140+
| 1280×720 | 0.83 ms | ~1200 | ~635 | 1.9× |
141+
| 1920×1080 | 1.85 ms | ~545 | ~310 | 1.8× |
142+
143+
Recall 100% and false-positive rate 0% on the benchmark's planted-code frames.
144+
Locating is comfortably real-time at every resolution; decoding then runs only on the
145+
regions the locator hands off (and `Hints` lets already-decoded codes be skipped
146+
across frames).
147+
117148
## Command-line tool (`anyd`)
118149

119150
An optional binary is bundled behind the **`cli`** feature, so the library itself

0 commit comments

Comments
 (0)