Files
DeeJanuz--frametop/hands/track/io.h
T
DeeJanuzandClaude Opus 5.5 499035216c Make hand tracking a Frametop component
- Programs: ft-camd (the camera broker), ft-hands (the tracker), and
  ft-handreplay and ft-ringplay for recordings, built by hands/build.sh
  into hands/build/ with one Makefile. The first build fetches ncnn at
  frame-hands' pinned tag and builds it with the same options.
- ft-camd gets its privileges from file capabilities (CAP_SYS_PTRACE,
  CAP_PERFMON, CAP_DAC_READ_SEARCH) that hands/run.sh install sets with
  sudo, and drops them once set up. It still works under sudo. It runs
  on the host, linked statically, as frametop-camd.service. ft-hands
  runs in the dev container as frametop-hands.service. Both start and
  stop with SteamVR.
- Files move to /run/user/UID/frametop/ (cam-ring, hands, gestures),
  not $XDG_RUNTIME_DIR, which a terminal in the Frametop desktop has
  its own of. SIGUSR1 recordings go to ~/.local/share/frametop/hands.
- The calibration is read through /run/host in the container.
- Settings: HANDS_SWAP_SIDES and HANDS_CPUS in frametop.conf.
- install.sh offers hand tracking as an optional last step.
- The container gets jsoncpp-devel, glibc-static, and NumPy and OpenCV
  for the Python tools.
- tools/ring.py reads the ring, and models/NOTICE credits the
  Apache-2.0 models.

Checked: ft-handreplay gives identical summaries and byte-identical
depth dumps to frame-hands' fh-replay on both 2026-09-29 recordings.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-30 09:15:07 -06:00

52 lines
1.6 KiB
C++

// Frames in from ft-camd's ring (camd/fhring.h), hands out to the hands file
// (include/fh_hands.h, read by Frametop's ft-screens).
#pragma once
#include "tracker.h"
#include <cstdint>
#include <string>
#include <vector>
extern "C" {
#include "../camd/fhring.h"
#include "../include/fh_hands.h"
}
class Ring {
public:
bool open(const char *path, std::string &err);
bool alive() const; // the writer's heartbeat is fresh
int cameras() const { return int(hdr_->ncams); }
const fh_ring_cam_t &camera(int i) const { return hdr_->cams[i]; }
uint64_t latest(int i) const;
// Copy frame n of camera i into out (width x height, tightly packed). False if it's
// gone or was being written.
bool read(int i, uint64_t n, std::vector<uint8_t> &out, fh_ring_slot_t *meta) const;
// Just frame n's slot header (capture time etc.), without copying the image.
bool meta(int i, uint64_t n, fh_ring_slot_t *meta) const;
private:
const uint8_t *map_ = nullptr;
const fh_ring_hdr_t *hdr_ = nullptr;
size_t len_ = 0;
};
class Publisher {
public:
bool open(std::string &err);
void write(const std::vector<const Hand *> &hands, uint64_t capture_ns);
private:
fh_hands_t *out_ = nullptr;
uint64_t seq_ = 0;
};
uint64_t mono_ns();
int64_t raw_minus_mono_ns(); // camera timestamps are CLOCK_MONOTONIC_RAW
// /run/user/UID/frametop, created private to the user if it's missing: where ft-camd's ring
// (FH_RING_NAME) and the hands and gestures files live. Not $XDG_RUNTIME_DIR: a terminal in
// the Frametop desktop has a private one of its own.
std::string run_dir();