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

Native Spottercam backend and optional C11 UART target-slot projection. More...

#include "spotter_camera_backend.h"
#include "camera_profile.h"
#include "coverage_scheduler.h"
#include "spotter_cam_pipe.h"
#include "../modules/spotter_cam/spotter_targets.h"
#include <errno.h>
#include <math.h>
#include <pthread.h>
#include <stdio.h>
#include <sys/eventfd.h>
#include <unistd.h>
Include dependency graph for spotter_camera_backend.c:

Go to the source code of this file.

Macros

#define USHER_SODA   "./bin/soda"
#define USHER_AI_CAM_PHOTO_DIR   "~/Pictures/sensoraia"
#define USHER_SPOTTERCAM_PHOTO_DIR   USHER_AI_CAM_PHOTO_DIR
#define SPOTTER_POINT_QUEUE_CAPACITY   16U

Functions

static void drain_notification_locked (void)
 Clear the event hint while holding target_mutex.
static void notify_locked (void)
 Wake the event loop after queuing a result under target_mutex.
bool spotter_camera_backend_set_targets_profile (const char *filename)
 Configure pinhole camera calibration for projecting Spottercam boxes to UART points.
bool spotter_camera_backend_targets_enabled (void)
 True when native Spottercam UART target projection is configured and active.
static int spotter_stream_init (void)
 Reset target accumulation and prepare completion notification.
static void spotter_stream_drain (void)
 Discard pending target results and close their notification channel.
static int spotter_stream_completion_fd (void)
 Get the stream's borrowed poll descriptor.
static bool spotter_stream_poll_result (struct camera_point_result *result)
 Pop one queued Spottercam point.
static void spotter_image_saved (const char *filename, const union dc_shot_union *shot)
 Convert a saved image's detections into stream observations.
struct camera_backend spotter_camera_backend_get (void)
 Build the Spottercam backend descriptor for the registry.

Variables

static pthread_mutex_t target_mutex = PTHREAD_MUTEX_INITIALIZER
static struct usher_camera_profile target_profile
static bool target_profile_loaded
static struct spotter_targets target_store
static struct spotter_detections parsed_detections
static struct camera_point_result pending_points [SPOTTER_POINT_QUEUE_CAPACITY]
static size_t pending_head
static size_t pending_count
static uint32_t last_admitted_shot
static int notification_fd = -1

Detailed Description

Native Spottercam backend and optional C11 UART target-slot projection.

Projects validated vehicle detections through a measured PANGEA_CAMERA_V1 pinhole profile onto the five ranked geographic target slots (0..4 -> T1..T5) and publishes correlated USHER_CAM_POINT_UPDATE frames without Python helpers.

Definition in file spotter_camera_backend.c.

Macro Definition Documentation

◆ SPOTTER_POINT_QUEUE_CAPACITY

#define SPOTTER_POINT_QUEUE_CAPACITY   16U

Definition at line 48 of file spotter_camera_backend.c.

◆ USHER_AI_CAM_PHOTO_DIR

#define USHER_AI_CAM_PHOTO_DIR   "~/Pictures/sensoraia"

Definition at line 42 of file spotter_camera_backend.c.

◆ USHER_SODA

#define USHER_SODA   "./bin/soda"

Definition at line 39 of file spotter_camera_backend.c.

◆ USHER_SPOTTERCAM_PHOTO_DIR

#define USHER_SPOTTERCAM_PHOTO_DIR   USHER_AI_CAM_PHOTO_DIR

Definition at line 45 of file spotter_camera_backend.c.

Function Documentation

◆ drain_notification_locked()

void drain_notification_locked ( void )
static

Clear the event hint while holding target_mutex.

The result queue, not the event counter, owns pending work. Clear the counter only while producers are excluded and the queue is empty.

Definition at line 64 of file spotter_camera_backend.c.

◆ notify_locked()

void notify_locked ( void )
static

Wake the event loop after queuing a result under target_mutex.

An eventfd wake is a readability hint, not a second result queue; a saturated counter already has the desired readable state.

