Skip to content

Commit 31b099a

Browse files
authored
add coco whole-body skeleton (#1736)
1 parent a3311b0 commit 31b099a

File tree

3 files changed

+46
-3
lines changed

3 files changed

+46
-3
lines changed

demo/csrc/cpp/pose_tracker.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ DEFINE_int32(output_size, 0, "Long-edge of output frames");
1717
DEFINE_int32(flip, 0, "Set to 1 for flipping the input horizontally");
1818
DEFINE_int32(show, 1, "Delay passed to `cv::waitKey` when using `cv::imshow`; -1: disable");
1919

20-
DEFINE_string(skeleton, "coco", R"(Path to skeleton data or name of predefined skeletons: "coco")");
20+
DEFINE_string(skeleton, "coco",
21+
R"(Path to skeleton data or name of predefined skeletons: "coco", "coco-wholebody")");
2122
DEFINE_string(background, "default",
2223
R"(Output background, "default": original image, "black": black background)");
2324

demo/csrc/cpp/utils/skeleton.h

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct Skeleton {
1919
static Skeleton get(const std::string& path);
2020
};
2121

22-
const Skeleton& gCocoSkeleton() {
22+
const Skeleton& gSkeletonCoco() {
2323
static const Skeleton inst{
2424
{
2525
{15, 13}, {13, 11}, {16, 14}, {14, 12}, {11, 12}, {5, 11}, {6, 12},
@@ -38,6 +38,41 @@ const Skeleton& gCocoSkeleton() {
3838
return inst;
3939
}
4040

41+
const Skeleton& gSkeletonCocoWholeBody() {
42+
static const Skeleton inst{
43+
{
44+
{15, 13}, {13, 11}, {16, 14}, {14, 12}, {11, 12}, {5, 11}, {6, 12},
45+
{5, 6}, {5, 7}, {6, 8}, {7, 9}, {8, 10}, {1, 2}, {0, 1},
46+
{0, 2}, {1, 3}, {2, 4}, {3, 5}, {4, 6}, {15, 17}, {15, 18},
47+
{15, 19}, {16, 20}, {16, 21}, {16, 22}, {91, 92}, {92, 93}, {93, 94},
48+
{94, 95}, {91, 96}, {96, 97}, {97, 98}, {98, 99}, {91, 100}, {100, 101},
49+
{101, 102}, {102, 103}, {91, 104}, {104, 105}, {105, 106}, {106, 107}, {91, 108},
50+
{108, 109}, {109, 110}, {110, 111}, {112, 113}, {113, 114}, {114, 115}, {115, 116},
51+
{112, 117}, {117, 118}, {118, 119}, {119, 120}, {112, 121}, {121, 122}, {122, 123},
52+
{123, 124}, {112, 125}, {125, 126}, {126, 127}, {127, 128}, {112, 129}, {129, 130},
53+
{130, 131}, {131, 132},
54+
},
55+
{
56+
{51, 153, 255},
57+
{0, 255, 0},
58+
{255, 128, 0},
59+
{255, 255, 255},
60+
{255, 153, 255},
61+
{102, 178, 255},
62+
{255, 51, 51},
63+
},
64+
{1, 1, 2, 2, 0, 0, 0, 0, 1, 2, 1, 2, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1,
65+
2, 2, 2, 2, 2, 2, 2, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 1, 1, 1,
66+
1, 2, 2, 2, 2, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 1, 1, 1, 1},
67+
{0, 0, 0, 0, 0, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3,
68+
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
69+
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
70+
3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6,
71+
1, 1, 1, 1, 3, 2, 2, 2, 2, 4, 4, 4, 4, 5, 5, 5, 5, 6, 6, 6, 6, 1, 1, 1, 1},
72+
};
73+
return inst;
74+
}
75+
4176
// n_links
4277
// u0, v0, u1, v1, ..., un-1, vn-1
4378
// n_palette
@@ -48,7 +83,9 @@ const Skeleton& gCocoSkeleton() {
4883
// j0, j1, ..., jn-1
4984
inline Skeleton Skeleton::get(const std::string& path) {
5085
if (path == "coco") {
51-
return gCocoSkeleton();
86+
return gSkeletonCoco();
87+
} else if (path == "coco-wholebody") {
88+
return gSkeletonCocoWholeBody();
5289
}
5390
std::ifstream ifs(path);
5491
if (!ifs.is_open()) {

demo/csrc/cpp/utils/visualize.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,11 @@ class Visualize {
198198

199199
void add_pose(const mmdeploy_point_t* pts, const float* scores, int32_t pts_size, double thr) {
200200
auto& skel = v_.skeleton_;
201+
if (skel.point_colors.size() != pts_size) {
202+
std::cout << "error: mismatched number of keypoints: " << skel.point_colors.size() << " vs "
203+
<< pts_size << ", skip pose visualization.\n";
204+
return;
205+
}
201206
std::vector<int> used(pts_size);
202207
std::vector<int> is_end_point(pts_size);
203208
for (size_t i = 0; i < skel.links.size(); ++i) {

0 commit comments

Comments
 (0)