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
camera_backend_registry.c
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/**
19 * @file camera_backend_registry.c
20 * @brief Shared backend catalogue; the service schedules capabilities, not devices.
21 * @details Descriptor lookup is side-effect free. Specialized backends own their
22 * hooks; simple adapters share this table. Profiles never allocate protocol IDs.
23 */
25#include "ai_cam_pipe.h"
26#include "chdk_camera_backend.h"
27#include "local_pipe.h"
28#include "loom_camera_backend.h"
29#include "lwir_cam_pipe.h"
31#include "spotter_cam_pipe.h"
33
34#include "ear_camera_backend.h"
36#ifndef USHER_SODA
37 #define USHER_SODA "./bin/soda"
38#endif
39#ifndef USHER_AI_CAM_PHOTO_DIR
40 #define USHER_AI_CAM_PHOTO_DIR "~/Pictures/sensoraia"
41#endif
42#ifndef USHER_LWIR_CAM_PHOTO_DIR
43 #define USHER_LWIR_CAM_PHOTO_DIR "~/Pictures/sensoraia"
44#endif
45#ifndef USHER_SPOTTERCAM_PHOTO_DIR
46 #define USHER_SPOTTERCAM_PHOTO_DIR "~/Pictures/sensoraia"
47#endif
48
50{
51 if (type == CAMERA_BACKEND_CHDK) return chdk_camera_backend_get();
56 static const struct camera_backend backends[CAMERA_BACKEND_COUNT] = {
58 .name = "local", .init = local_pipe_init, .deinit = local_pipe_deinit,
59 .soda_application = USHER_SODA, .camera_id = USHER_CAMERA_ALL,
60 .capabilities = CAMERA_CAP_IMAGE | CAMERA_CAP_MOCK
61 },
63 .name = "aicam", .init = ai_cam_pipe_init, .shoot = ai_cam_pipe_shoot,
64 .deinit = ai_cam_pipe_deinit, .soda_application = USHER_SODA,
65 .configure = ai_cam_pipe_configure,
66 .camera_id = USHER_CAMERA_AICAM, .prefix = 'a', .capabilities = CAMERA_CAP_IMAGE | CAMERA_CAP_PRIVATE_IMAGE,
67 .mock = {.width = 2028, .height = 1520, .filename_marker = "m"},
68 .soda_option = "--aicam", .photo_directory = USHER_AI_CAM_PHOTO_DIR
69 },
71 .name = "spottercam", .init = spotter_cam_pipe_init,
72 .shoot = spotter_cam_pipe_shoot, .deinit = spotter_cam_pipe_deinit, .soda_application = USHER_SODA,
73 .configure = spotter_cam_pipe_configure,
74 .camera_id = USHER_CAMERA_AICAM, .prefix = 'a',
75 .mock = {.width = 2028, .height = 1520, .filename_marker = "m"},
76 .capabilities = CAMERA_CAP_IMAGE | CAMERA_CAP_DETECTION | CAMERA_CAP_FINISH_OWNED | CAMERA_CAP_PRIVATE_IMAGE, .soda_option = "--aicam",
78 .save_detection_copy = spotter_cam_pipe_save_detection_copy, .photo_directory = USHER_SPOTTERCAM_PHOTO_DIR
79 },
81 .name = "lwircam", .init = lwir_cam_pipe_init, .shoot = lwir_cam_pipe_shoot,
82 .configure = lwir_cam_pipe_configure,
83 .deinit = lwir_cam_pipe_deinit, .soda_application = USHER_SODA, .camera_id = USHER_CAMERA_LWIRCAM,
84 .prefix = 'l', .capabilities = CAMERA_CAP_IMAGE | CAMERA_CAP_FINISH_OWNED |
87 .mock = {.width = 256, .height = 192, .filename_marker = "m"},
88 #endif
89 .soda_option = "--lwircam", .init_cancelable = lwir_cam_pipe_init_cancelable,
90 .capture_delay = lwir_cam_pipe_capture_delay, .capture_timing = lwir_cam_pipe_capture_timing,
91 #if LWIR_ENABLE_ANALYSIS
92 .geolocate = lwir_cam_pipe_geolocate,
93 #endif
94 .photo_directory = USHER_LWIR_CAM_PHOTO_DIR
95 },
96 };
97 if (type <= CAMERA_BACKEND_UNSELECTED || type >= CAMERA_BACKEND_COUNT) return (struct camera_backend) {0};
98 struct camera_backend backend = backends[type];
99 if (type == CAMERA_BACKEND_AI_CAM && ai_cam_pipe_native()) backend.soda_application = NULL;
100 return backend;
101}
102
104 bool local_only)
105{
107 const struct camera_backend selected = camera_backend_registry_get(preferred, false);
108 if (selected.name && selected.camera_id == camera_id)
109 return local_only && (selected.capabilities & CAMERA_CAP_IMAGE) ? CAMERA_BACKEND_LOCAL : preferred;
110 for (enum camera_backend_type type = CAMERA_BACKEND_CHDK; type < CAMERA_BACKEND_COUNT; ++type) {
111 const struct camera_backend backend = camera_backend_registry_get(type, false);
112 if (!backend.name || backend.camera_id != camera_id) continue;
113 return local_only && (backend.capabilities & CAMERA_CAP_IMAGE) ? CAMERA_BACKEND_LOCAL : type;
114 }
116}
117
int ai_cam_pipe_init(const char *unused)
Validate storage and start the selected camera owner.
int ai_cam_pipe_shoot(char *filename, size_t filename_size, int image_number)
Capture one ordinary JPEG into private staging for metadata completion.
#define USHER_AI_CAM_PHOTO_DIR
Definition ai_cam_pipe.c:54
void ai_cam_pipe_configure(const struct camera_backend_host *host)
Pass the shutdown flag to native worker supervision.
void ai_cam_pipe_deinit(void)
Stop the native and system-camera subprocesses.
bool ai_cam_pipe_native(void)
Report whether the selected AIcam mode uses native photo-only capture.
Parent-side contract for stock and native Raspberry Pi camera capture.
@ CAMERA_CAP_MOCK
@ CAMERA_CAP_GEOLOCATION
@ CAMERA_CAP_FINISH_OWNED
@ CAMERA_CAP_IMAGE
@ CAMERA_CAP_PRIVATE_IMAGE
@ CAMERA_CAP_DETECTION
@ CAMERA_BACKEND_MAX_ID
#define USHER_SODA
#define USHER_SPOTTERCAM_PHOTO_DIR
#define USHER_LWIR_CAM_PHOTO_DIR
struct camera_backend camera_backend_registry_identity(int camera_id, enum camera_backend_type preferred, bool mock)
Resolve naming/metadata identity from the profile used for acquisition.
struct camera_backend camera_backend_registry_get(enum camera_backend_type type, bool mock)
Return a descriptor without selecting, configuring or opening hardware.
enum camera_backend_type camera_backend_registry_route(int camera_id, enum camera_backend_type preferred, bool local_only)
Resolve a physical ID, preferring its configured logical profile.
Backend definitions and physical-camera routing.
@ CAMERA_BACKEND_LOCAL
@ CAMERA_BACKEND_CHDK
@ CAMERA_BACKEND_COUNT
@ CAMERA_BACKEND_AI_CAM
@ CAMERA_BACKEND_UNSELECTED
@ CAMERA_BACKEND_LOOM_CAM
@ CAMERA_BACKEND_LWIR_CAM
@ CAMERA_BACKEND_DIPLA_CAM
@ CAMERA_BACKEND_SPOTTER_CAM
@ CAMERA_BACKEND_EAR_CAM
struct camera_backend chdk_camera_backend_get(void)
CHDK-owned download and photo publication.
struct camera_backend dipla_camera_backend_get(void)
Describe camera slot five without starting work.
Optional non-image camera adapter for the native Diplacam worker.
struct camera_backend ear_camera_backend_get(void)
Return the EAR backend descriptor by value; its session hook table has static lifetime.
EAR-specific startup configuration behind USHER's generic backend interface.
void local_pipe_deinit(void)
Forget selected local fixture sources.
Definition local_pipe.c:295
int local_pipe_init(const char *mock_image)
Initialize a deterministic mock image source for local camera simulation.
Definition local_pipe.c:64
Local mock-camera backend API for simulator and desk testing.
struct camera_backend loom_camera_backend_get(bool mock)
Return LOOM's descriptor without opening a sensor or starting a thread.
LOOM-owned capture specialization and stream lifecycle.
int lwir_cam_pipe_shoot(char *filename, size_t filename_size, int image_number)
Request one thermal JPEG from an initialized capture server.
int lwir_cam_pipe_init_cancelable(const char *unused, const volatile sig_atomic_t *keep_running)
Start the server but abort promptly when USHER begins shutdown.
double lwir_cam_pipe_capture_delay(void)
Return the delay of the last successful capture request in seconds.
struct capture_timing lwir_cam_pipe_capture_timing(void)
Return detailed callback or polling timing evidence for the last capture.
void lwir_cam_pipe_deinit(void)
Stop, reap, and forget the persistent LWIR capture server.
int lwir_cam_pipe_init(const char *unused)
Start and qualify the persistent LWIR capture server.
void lwir_cam_pipe_configure(const struct camera_backend_host *host)
Bind the owner's long-lived shutdown flag before starting workers.
int lwir_cam_pipe_geolocate(char *filename)
Add thermal hotspot/geolocation metadata through the running server.
Parent-side protocol for USHER's persistent Tiny1-C LWIR capture server.
Positive opt-ins shared by the worker and its USHER adapter.
#define LWIR_ENABLE_MOCK
1 builds the development replay/synthetic-temperature adapter (lwir_mock).
#define LWIR_ENABLE_ANALYSIS
1 builds the optional ONNX analysis of saved photos (lwir_inference).
void spotter_cam_pipe_deinit(void)
Stop the native camera process and clear detector-specific configuration.
void spotter_cam_pipe_last_detection_summary(char *buffer, size_t buffer_size)
Format the most recent shot's detection result for EXIF writing.
void spotter_cam_pipe_save_detection_copy(const char *filename)
Copy filename into a "detections" subdirectory of the photo directory if the last spotter_cam_pipe_sh...
void spotter_cam_pipe_configure(const struct camera_backend_host *host)
Borrow USHER's shutdown flag for both serialized native worker owners.
int spotter_cam_pipe_shoot(char *filename, size_t filename_size, int image_number)
Request one JPEG and, when enabled, parse its matching detection sidecar.
bool spotter_cam_pipe_bind_frame(uint64_t sequence, uint64_t sensor_timestamp_ns)
Reject a detection result whose identity differs from the validated saved frame.
int spotter_cam_pipe_init(const char *unused)
Start and qualify native persistent capture with the selected analysis policy.
Native USHER adapter for on-sensor detection or photo-only capture.
struct camera_backend spotter_camera_backend_get(void)
Build the Spottercam backend descriptor for the registry.
Spottercam backend descriptor and optional native UART target projection.
Function table describing one backend's owned camera operations.
unsigned capabilities
struct camera_backend::@243120217343377347337244154071360217343172026241 mock
const char * name
Stable backend name used for logs and diagnostics.
#define USHER_CAMERA_ALL
#define USHER_CAMERA_AICAM
#define USHER_CAMERA_LWIRCAM