Illustrated C/C++ source sheets, symbol index, API relationship graph, compiler console and debug trace

LIVE AI / FLEXIBLE SENSING / FLIGHT CONTEXT

Sensoraia API

Live AI and sensing, connected to the flight.
See, listen, inspect and return supported results while airborne.

Loading...
Searching...
No Matches
ear_inference.h
Go to the documentation of this file.
1/*
2 * Copyright 2026 OpenUAS
3 * SPDX-License-Identifier: Apache-2.0
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18/** @file ear_inference.h
19 * @brief Bounded PCM classification without allowing model latency to stall ALSA capture. */
20#ifndef SENSORAIA_EAR_INFERENCE_H
21#define SENSORAIA_EAR_INFERENCE_H
22
23#include <stdbool.h>
24#include <stddef.h>
25#include <stdint.h>
26
27/** @brief One classified audio window; probability and measured level are different evidence. */
30 double level_dbfs, score; /**< PCM RMS level and selected model probability, respectively. */
31 unsigned category;
33};
34
35/** @brief Select the explicit detector and qualify an ONNX PCM contract before capture starts.
36 * @param settings EARcam application settings path.
37 * @param rate Exact capture sample rate; no implicit resampling is performed.
38 * @param enabled Set true for ONNX, false for a successfully selected native detector.
39 * @param error Writable failure diagnostic.
40 * @param capacity Available bytes in error.
41 * @return True for an accepted native or ONNX selection; false never means native fallback.
42 * @pre No inference thread or previously configured model is active. */
43bool ear_inference_configure(const char *settings, unsigned rate, bool *enabled,
44 char *error, size_t capacity);
45/** @brief Start the sole classifier thread after successful ONNX configuration.
46 * @param error Writable failure diagnostic.
47 * @param capacity Available bytes in error.
48 * @return True after thread creation, not proof of a classified acoustic event. */
49bool ear_inference_start(char *error, size_t capacity);
50/** @brief Supply capture samples without waiting for model execution or a busy model mailbox.
51 * @param samples Borrowed signed mono PCM; no pointer survives this call.
52 * @param count Number of samples in this continuous capture chunk.
53 * @param end_us Capture end of the chunk in CLOCK_MONOTONIC microseconds, or zero when unknown.
54 * @param error_us Bound on capture-window timing uncertainty, not inference duration.
55 * @details Complete windows may replace pending work; overload loses evidence rather than blocking ALSA.
56 * @pre One capture producer owns push/discontinuity calls until stop begins. */
57void ear_inference_push(const int16_t *samples, size_t count, uint64_t end_us, uint64_t error_us);
58/** @brief Consume at most one completed original-window result without blocking capture.
59 * @param result Writable destination, unchanged when no result is available.
60 * @return True for a newly consumed completion; its window time is not its inference completion time. */
62/** @brief Invalidate queued/completed evidence after capture continuity breaks, including in-flight generations. */
64/** @brief Request termination, join the classifier and release its model; repeat calls are harmless.
65 * @pre The capture producer has stopped supplying new chunks. */
66void ear_inference_stop(void);
67/** @brief Classify exact whole windows from a regular little-endian signed-16 mono PCM file.
68 * @param filename Immutable replay input; no hardware or simulated exposure timing is invented.
69 * @return Zero after complete replay, otherwise one for invalid input or model failure.
70 * @pre The model is configured but its capture worker is not running. */
71int ear_inference_file(const char *filename);
72
73#endif
static unsigned capacity[COVERAGE_CAMERAS]
static bool enabled(void)
Report explicit opt-in independently of process or model readiness.
static struct ear_sample samples[EAR_MAX_SAMPLES]
void ear_inference_stop(void)
Request termination, join the classifier and release its model; repeat calls are harmless.
bool ear_inference_start(char *error, size_t capacity)
Start the sole classifier thread after successful ONNX configuration.
bool ear_inference_take(struct ear_inference_result *result)
Consume at most one completed original-window result without blocking capture.
int ear_inference_file(const char *filename)
Classify exact whole windows from a regular little-endian signed-16 mono PCM file.
bool ear_inference_configure(const char *settings, unsigned rate, bool *enabled, char *error, size_t capacity)
Select the explicit detector and qualify an ONNX PCM contract before capture starts.
void ear_inference_push(const int16_t *samples, size_t count, uint64_t end_us, uint64_t error_us)
Supply capture samples without waiting for model execution or a busy model mailbox.
void ear_inference_discontinuity(void)
Invalidate queued/completed evidence after capture continuity breaks, including in-flight generations...
struct jpeg_error_mgr error
Definition lwir_image.c:60
static size_t count
Definition pose_log.c:79
One classified audio window; probability and measured level are different evidence.
struct usher_control_result result
Definition usher.c:377