mirror of
https://github.com/DeeJanuz/frametop.git
synced 2026-10-06 07:00:14 +02:00
ft-camd tells the side cameras apart by XRService's buffer allocation order, which some XRService starts reverse; both of 2026-10-02's starts did, so the cutouts missed the hands. HANDS_SWAP_SIDES=auto (the default) has ft-hands vote from hands seen in both side cameras: the landmark rays meet in front of both cameras only under the right naming. While undecided it probes the exchanged naming with the landmark model. It decides in about 2 s of hands (right on all 7 recordings replayed), swaps the views in place, and publishes sides.json. 0 and 1 still force it, with a warning when the hands disagree. Recordings carry each part's naming and the session's decision; review, export, validate and ft-handreplay put the names right, and takes.py sides records a decision by hand. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
73 lines
2.0 KiB
C++
73 lines
2.0 KiB
C++
// Recordings of frame sets, for replaying live sessions through the tracker offline
|
|
// (ft-handreplay). A recording is DIR/sets.bin: one record per frame set, each
|
|
// fh_set_hdr_t, then per camera fh_set_cam_t, then each camera's pixels (w x h, packed)
|
|
// in the same camera order.
|
|
#pragma once
|
|
|
|
#include <condition_variable>
|
|
#include <cstdint>
|
|
#include <cstdio>
|
|
#include <deque>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <thread>
|
|
#include <vector>
|
|
|
|
#define FH_SET_MAGIC "FHSET01"
|
|
|
|
struct fh_set_hdr_t {
|
|
char magic[8];
|
|
uint32_t ncams;
|
|
uint32_t bytes; // the whole record, this header included
|
|
};
|
|
|
|
struct fh_set_cam_t {
|
|
char name[16]; // calibration name, e.g. "slam_left"
|
|
uint32_t width, height;
|
|
uint64_t capture_ns; // CLOCK_MONOTONIC_RAW, as the ring has it
|
|
uint64_t dqbuf_ns; // CLOCK_MONOTONIC
|
|
};
|
|
|
|
struct SetFrame {
|
|
std::string name;
|
|
const uint8_t *px;
|
|
uint32_t width, height;
|
|
uint64_t capture_ns, dqbuf_ns;
|
|
};
|
|
|
|
// Writes sets on its own thread, so a slow disk never holds up tracking; drops sets
|
|
// when too many are waiting.
|
|
class Recorder {
|
|
public:
|
|
~Recorder();
|
|
bool open(const std::string &dir, std::string &err);
|
|
void add(const std::vector<SetFrame> &frames);
|
|
// Sets taken (not dropped for a full queue): the next one's place in the file, unless a
|
|
// write fails.
|
|
size_t added() const { return added_; }
|
|
size_t written() const { return written_; }
|
|
size_t dropped() const { return dropped_; }
|
|
|
|
private:
|
|
void loop();
|
|
FILE *f_ = nullptr;
|
|
std::thread thread_;
|
|
std::mutex mu_;
|
|
std::condition_variable wake_;
|
|
std::deque<std::vector<uint8_t>> queue_;
|
|
bool stop_ = false;
|
|
size_t written_ = 0, dropped_ = 0, added_ = 0;
|
|
};
|
|
|
|
// Reads a recording back one set at a time.
|
|
class SetReader {
|
|
public:
|
|
bool open(const std::string &dir, std::string &err);
|
|
// False at the end (or on a truncated last set).
|
|
bool next(std::vector<fh_set_cam_t> &cams, std::vector<std::vector<uint8_t>> &pixels);
|
|
~SetReader();
|
|
|
|
private:
|
|
FILE *f_ = nullptr;
|
|
};
|