Loading...
Searching...
No Matches
loom_capture.cpp
Go to the documentation of this file.
50/** @brief Establish finite-storage feature transport limits without claiming a trained visual match. */
51bool validate_onnx_features(void *configuration, const inference_context *context, char *error, size_t capacity)
73 std::snprintf(error, capacity, "Declared LOOM return vectors require one float32 output with two or three values");
79/** @brief Embed only in an exclusively owned private JPEG so published or hard-linked references stay immutable. */
82 /* The worker serializes callbacks; reusable bounded EXIF storage avoids a large per-request stack frame. */
92 if (exif_parse(&view, payload, payload_size) || image_exif_import(&document, &view)) return false;
94 unsigned char *destination = exif_document_reserve(&document, EXIF_CAMERA, LOOM_ONNX_FEATURES_TAG,
103 exif_update_jpeg(output, payload, payload_size) == 0 && !std::fflush(output) && !fsync(fileno(output));
108/** @brief Retain exact model/preprocessing identity with features; ordinary offline analysis never mutates its input. */
116 if (model.outputs[slot].type != ONNX_FLOAT32 || model.outputs[slot].bytes / sizeof(float) > 4096 - total) {
123 if (!std::isfinite(values[index])) { std::snprintf(error, capacity, "Nonfinite LOOM feature"); return false; }
131 if (length < 4 || std::strcmp(image + length - 4, ".jpg") || !inference_file_sha256(image, digest)) return false;
132 const int count = std::snprintf(filename, sizeof(filename), "%.*s.loom.ini", static_cast<int>(length - 4), image);
135 if (!output) { std::snprintf(error, capacity, "Cannot exclusively create LOOM features: %s", filename); return false; }
139 if (options.frame == LOOM_RETURN_NORTH_EAST || options.frame == LOOM_RETURN_BODY_FORWARD_RIGHT) {
141 std::fprintf(output, "return_vector_frame=%s\nreturn_first=%.9g\nreturn_second=%.9g\nreturn_confidence=%.9g\n",
152 std::fprintf(output, "%s%lld", axis ? "," : "", static_cast<long long>(tensor.dimensions[axis]));
161 if (!written) { unlink(filename); std::snprintf(error, capacity, "Cannot publish LOOM features"); }
206 std::puts("Usage: loomcam --analyze FILE.jpg | --analyze-server | --check-model [--settings FILE]\n"
215 "Return-server skips rejected vectors unless --simulation is explicit; ACK budget is 4 seconds.");
static int record(const union dc_shot_union *shot)
Retrieve a point and admit a new observation only when its credit is free.
Definition dipla_camera_backend.c:206
int exif_serialize(const struct exif_document *document, unsigned char *payload, size_t capacity, size_t *size)
Serialize a document into one complete EXIF APP1 payload.
Definition exifite.c:736
void exif_document_init(struct exif_document *document)
Start a fresh upright sRGB/Y-Cb-Cr document with EXIF 2.32 defaults.
Definition exifite.c:412
unsigned char * exif_document_reserve(struct exif_document *document, enum exif_directory directory, uint16_t tag, enum exif_format format, uint32_t count)
Create or replace a field with zeroed, bounded value storage.
Definition exifite.c:508
int exif_parse(struct exif_view *view, const unsigned char *payload, size_t size)
Validate an EXIF APP1 payload and create a borrowed view.
Definition exifite.c:257
int exif_read_jpeg(const char *filename, unsigned char *payload, size_t capacity, size_t *size)
Read the single EXIF APP1 segment before the first JPEG scan.
Definition exifite.c:1022
#define EXIF_MAX_PAYLOAD
APP1 payload ceiling: the JPEG length includes its own two bytes.
Definition exifite.h:51
int exif_update_jpeg(FILE *file, const unsigned char *payload, size_t size)
Replace EXIF in a regular JPEG file without a temporary file.
Definition exifite.c:1649
Flight, timing, and thermal-analysis metadata writing for captured JPEGs.
static int image_exif_import(struct exif_document *document, const struct exif_view *view)
Import standard metadata plus the application's approved capture evidence.
Definition image_exif.h:58
Neutral IMX500 frame ownership, JPEG publication and worker protocol.
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_file_sha256(const char *filename, char digest[65])
Hash a stable nonempty regular file using bounded streaming scratch.
Definition inference_model.c:41
int inference_worker_cli(int argc, char **argv, const struct inference_image_processor *processor)
Dispatch one-shot analysis, model checks or the persistent ANALYZE protocol.
Definition inference_worker.c:75
Warm saved-picture processing without acquiring a camera or interpreting CAM results.
int main(int argc, char **argv)
Dispatch saved-photo processing without opening a second camera owner.
Definition loom_capture.cpp:202
int loomcam_photo_main(int argc, char **argv)
Dispatch the saved-photo CLI through its C linkage boundary.
bool loom_features_pack(unsigned char *record, size_t capacity, const float *values, size_t count, const uint8_t *information, size_t information_size, uint64_t sequence, uint64_t sensor_timestamp_ns)
Pack validated same-exposure shapes, exact uint64 identities and float bits.
Definition loom_features.c:116
size_t loom_features_size(size_t count)
Required bytes for 1..4096 floats, or zero for unsupported counts.
Definition loom_features.c:100
bool loom_features_valid(const float *values, size_t count, const uint8_t *information, size_t information_size)
Validate finite features against the shared IMX500 shape metadata.
Definition loom_features.c:47
LOOM-owned bounded feature validation and evidence serialization.
#define LOOM_FEATURES_TAG
LOOM-owned camera-directory tag; its value is a LOOMNN02 opaque record.
Definition loom_features.h:30
size_t loom_onnx_features_pack(unsigned char *record, size_t capacity, const struct inference_model *model, uint64_t sequence, uint64_t sensor_timestamp_ns)
Encode a complete LOOMOX01 record without fabricating an IMX500 metadata header.
Definition loom_onnx_features.c:39
void loom_return_options_init(struct loom_return_options *options)
Initialize return limits with feature-only semantics by default.
Definition loom_return.c:40
bool loom_return_options_valid(const struct loom_return_options *options)
Check that optional destination coordinates are either both present or both omitted.
Definition loom_return.c:47
bool loom_return_setting(void *context, const char *key, const char *value)
Parse one LOOM-owned settings field, rejecting duplicates and unknown keys.
Definition loom_return.c:55
Bounded direction-to-target policy, independent of inference and FC transport.
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
Compile-time build identity strings for USHER executables.
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
Independent, noncopyable model owner; mapped tensor buffers and session are reused between jobs.
Definition inference_model.h:43
Borrowed module callbacks; the worker serializes calls and retains no per-request pixel pointers.
Definition inference_worker.h:32
struct onnx_tensor outputs[ONNX_TENSOR_LIMIT]
Definition inference_model.h:36
Module-owned inference settings, separate from universal runtime settings.
Definition loom_return.h:65