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
local_pipe.c File Reference

Hardware-free camera backend for fixture copies and cached map views. More...

#include "local_pipe.h"
#include "image_mock_transform.h"
#include "path_utils.h"
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>
#include <sys/stat.h>
#include <unistd.h>
Include dependency graph for local_pipe.c:

Go to the source code of this file.

Macros

#define USHER_LOCAL_PHOTO_DIR   "~/Pictures/sensoraia"
#define USHER_MOCK_IMAGE   "resources/mock_image_01.jpg"

Functions

static int prepare_photo_directory (void)
 Prepare usable output storage before accepting local shots.
static int resolve_photo_directory (void)
 Resolve the configured local output path into backend storage.
static int find_test_photo_directory (char *directory, size_t directory_size)
 Locate and count eligible fixtures beside the executable.
static int select_random_test_photo (char *path, size_t path_size)
 Select a fixture from the current test photo directory.
static bool is_readable_jpg (DIR *directory, const struct dirent *entry)
 Test whether a directory entry is an eligible JPEG fixture.
static int random_index (size_t count, size_t *index)
 Select an index for fixture playback.
int local_pipe_init (const char *mock_image)
 Initialize a deterministic mock image source for local camera simulation.
int local_pipe_test_init (const char *mock_image)
 Initialize test mode with a supplied JPEG or a random fixture beside USHER.
int local_pipe_map_init (const char *source)
 Prepare output storage for map-backed simulation.
int local_pipe_map_shoot (char *filename, size_t filename_size, const union dc_shot_union *shot, const struct camera_backend *identity, const char *cache_directory, double horizontal_fov_deg, double vertical_fov_deg)
 Render a map-backed capture using the trigger's camera geometry.
int local_pipe_shoot (char *filename, size_t filename_size, int image_number, const struct camera_backend *identity)
 Create a mock capture file for a shot.
void local_pipe_deinit (void)
 Forget selected local fixture sources.

Variables

static char source_image [PATH_MAX]
static char test_photo_directory [PATH_MAX]
static char photo_directory [PATH_MAX]

Detailed Description

Hardware-free camera backend for fixture copies and cached map views.

Use the requested camera identity for naming while keeping simulation outputs distinct from hardware captures. Map rendering delegates projection and publication to the shared image workspace. Fixture mode copies an existing image without recoding it.

Definition in file local_pipe.c.

Macro Definition Documentation

◆ USHER_LOCAL_PHOTO_DIR

#define USHER_LOCAL_PHOTO_DIR   "~/Pictures/sensoraia"

Definition at line 42 of file local_pipe.c.

◆ USHER_MOCK_IMAGE

#define USHER_MOCK_IMAGE   "resources/mock_image_01.jpg"

Definition at line 46 of file local_pipe.c.

Function Documentation

◆ find_test_photo_directory()

int find_test_photo_directory ( char * directory,
size_t directory_size )
static

Locate and count eligible fixtures beside the executable.

Parameters
[out]directoryBuffer for the discovered path.
directory_sizeCapacity including the terminator.
Returns
Eligible fixture count, zero when absent or empty, or -1 on setup failure.

Missing fixture storage is a normal case that lets the caller fall back to the bundled image.

Definition at line 307 of file local_pipe.c.

◆ is_readable_jpg()

bool is_readable_jpg ( DIR * directory,
const struct dirent * entry )
static

Test whether a directory entry is an eligible JPEG fixture.

Parameters
directoryOpen stream containing the entry.
entryCurrent directory entry.
Returns
True for a readable regular file with a case-insensitive .jpg suffix.

Check metadata relative to the open directory without building a pathname per candidate. This is eligibility only, not JPEG validation.

Definition at line 420 of file local_pipe.c.

◆ local_pipe_deinit()

void local_pipe_deinit ( void )

Forget selected local fixture sources.

No subprocess is owned and previously captured files are retained.

Definition at line 295 of file local_pipe.c.

◆ local_pipe_init()

int local_pipe_init ( const char * mock_image)

Initialize a deterministic mock image source for local camera simulation.

Parameters
mock_imageReadable JPEG copied for each shot.
Returns
0 on readiness or -1 on missing source/output storage.

Copy the path into the backend so the caller need not retain it.

