Packages
bb_inference_opencv
0.1.0
A BB.Inference runtime that runs ONNX models through OpenCV's DNN module, via evision.
Current section
Files
Jump to
Current section
Files
bb_inference_opencv
usage-rules.md
usage-rules.md
<!--
SPDX-FileCopyrightText: 2026 James Harton
SPDX-License-Identifier: Apache-2.0
-->
# BB.Inference.OpenCV Usage Rules
`bb_inference_opencv` is a runtime for [`bb_inference`](https://hexdocs.pm/bb_inference).
See `bb_inference`'s rules for models, codecs and components; this file
covers only what is specific here.
## Core principles
1. **Name it as a model's `runtime`,** never call it directly from a
component. Components go through `BB.Inference.infer/4`.
2. **It passes raw tensors.** Inputs must already be in the model's types;
outputs come back in theirs.
3. **`describe/1` is partial.** Check `can?/1` before relying on a field.
## Wiring it in
```elixir
model :detector do
runtime BB.Inference.OpenCV
source "https://example.com/model"
sha256 "..."
codec MyCodec
end
```
## Anti-patterns
- **Relying on quantisation or layout from `describe/1`** where `can?/1`
says it isn't reported.
- **Converting tensors in the runtime.** Codecs do that, cheaply.
## Further reading
- [Hexdocs](https://hexdocs.pm/bb_inference_opencv)
- `BB.Inference.OpenCV`, `BB.Inference.Runtime`