EVAx10_Video_analitics/ARCHITECTURE.md

48 lines
2.7 KiB
Markdown

# Edge Vision v0.1 architecture
`VideoSource` emits immutable bitmap frames and camera metrics. Camera2
consumes latest YUV frames on its own looper, samples preview frames and
rotates by the sensor orientation. It preserves the negotiated source
resolution in metrics and downsamples the analysis image to at most 640
pixels wide. RTSP, USB and file sources can implement the same interface.
The test-image source is available for deterministic local smoke tests.
`InferenceEngine` exposes providers, reusable model sessions, named tensor
execution and runtime metrics. `OrtEngine` verifies manifest size and
SHA-256, validates the ONNX session against declared input and outputs and
profiles first-run node assignment. Accelerator selection and actual node
placement are shown separately. The owner serializes all use and release of
ORT sessions on one worker. A future RKNN implementation can implement
this interface without camera or analytics changes.
Adapters convert pixels and decode outputs independently of the source.
YuNet implements face detection. Two Cydral ONNX sessions produce the
age distribution and classification probabilities independently. Adapter types are explicit
in the model manifest. Compatible weights can be replaced independently after license review and a new build.
A new tensor contract requires an adapter.
The worker admits at most one frame at a time. Busy, interval and
preview-sampling skips are counted. Camera HAL losses are unavailable.
The UI consumes the latest preview and normalized face boxes. Camera
permission and lifecycle are owned by the separate native APK. Inference
results from stopped generations are discarded.
The tracker uses geometry and temporary in-memory IDs. After two
observations, a new track can be matched against recent visits by comparing
normalized SFace embeddings. YuNet landmarks align the face crop, and pose,
size and sharpness checks reject poor samples. At most three pose templates
are retained per visit and up to 256 visits live in memory. A repeat requires
two confident matches to the same inactive visit, separated in time and
ahead of the runner-up. Unknown matches are resolved as new visits after
a short delay. A repeat never updates aggregate demographics.
The repeat window starts from last appearance. Stop, restart and Reset
Statistics clear the templates. The aggregator stores totals and buckets
in private preferences. Benchmark export stores only counters and timing.
The on-screen tracking log holds up to four recent decisions in memory.
Model selection, provider, interval, threads and confidence are kept in an
independent session configuration. Digital DNA can map declarative fields
to that configuration in a later version. The current APK has no network
permission.