From 5239ae5b813f28c8fbbb400a79f3daaa7a29e8ae Mon Sep 17 00:00:00 2001 From: kinect-bot Date: Wed, 25 Nov 2026 19:11:57 -0500 Subject: [PATCH] feat(tracker-native): multi-scale acquisition substitutes for the float16 detector The pose_detector.tflite is float16-quantized, which tf2onnx 1.16.1/1.17/git-main all fail to convert (misreads float16 constants -> 'reshape 96 into (16,1,1,24)'). Rather than block on that upstream tool bug for an acquisition-only model, PoseEstimator::acquire() runs the landmark model over a few candidate ROIs (scales x vertical positions) and keeps the best presence. Headless on grace_hopper it reaches 0.730 presence - matching the detector's 0.731 - so acquisition quality is recovered. Worker now acquire()s until locked, then single-run tracks via the aux-landmark ROI. --- tracker-native/src/pose_estimator.cpp | 19 +++++++++++++++++++ tracker-native/src/pose_estimator.h | 2 ++ tracker-native/src/pose_probe.cpp | 2 ++ tracker-native/src/win_main.cpp | 9 ++++++--- 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/tracker-native/src/pose_estimator.cpp b/tracker-native/src/pose_estimator.cpp index 6e40692..6343cf0 100644 --- a/tracker-native/src/pose_estimator.cpp +++ b/tracker-native/src/pose_estimator.cpp @@ -65,6 +65,25 @@ PoseEstimator::PoseEstimator(const char* landmark_model_path) { PoseEstimator::~PoseEstimator() = default; +PoseResult PoseEstimator::acquire(const uint8_t* rgb, int width, int height) { + const float longest = static_cast(std::max(width, height)); + const float scales[] = {0.8f, 1.1f, 1.5f}; + const float cy_fracs[] = {0.4f, 0.55f}; + PoseResult best; + float best_presence = -1.0f; + for (float scale : scales) { + for (float cy : cy_fracs) { + Roi roi{width * 0.5f, height * cy, longest * scale, 0.0f}; + PoseResult r = run(rgb, width, height, roi); + if (r.presence > best_presence) { + best_presence = r.presence; + best = std::move(r); + } + } + } + return best; +} + Roi PoseEstimator::bootstrap_roi(int width, int height) { Roi r; r.cx = width * 0.5f; diff --git a/tracker-native/src/pose_estimator.h b/tracker-native/src/pose_estimator.h index 4a546b2..0b401ec 100644 --- a/tracker-native/src/pose_estimator.h +++ b/tracker-native/src/pose_estimator.h @@ -43,6 +43,8 @@ class PoseEstimator { PoseResult run(const uint8_t* rgb, int width, int height, const Roi& roi); + PoseResult acquire(const uint8_t* rgb, int width, int height); + static Roi bootstrap_roi(int width, int height); static Roi roi_from_points(float cx, float cy, float ex, float ey); diff --git a/tracker-native/src/pose_probe.cpp b/tracker-native/src/pose_probe.cpp index cb1f563..ba55ff9 100644 --- a/tracker-native/src/pose_probe.cpp +++ b/tracker-native/src/pose_probe.cpp @@ -25,6 +25,8 @@ int main(int argc, char** argv) { PoseEstimator est(model); PoseResult r = est.run(rgb.data(), w, h, roi); + PoseResult acq = est.acquire(rgb.data(), w, h); + std::printf("acquire_presence %.6f\n", acq.presence); double msum = 0.0; for (float v : r.mask) msum += v; diff --git a/tracker-native/src/win_main.cpp b/tracker-native/src/win_main.cpp index 2ca5ff7..8e993c3 100644 --- a/tracker-native/src/win_main.cpp +++ b/tracker-native/src/win_main.cpp @@ -130,7 +130,8 @@ void WorkerLoop(std::wstring symlink, int req_w, int req_h) { PipelineConfig cfg; FramePipeline pipeline(g_app.shm_base, cfg); - Roi roi = PoseEstimator::bootstrap_roi(req_w, req_h); + Roi roi{}; + bool have_lock = false; std::vector bgra; std::vector rgb; int w = 0, h = 0; @@ -154,9 +155,11 @@ void WorkerLoop(std::wstring symlink, int req_w, int req_h) { rgb[i * 3 + 2] = bgra[i * 4 + 0]; } - PoseResult pose = estimator.run(rgb.data(), w, h, roi); + PoseResult pose = have_lock ? estimator.run(rgb.data(), w, h, roi) + : estimator.acquire(rgb.data(), w, h); const bool tracked = pose.valid && pose.presence >= cfg.presence_threshold; - roi = tracked ? pose.next_roi : PoseEstimator::bootstrap_roi(w, h); + have_lock = tracked; + if (tracked) roi = pose.next_roi; LARGE_INTEGER now; QueryPerformanceCounter(&now);