Monado OpenXR Runtime
Loading...
Searching...
No Matches
t_rift_blobwatch.c File Reference

Blob thresholding and tracking in camera frames. More...

#include "xrt/xrt_defines.h"
#include "xrt/xrt_frame.h"
#include "xrt/xrt_config_build.h"
#include "util/u_logging.h"
#include "util/u_misc.h"
#include "util/u_frame.h"
#include "util/u_time.h"
#include "util/u_var.h"
#include "os/os_threading.h"
#include "tracking/t_constellation.h"
#include "tracking/t_camera_models.h"
#include "math/m_api.h"
#include "t_rift_blobwatch.h"
#include <string.h>
Include dependency graph for t_rift_blobwatch.c:

Data Structures

struct  blob
 
struct  blobservation
 
struct  extent
 
struct  blob_pixel
 
struct  blob_bounds
 
struct  extent_line
 
struct  blobservation_queue
 
struct  t_rift_blobwatch
 

Macros

#define LED_INVALID_ID   ((led_id_t)(-1))
 
#define LED_NOISE_ID   ((led_id_t)(-2))
 
#define LED_LOCAL_ID(l)   (((l) == LED_INVALID_ID) ? (l) : (l) & 0xFF)
 
#define LED_OBJECT_ID(l)   (((l) == LED_INVALID_ID) ? (l) : (l) >> 8)
 
#define LED_MAKE_ID(o, n)   ((led_id_t)(((led_id_t)(o)) << 8 | ((led_id_t)(n))))
 
#define NUM_FRAMES_HISTORY   5
 
#define MAX_EXTENTS_PER_LINE   30
 
#define CONSISTENCY_CHECKS   0
 
#define QUEUE_ENTRIES   (NUM_FRAMES_HISTORY + 1)
 
#define BLOB_SPLIT_SADDLE_RATIO   0.75f
 
#define MAX_PEAKS_PER_BLOB   32
 
#define PEAK_NONE   ((uint8_t)0xFF)
 

Typedefs

typedef uint16_t led_id_t
 

Functions

static void init_queue (struct blobservation_queue *q)
 
static void push_queue (struct blobservation_queue *q, struct blobservation *b)
 
static struct blobservation * pop_queue (struct blobservation_queue *q)
 
static struct t_rift_blobwatch * t_rift_blobwatch (struct t_blobwatch *bw)
 
static bool collect_blob_pixels (struct t_rift_blobwatch *bw, struct xrt_frame *frame, uint16_t seed_x, uint16_t seed_y, uint32_t *out_count, uint32_t *out_peak_count, struct blob_bounds *out_bounds)
 
static uint8_t find_peak_root (const uint8_t *parent, uint8_t peak)
 
static uint32_t split_blob_peaks (struct t_rift_blobwatch *bw, uint32_t count, const struct blob_bounds *bounds)
 
static void store_blob (struct t_rift_blobwatch *bw, struct blobservation *ob, uint32_t count, uint8_t peak)
 
static void extent_to_blobs (struct t_rift_blobwatch *bw, struct blobservation *ob, struct extent *e, uint16_t y, struct xrt_frame *frame)
 
static void process_scanline (uint8_t *line, struct t_rift_blobwatch *bw, uint32_t y, struct extent_line *el, struct extent_line *prev_el, struct xrt_frame *frame, struct blobservation *ob)
 
static void ensure_scratch (struct t_rift_blobwatch *bw, struct xrt_frame *frame)
 Ensures the scratch space is large enough for this particular frame.
 
static void free_scratch (struct t_rift_blobwatch *bw)
 Frees the scratch memory used by this blobwatch.
 
static void process_frame (struct t_rift_blobwatch *bw, struct blobservation *ob, struct xrt_frame *frame)
 
static int16_t find_free_track (uint8_t *tracked)
 
static void copy_matching_blob (struct blob *to, struct blob *from)
 
static void blobwatch_release_observation (struct t_rift_blobwatch *bw, struct blobservation *ob)
 
static void blobwatch_process (struct t_rift_blobwatch *bw, struct xrt_frame *frame, struct blobservation **output)
 
static void t_rift_blobwatch_push_frame (struct xrt_frame_sink *sink, struct xrt_frame *frame)
 
static void t_rift_blobwatch_node_break_apart (struct xrt_frame_node *node)
 
static void t_rift_blobwatch_node_destroy (struct xrt_frame_node *node)
 
static void t_rift_blobwatch_fake_destroy (struct t_blobwatch *xbw)
 
static void t_rift_blobwatch_mark_blob_device (struct t_blobwatch *xbw, const struct t_blob_observation *xbo, t_constellation_device_id_t device_id)
 
int t_rift_blobwatch_create (const struct t_rift_blobwatch_params *params, struct xrt_frame_context *xfctx, struct t_blob_sink *blob_sink, struct xrt_frame_sink **out_frame_sink, struct t_blobwatch **out_blobwatch)
 

Detailed Description

Function Documentation

◆ ensure_scratch()

static void ensure_scratch ( struct t_rift_blobwatch *  bw,
struct xrt_frame *  frame 
)
static

Ensures the scratch space is large enough for this particular frame.

References t_rift_blobwatch_params::max_blob_width, U_ARRAY_REALLOC_OR_FREE, and U_TYPED_ARRAY_CALLOC.

◆ free_scratch()

static void free_scratch ( struct t_rift_blobwatch *  bw)
static

Frees the scratch memory used by this blobwatch.