Definition at line 64 of file local_pipe.c.

◆ local_pipe_map_init()

int local_pipe_map_init ( const char * source)

Prepare output storage for map-backed simulation.

Parameters
sourceUnused compatibility argument.
Returns
Zero on readiness, or -1 on path or storage failure.

Tile availability is checked per capture because the set of required tiles depends on the shot position and attitude.

Definition at line 171 of file local_pipe.c.

◆ local_pipe_map_shoot()

int local_pipe_map_shoot ( char * filename,
size_t filename_size,
const union dc_shot_union * shot,
const struct camera_backend * identity,
const char * cache_directory,
double horizontal_fov_deg,
double vertical_fov_deg )

Render a map-backed capture using the trigger's camera geometry.

Parameters
[out]filenameOutput path buffer; use only after a successful capture.
filename_sizeCapacity including the terminator.
shotTrigger containing the photo number, position, attitude and AGL.
identitySimulated camera prefix and raster dimensions.
cache_directoryMap tile cache root.
horizontal_fov_degHorizontal field of view in degrees.
vertical_fov_degVertical field of view in degrees.
Returns
Zero on publication, or -1 on invalid input, rendering or storage failure.

Construct a simulation filename for this camera and pass its geometry to the cached-tile renderer; this path does not use a fixture JPEG.

Definition at line 179 of file local_pipe.c.

◆ local_pipe_shoot()

int local_pipe_shoot ( char * filename,
size_t filename_size,
int image_number,
const struct camera_backend * identity )

Create a mock capture file for a shot.

Parameters
filenameDestination path buffer.
filename_sizeDestination capacity.
image_numberShot sequence.
identityBackend-owned filename prefix and simulation namespace.
Returns
0 after a complete stable regular-file copy, otherwise -1.

Existing destinations are never overwritten; failed copies remove only their new output.

Definition at line 193 of file local_pipe.c.

◆ local_pipe_test_init()

int local_pipe_test_init ( const char * mock_image)

Initialize test mode with a supplied JPEG or a random fixture beside USHER.

Parameters
mock_imageOptional explicit JPEG; NULL enables testphotos discovery.
Returns
0 on readiness or -1 on configuration failure.

If discovery finds no eligible fixture, use the bundled mock JPEG.

Definition at line 87 of file local_pipe.c.

◆ prepare_photo_directory()

int prepare_photo_directory ( void )
static

Prepare usable output storage before accepting local shots.

Returns
Zero for a writable directory, or -1 on resolution or storage failure.

Confirm directory type after creation; an existing regular file at the configured path is not a usable output location.

Definition at line 118 of file local_pipe.c.

◆ random_index()

int random_index ( size_t count,
size_t * index )
static

Select an index for fixture playback.

Parameters
countNonzero number of eligible entries.
[out]indexSelected index in [0, count).
Returns
Zero on success, or -1 if the random word cannot be read.

Use a fixed-size random word and modulo reduction. The slight modulo bias is acceptable for fixture variety, not for statistical sampling.

Definition at line 441 of file local_pipe.c.

◆ resolve_photo_directory()

int resolve_photo_directory ( void )
static

Resolve the configured local output path into backend storage.

Returns
Zero if the path fits, or -1 on invalid configuration or path lookup failure.

Anchor relative paths beside the executable rather than the caller's working directory so service and interactive launches agree.

Definition at line 142 of file local_pipe.c.

◆ select_random_test_photo()

int select_random_test_photo ( char * path,
size_t path_size )
static

Select a fixture from the current test photo directory.

Parameters
[out]pathBuffer for the selected pathname.
path_sizeCapacity including the terminator.
Returns
Zero when a fixture path fits, or -1 when none can be selected.

Count entries, choose an index, then rescan. This needs no directory-sized allocation, at the cost of a second scan that may see changes.

Definition at line 363 of file local_pipe.c.

Variable Documentation

◆ photo_directory

char photo_directory[PATH_MAX]
static

Definition at line 55 of file local_pipe.c.

◆ source_image

char source_image[PATH_MAX]
static

Definition at line 53 of file local_pipe.c.

◆ test_photo_directory

char test_photo_directory[PATH_MAX]
static

Definition at line 54 of file local_pipe.c.