tracker-native: draw skeleton bones in preview; windows-nui: revert diagnostic fixed-Position probe
This commit is contained in:
1 parent
d651fc89b0
commit
6c886ae328
1 file changed
+43
@@ -93,6 +93,35 @@ void DrawOverlay(std::vector<uint8_t>& bgra, int w, int h, const PoseResult& pos
|
||||
}
|
||||
}
|
||||
};
|
||||
auto draw_line = [&](int x0, int y0, int x1, int y1, uint8_t b, uint8_t g,
|
||||
uint8_t r) {
|
||||
const int dx = x1 > x0 ? x1 - x0 : x0 - x1;
|
||||
const int sx = x0 < x1 ? 1 : -1;
|
||||
const int dy = -(y1 > y0 ? y1 - y0 : y0 - y1);
|
||||
const int sy = y0 < y1 ? 1 : -1;
|
||||
int err = dx + dy;
|
||||
for (;;) {
|
||||
for (int oy = -1; oy <= 1; ++oy)
|
||||
for (int ox = -1; ox <= 1; ++ox) {
|
||||
const int px = x0 + ox, py = y0 + oy;
|
||||
if (px < 0 || py < 0 || px >= w || py >= h) continue;
|
||||
uint8_t* p = &bgra[(static_cast<size_t>(py) * w + px) * 4];
|
||||
p[0] = b;
|
||||
p[1] = g;
|
||||
p[2] = r;
|
||||
}
|
||||
if (x0 == x1 && y0 == y1) break;
|
||||
const int e2 = 2 * err;
|
||||
if (e2 >= dy) {
|
||||
err += dy;
|
||||
x0 += sx;
|
||||
}
|
||||
if (e2 <= dx) {
|
||||
err += dx;
|
||||
y0 += sy;
|
||||
}
|
||||
}
|
||||
};
|
||||
if (!pose.image_mask.empty() && pose.image_mask_width == w &&
|
||||
pose.image_mask_height == h) {
|
||||
for (size_t i = 0; i < static_cast<size_t>(w) * h; ++i) {
|
||||
@@ -102,6 +131,20 @@ void DrawOverlay(std::vector<uint8_t>& bgra, int w, int h, const PoseResult& pos
|
||||
}
|
||||
}
|
||||
}
|
||||
// Skeleton bones (MediaPipe-33 body connections): torso, arms, legs, neck.
|
||||
static const int kBones[][2] = {
|
||||
{11, 12}, {11, 13}, {13, 15}, {12, 14}, {14, 16}, {11, 23}, {12, 24},
|
||||
{23, 24}, {23, 25}, {25, 27}, {27, 29}, {29, 31}, {24, 26}, {26, 28},
|
||||
{28, 30}, {30, 32}, {0, 11}, {0, 12}};
|
||||
for (const auto& bone : kBones) {
|
||||
const int a = bone[0], c = bone[1];
|
||||
const bool vis = pose.visibility[a] > 0.5f && pose.visibility[c] > 0.5f;
|
||||
draw_line(static_cast<int>(pose.image_xy[a * 2]),
|
||||
static_cast<int>(pose.image_xy[a * 2 + 1]),
|
||||
static_cast<int>(pose.image_xy[c * 2]),
|
||||
static_cast<int>(pose.image_xy[c * 2 + 1]),
|
||||
vis ? 0 : 150, vis ? 255 : 150, vis ? 0 : 150);
|
||||
}
|
||||
for (int i = 0; i < kBodyLandmarks; ++i) {
|
||||
const int x = static_cast<int>(pose.image_xy[i * 2]);
|
||||
const int y = static_cast<int>(pose.image_xy[i * 2 + 1]);
|
||||
|
||||
Reference in new issue
Block a user