Files
DeeJanuz--frametop/include/fh_hands.h
T
DeeJanuzandClaude Opus 5.5 067a03ce38 Hand tracking for Frametop's hand cutouts
fh-camd (camd/) borrows XRService's camera buffers and publishes the tracking
cameras' frames to a shared ring. fh-tracker (trackd/) finds hands in them with
MediaPipe's palm and landmark models on ncnn, triangulates them in 3D, and
publishes them for ft-screens. fh-replay replays recordings offline. tracker/ is
the earlier Python version; tools/ and probes/ hold the checks and experiments.

As of this commit: crop contrast defaults to CLAHE for the palm search and plain
crops for the landmarks, --swap-sides works around fh-camd naming the side
cameras backwards after some XRService restarts (tools/check_sides.py detects
it), and --record-only, --with-dark, --cpus and --keep-presence support the
bright-light and CPU-placement tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-29 22:36:48 -06:00

59 lines
2.4 KiB
C

/*
* fh_hands - the tracked-hands file frame-hands' tracker publishes
* ($XDG_RUNTIME_DIR/frame-hands/hands, directory mode 0700), rewritten in place
* under a sequence lock: read seq, copy, read seq again; use the copy only if
* both reads are the same even number.
*
* Positions are metres in the head frame at capture time, which is OpenVR's HMD
* frame (+x right, +y up, -z forward). Turn them into the room with the HMD pose
* at capture_ns (CLOCK_MONOTONIC). Writers: trackd (fh-tracker), tracker/publish.py.
*/
#pragma once
#include <assert.h>
#include <stdint.h>
#define FH_HANDS_MAGIC "FHHANDS1"
#define FH_HANDS_VERSION 1
#define FH_HANDS_MAX_HANDS 2
#define FH_HANDS_MAX_CAPSULES 64
enum {
FH_HAND_RIGHT = 1u << 0, /* else the left hand */
FH_HAND_STEREO = 1u << 1, /* triangulated from two or more cameras */
};
typedef struct {
uint32_t id; /* stays the same while the hand is tracked */
uint32_t flags; /* FH_HAND_* */
float confidence;
float reserved;
float pts[21][3]; /* MediaPipe hand landmarks */
uint32_t ncapsules; /* this hand's capsules, which follow the */
/* previous hands' in capsules[] */
} fh_hand_t; /* 272 bytes */
typedef struct {
float a[3], b[3]; /* segment ends */
float ra, rb; /* radius at each end */
} fh_capsule_t; /* 32 bytes: the hand's shape, to cut out */
typedef struct {
char magic[8];
uint32_t version;
uint32_t size;
volatile uint64_t seq;
uint64_t capture_ns; /* CLOCK_MONOTONIC when the cameras took the frames */
uint64_t publish_ns; /* CLOCK_MONOTONIC when this was written */
uint32_t nhands;
uint32_t ncapsules;
uint8_t reserved[16];
fh_hand_t hands[FH_HANDS_MAX_HANDS];
fh_capsule_t capsules[FH_HANDS_MAX_CAPSULES];
} fh_hands_t;
static_assert(sizeof(fh_hand_t) == 272, "fh_hand_t layout");
static_assert(sizeof(fh_capsule_t) == 32, "fh_capsule_t layout");
static_assert(sizeof(fh_hands_t) == 64 + 2 * 272 + 64 * 32, "fh_hands_t layout");