Loading...
Searching...
No Matches
inference_capture.cpp
Go to the documentation of this file.
20 * @details CPU inference runs after the frame lease ends so model latency does not hold camera DMA ownership. */
65 return inference_context_prepare_image(preparation.context, &image, preparation.error, preparation.capacity);
68/** @brief Permit the neutral encoder to retain a useful photograph before optional CPU analysis succeeds. */
71/** @brief Preserve fake-camera JPEG bytes without reencoding, refusing overwrite and changing input files. */
77 if (fstat(input, &before) || !S_ISREG(before.st_mode) || before.st_size <= 0 || before.st_size > 128 * 1024 * 1024) {
101 valid = valid && copied == before.st_size && !fstat(input, &after) && before.st_size == after.st_size &&
102 before.st_mtim.tv_sec == after.st_mtim.tv_sec && before.st_mtim.tv_nsec == after.st_mtim.tv_nsec && !fsync(output);
116 if ((!serve && !probe && !capture) || (serve && argc != 6) || (probe && argc != 4) || (capture && argc != 5)) return 2;
123 if (!inference_settings_find(processor.application, processor.module, discovered, sizeof(discovered))) {
129 if (!inference_settings_read(&settings, settings_path, processor.setting, processor.context, error, sizeof(error))) {
137 return imx500::run_worker(serve ? 5 : capture ? 4 : 3, arguments, sensor_processor, processor.application);
142 if (width > std::numeric_limits<unsigned>::max() || height > std::numeric_limits<unsigned>::max() ||
143 !imx500::valid_capture_dimensions(static_cast<unsigned>(width), static_cast<unsigned>(height))) return 2;
147 if (!inference_context_open(&context, &settings, processor.adapter, error, sizeof(error))) throw std::runtime_error(error);
148 if (processor.validate && !processor.validate(processor.context, &context, error, sizeof(error))) throw std::runtime_error(error);
158 } else if (!settings.input[0] || !inference_jpeg_prepare(&context, settings.input, error, sizeof(error))) {
159 throw std::runtime_error(settings.input[0] ? error : "Picture source requires input in settings");
179 /* The staged image is still exclusively producer-owned, so LOOM may embed feature evidence here. */
204 /* Remove only names created by this attempt; never erase a pre-existing image or analysis result. */
static bool ini_uint(const char *text, uint64_t *number)
Parse digits-only uint64; overflow and signs are rejected.
Definition bounded_ini.h:52
static bool capture(struct transport *transport, FILE *file, const struct capture_settings *settings)
Capture to the camera's SD card and download the resulting JPEG.
Definition chdkbridge.c:1463
int inference_capture_cli(int argc, char **argv, const inference_image_processor &processor, const imx500::FrameProcessor &sensor_processor)
Dispatch configured RPK/ONNX capture while preserving one physical camera owner.
Definition inference_capture.cpp:110
Settings-driven capture bridge; neutral camera mechanics never interpret neural outputs.
bool inference_jpeg_prepare(struct inference_context *context, const char *filename, char *error, size_t capacity)
Stream a JPEG into an open context's single declared image input.
Definition inference_jpeg.c:167
bool inference_context_run(struct inference_context *context, char *error, size_t capacity)
Run the currently prepared tensors using the context's timeout policy.
Definition inference_model.c:346
bool inference_context_open(struct inference_context *context, const struct inference_settings *settings, const char *adapter, char *error, size_t capacity)
Verify a bundle, map bounded tensors and bind one warm session.
Definition inference_model.c:277
bool inference_context_prepare_image(struct inference_context *context, const struct inference_image *image, char *error, size_t capacity)
Prepare a single image input without running the model, so camera leases can be released first.
Definition inference_model.c:361
void inference_context_close(struct inference_context *context)
Release the session before unmapping its borrowed tensor storage.
Definition inference_model.c:373
bool inference_settings_find(const char *application, const char *module, char *filename, size_t capacity)
Discover application_settings.ini in adjacent, development-module, then installed-share order.
Definition inference_settings.c:202
bool inference_settings_read(struct inference_settings *settings, const char *filename, ini_field_handler extra, void *context, char *error, size_t capacity)
Parse one flat INI, delegate application keys and resolve paths against the selected file.
Definition inference_settings.c:158
void inference_settings_init(struct inference_settings *settings, enum inference_backend backend)
Reset storage and select conservative thread/timeout defaults.
Definition inference_settings.c:28
int run_worker(int argc, char **argv, const FrameProcessor &processor, const char *application)
Run the shared probe/capture/READY-SHOT-OK worker with supplied model policy.
Definition imx500_camera.cpp:817
constexpr bool valid_capture_dimensions(unsigned width, unsigned height)
Check that capture dimensions meet the worker's raster policy.
Definition imx500_camera.hpp:68
Stack-owned model-specific operations; no dynamic plugin allocation.
Definition imx500_camera.hpp:109
Borrowed same-exposure evidence, without object or navigation semantics.
Definition imx500_camera.hpp:77
Borrowed module callbacks; the worker serializes calls and retains no per-request pixel pointers.
Definition inference_worker.h:32
bool(* validate)(void *context, const struct inference_context *model, char *error, size_t capacity)
Definition inference_worker.h:38
bool(* write)(void *context, const struct inference_context *model, const char *image, uint32_t sequence, char *error, size_t capacity)
Definition inference_worker.h:36
Borrowed immutable planes; lengths/strides prove all addressed rows are available.
Definition inference_image.h:37
Per-application configuration; all resolved paths belong to this caller-owned value.
Definition inference_settings.h:39