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.
This commit is contained in:
1 parent
f2783ce903
commit
5239ae5b81
4 files changed
+29
-3
No files matched your search
@@ -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<float>(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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<uint8_t> bgra;
|
||||
std::vector<uint8_t> 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);
|
||||
|
||||
Reference in new issue
Block a user