Definition at line 77 of file spotter_camera_backend.c.

◆ spotter_camera_backend_get()

struct camera_backend spotter_camera_backend_get ( void )

Build the Spottercam backend descriptor for the registry.

Definition at line 289 of file spotter_camera_backend.c.

◆ spotter_camera_backend_set_targets_profile()

bool spotter_camera_backend_set_targets_profile ( const char * filename)

Configure pinhole camera calibration for projecting Spottercam boxes to UART points.

Parameters
filenamePath to an AIcam PANGEA_CAMERA_V1 calibration profile.
Returns
True when the profile is valid for USHER_CAMERA_AICAM.

Definition at line 87 of file spotter_camera_backend.c.

◆ spotter_camera_backend_targets_enabled()

bool spotter_camera_backend_targets_enabled ( void )

True when native Spottercam UART target projection is configured and active.

Definition at line 102 of file spotter_camera_backend.c.

◆ spotter_image_saved()

void spotter_image_saved ( const char * filename,
const union dc_shot_union * shot )
static

Convert a saved image's detections into stream observations.

Parameters
filenamePublished JPEG used to locate matching detector evidence.
shotPose and photo number associated with that image.

Reject non-increasing shot IDs and invalid evidence before updating the target store. Rescale intrinsics to the detection raster before projecting; these are flat-ground estimates, not surveyed positions.

Definition at line 182 of file spotter_camera_backend.c.

◆ spotter_stream_completion_fd()

int spotter_stream_completion_fd ( void )
static

Get the stream's borrowed poll descriptor.

Returns
Event descriptor, or -1 if the stream has none.

The lock protects lookup, not the lifetime after return; the event-loop owner coordinates polling with teardown.

Definition at line 145 of file spotter_camera_backend.c.

◆ spotter_stream_drain()

void spotter_stream_drain ( void )
static

Discard pending target results and close their notification channel.

Serialize descriptor lifetime with producers so they cannot write to a closed or subsequently reused descriptor.

Definition at line 129 of file spotter_camera_backend.c.

◆ spotter_stream_init()

int spotter_stream_init ( void )
static

Reset target accumulation and prepare completion notification.

Returns
Zero with a usable event descriptor, or -1 on eventfd failure.

Reset shot ordering with the result ring so a prior stream's observations cannot be mistaken for this stream's output.

Definition at line 111 of file spotter_camera_backend.c.

◆ spotter_stream_poll_result()

bool spotter_stream_poll_result ( struct camera_point_result * result)
static

Pop one queued Spottercam point.

Parameters
[out]resultDestination, unchanged if no point is available.
Returns
True when a point was copied.

Keep the event descriptor readable while more points remain, and clear it under the producer lock once the last point is removed.

Definition at line 158 of file spotter_camera_backend.c.

Variable Documentation

◆ last_admitted_shot

uint32_t last_admitted_shot
static

Definition at line 58 of file spotter_camera_backend.c.

◆ notification_fd

int notification_fd = -1
static

Definition at line 59 of file spotter_camera_backend.c.

◆ parsed_detections

struct spotter_detections parsed_detections
static

Definition at line 54 of file spotter_camera_backend.c.

◆ pending_count

size_t pending_count
static

Definition at line 57 of file spotter_camera_backend.c.

◆ pending_head

size_t pending_head
static

Definition at line 56 of file spotter_camera_backend.c.

◆ pending_points

struct camera_point_result pending_points[SPOTTER_POINT_QUEUE_CAPACITY]
static

Definition at line 55 of file spotter_camera_backend.c.

◆ target_mutex

pthread_mutex_t target_mutex = PTHREAD_MUTEX_INITIALIZER
static

Definition at line 50 of file spotter_camera_backend.c.

◆ target_profile

struct usher_camera_profile target_profile
static

Definition at line 51 of file spotter_camera_backend.c.

◆ target_profile_loaded

bool target_profile_loaded
static

Definition at line 52 of file spotter_camera_backend.c.

◆ target_store

struct spotter_targets target_store
static

Definition at line 53 of file spotter_camera_backend.c.