Movenet model, input size is 192x192.
Base class for detecting poses of people.
Input is an image (cv:Mat).
Output is
MovenetResult
.
Sample code:
auto image = cv::imread(argv[2]);
if (image.empty()) {
std::cerr << "cannot load " << argv[2] << std::endl;
abort();
}
auto det = vitis::ai::Movenet::create(argv[1]);
vector<vector<int>> limbSeq = {{0, 1}, {0, 2},{0, 3},{0, 4},{0, 5},{0, 6},
{5, 7}, {7, 9}, {6, 8}, {8, 10},
{5, 11}, {6, 12}, {11, 13}, {13, 15},
{12, 14}, {14, 16}};
auto results = det->run(image.clone());
for (size_t i = 0; i < results.poses.size(); ++i) {
cout<< results.poses[i]<<endl;
if (results.poses[i].y >0 && results.poses[i].x > 0) {
cv::putText(image, to_string(i),results.poses[i],
cv::FONT_HERSHEY_COMPLEX, 1, cv::Scalar(0, 255, 255), 1, 1, 0);
cv::circle(image, results.poses[i], 5, cv::Scalar(0, 255, 0),
-1);
}
}
for (size_t i = 0; i < limbSeq.size(); ++i) {
auto a = results.poses[limbSeq[i][0]];
auto b = results.poses[limbSeq[i][1]];
if (a.x >0 && b.x > 0) {
cv::line(image, a, b, cv::Scalar(255, 0, 0), 3, 4);
}
}
Display of the movenet model results: width=400px
Figure 1. movenet result image
Declaration
typedef struct
{
int width;
int height;
std::vector< cv::Point2f > poses;
} vitis::ai::MovenetResult;
Member | Description |
---|---|
width | Width of input image. |
height | Height of input image. |
poses |
A vector of pose, pose is represented by a vector of Point. Joint points are arranged in order 0: 'nose', 1: 'left_eye', 2: 'right_eye', 3: 'left_ear', 4: 'right_ear', 5: 'left_shoulder', 6: 'right_shoulder', 7: 'left_elbow', 8: 'right_elbow', 9: 'left_wrist', 10 : 'right_wrist', 11: 'left_hip', 12: 'right_hip', 13: 'left_knee', 14: 'right_knee', 15: 'left_ankle', 16: 'right_ankle'] |