draw mouth to shoulder line after connection, to align with python viz code

PiperOrigin-RevId: 520935390
This commit is contained in:
MediaPipe Team 2023-03-31 09:02:35 -07:00 committed by Copybara-Service
parent 4dcb9a2201
commit 1ff80f906c

View File

@ -89,19 +89,6 @@ void DrawPose(const mediapipe::NormalizedLandmarkList& pose, int target_width,
constexpr int draw_line_width = 5; constexpr int draw_line_width = 5;
constexpr int draw_circle_radius = 7; constexpr int draw_circle_radius = 7;
const int lm = static_cast<int>(PoseLandmarkName::kMouthLeft);
const int rm = static_cast<int>(PoseLandmarkName::kMouthRight);
const int ls = static_cast<int>(PoseLandmarkName::kLeftShoulder);
const int rs = static_cast<int>(PoseLandmarkName::kRightShoulder);
if (visible_landmarks.find(lm) != visible_landmarks.end() &&
visible_landmarks.find(rm) != visible_landmarks.end() &&
visible_landmarks.find(ls) != visible_landmarks.end() &&
visible_landmarks.find(rs) != visible_landmarks.end()) {
cv::line(*image, (visible_landmarks[lm] + visible_landmarks[rm]) * 0.5f,
(visible_landmarks[ls] + visible_landmarks[rs]) * 0.5f,
cv::Scalar(255, 255, 255), draw_line_width);
}
for (int j = 0; j < 35; ++j) { for (int j = 0; j < 35; ++j) {
if (visible_landmarks.find(kJointConnection[j][0]) != if (visible_landmarks.find(kJointConnection[j][0]) !=
visible_landmarks.end() && visible_landmarks.end() &&
@ -115,6 +102,19 @@ void DrawPose(const mediapipe::NormalizedLandmarkList& pose, int target_width,
} }
} }
const int lm = static_cast<int>(PoseLandmarkName::kMouthLeft);
const int rm = static_cast<int>(PoseLandmarkName::kMouthRight);
const int ls = static_cast<int>(PoseLandmarkName::kLeftShoulder);
const int rs = static_cast<int>(PoseLandmarkName::kRightShoulder);
if (visible_landmarks.find(lm) != visible_landmarks.end() &&
visible_landmarks.find(rm) != visible_landmarks.end() &&
visible_landmarks.find(ls) != visible_landmarks.end() &&
visible_landmarks.find(rs) != visible_landmarks.end()) {
cv::line(*image, (visible_landmarks[lm] + visible_landmarks[rm]) * 0.5f,
(visible_landmarks[ls] + visible_landmarks[rs]) * 0.5f,
cv::Scalar(255, 255, 255), draw_line_width);
}
for (const auto& landmark : visible_landmarks) { for (const auto& landmark : visible_landmarks) {
cv::circle(*image, landmark.second, draw_circle_radius, cv::circle(*image, landmark.second, draw_circle_radius,
cv::Scalar(kJointColorMap[landmark.first][0], cv::Scalar(kJointColorMap[landmark.first][0],