feat(tracker-native): full pose->mapping->synth->shm pipeline (headless-validated)
FramePipeline ties PoseEstimator to the existing C++ core: 33 landmarks -> core/mapping SkeletonMapper (20 Kinect joints), the image-space segmentation mask + skeleton -> core/synth DepthRasterizer (articulated packed depth), color -> passthrough_color, all published via ShmPublisher. PoseEstimator now also emits world-landmark z (Identity_4) and an image-space mask (inverse-affine warp). pipeline_probe on grace_hopper: tracking_id=1, 9/20 joints tracked, 56% body depth pixels, hip at (0,-1.05,2.5)m - the whole tracker brain verified without a camera. Remaining: Media Foundation capture + Dear ImGui GUI.
This commit is contained in:
1 parent
2715a706a0
commit
41534b07d1
6 files changed
+256
-2
No files matched your search
@@ -18,6 +18,11 @@ struct Affine2x3 {
|
||||
*x = a * u + b * v + tx;
|
||||
*y = c * u + d * v + ty;
|
||||
}
|
||||
Affine2x3 inverse() const {
|
||||
const float det = a * d - b * c;
|
||||
const float ia = d / det, ib = -b / det, ic = -c / det, id = a / det;
|
||||
return {ia, ib, -(ia * tx + ib * ty), ic, id, -(ic * tx + id * ty)};
|
||||
}
|
||||
};
|
||||
|
||||
// crop(u,v in [0,kLandmarkInput]) -> source-image pixel, matching
|
||||
@@ -110,13 +115,14 @@ PoseResult PoseEstimator::run(const uint8_t* rgb, int width, int height,
|
||||
Ort::Value input = Ort::Value::CreateTensor<float>(
|
||||
mi, input_.data(), input_.size(), shape.data(), shape.size());
|
||||
const char* in_names[] = {"input_1"};
|
||||
const char* out_names[] = {"Identity", "Identity_1", "Identity_2"};
|
||||
const char* out_names[] = {"Identity", "Identity_1", "Identity_2", "Identity_4"};
|
||||
auto outs = session_->Run(Ort::RunOptions{nullptr}, in_names, &input, 1,
|
||||
out_names, 3);
|
||||
out_names, 4);
|
||||
|
||||
const float* lm = outs[0].GetTensorData<float>();
|
||||
const float* pres = outs[1].GetTensorData<float>();
|
||||
const float* mask = outs[2].GetTensorData<float>();
|
||||
const float* world = outs[3].GetTensorData<float>();
|
||||
|
||||
PoseResult out;
|
||||
out.valid = true;
|
||||
@@ -129,10 +135,30 @@ PoseResult PoseEstimator::run(const uint8_t* rgb, int width, int height,
|
||||
out.image_xy[i * 2 + 0] = ix;
|
||||
out.image_xy[i * 2 + 1] = iy;
|
||||
out.z[i] = lm[i * 5 + 2];
|
||||
out.world_z[i] = world[i * 3 + 2];
|
||||
out.visibility[i] = Sigmoid(lm[i * 5 + 3]);
|
||||
}
|
||||
out.mask.assign(mask, mask + static_cast<size_t>(kMaskDim) * kMaskDim);
|
||||
|
||||
const Affine2x3 inv = m.inverse();
|
||||
out.image_mask_width = width;
|
||||
out.image_mask_height = height;
|
||||
out.image_mask.assign(static_cast<size_t>(width) * height, 0.0f);
|
||||
for (int iy = 0; iy < height; ++iy) {
|
||||
for (int ix = 0; ix < width; ++ix) {
|
||||
float cu, cv;
|
||||
inv.apply(static_cast<float>(ix), static_cast<float>(iy), &cu, &cv);
|
||||
const int u0 = static_cast<int>(std::floor(cu));
|
||||
const int v0 = static_cast<int>(std::floor(cv));
|
||||
if (u0 < 0 || v0 < 0 || u0 + 1 >= kMaskDim || v0 + 1 >= kMaskDim) continue;
|
||||
const float fu = cu - u0, fv = cv - v0;
|
||||
auto mv = [&](int u, int v) { return mask[static_cast<size_t>(v) * kMaskDim + u]; };
|
||||
const float top = mv(u0, v0) * (1 - fu) + mv(u0 + 1, v0) * fu;
|
||||
const float bot = mv(u0, v0 + 1) * (1 - fu) + mv(u0 + 1, v0 + 1) * fu;
|
||||
out.image_mask[static_cast<size_t>(iy) * width + ix] = Sigmoid(top * (1 - fv) + bot * fv);
|
||||
}
|
||||
}
|
||||
|
||||
out.next_roi = roi_from_points(out.image_xy[33 * 2], out.image_xy[33 * 2 + 1],
|
||||
out.image_xy[34 * 2], out.image_xy[34 * 2 + 1]);
|
||||
return out;
|
||||
|
||||
Reference in new issue
Block a user