draw right eye with blue color

PiperOrigin-RevId: 525508840
This commit is contained in:
MediaPipe Team 2023-04-19 11:45:24 -07:00 committed by Copybara-Service
parent b2586e7e3b
commit 3231591f7f

View File

@ -107,6 +107,10 @@ const int kFaceMeshFaceOval[36][2] = {
{152, 148}, {148, 176}, {176, 149}, {149, 150}, {150, 136}, {136, 172}, {152, 148}, {148, 176}, {176, 149}, {149, 150}, {150, 136}, {136, 172},
{172, 58}, {58, 132}, {132, 93}, {93, 234}, {234, 127}, {127, 162}, {172, 58}, {58, 132}, {132, 93}, {93, 234}, {234, 127}, {127, 162},
{162, 21}, {21, 54}, {54, 103}, {103, 67}, {67, 109}, {109, 10}}; {162, 21}, {21, 54}, {54, 103}, {103, 67}, {67, 109}, {109, 10}};
const cv::Scalar kRightEyeColor = cv::Scalar(255.0, 48.0, 48.0);
const cv::Scalar kLeftEyeColor = cv::Scalar(48.0, 255.0, 48.0);
const cv::Scalar kFaceContourColor = cv::Scalar(224.0, 224.0, 224.0);
} // namespace } // namespace
namespace mediapipe { namespace mediapipe {
@ -180,49 +184,48 @@ void DrawFace(const mediapipe::NormalizedLandmarkList& face, bool flip_y,
constexpr int draw_line_width = 2; constexpr int draw_line_width = 2;
for (int j = 0; j < 36; ++j) { for (int j = 0; j < 36; ++j) {
cv::line(*image, landmarks[kFaceMeshFaceOval[j][0]], cv::line(*image, landmarks[kFaceMeshFaceOval[j][0]],
landmarks[kFaceMeshFaceOval[j][1]], cv::Scalar(224, 224, 224), landmarks[kFaceMeshFaceOval[j][1]], kFaceContourColor,
draw_line_width); draw_line_width);
} }
for (int j = 0; j < 40; ++j) { for (int j = 0; j < 40; ++j) {
cv::line(*image, landmarks[kFaceMeshLips[j][0]], cv::line(*image, landmarks[kFaceMeshLips[j][0]],
landmarks[kFaceMeshLips[j][1]], cv::Scalar(224, 224, 224), landmarks[kFaceMeshLips[j][1]], kFaceContourColor,
draw_line_width); draw_line_width);
} }
for (int j = 0; j < 16; ++j) { for (int j = 0; j < 16; ++j) {
cv::line(*image, landmarks[kFaceMeshLeftEye[j][0]], cv::line(*image, landmarks[kFaceMeshLeftEye[j][0]],
landmarks[kFaceMeshLeftEye[j][1]], cv::Scalar(48, 255, 48), landmarks[kFaceMeshLeftEye[j][1]], kLeftEyeColor, draw_line_width);
draw_line_width);
} }
for (int j = 0; j < 8; ++j) { for (int j = 0; j < 8; ++j) {
cv::line(*image, landmarks[kFaceMeshLeftEyebrow[j][0]], cv::line(*image, landmarks[kFaceMeshLeftEyebrow[j][0]],
landmarks[kFaceMeshLeftEyebrow[j][1]], cv::Scalar(48, 255, 48), landmarks[kFaceMeshLeftEyebrow[j][1]], kLeftEyeColor,
draw_line_width); draw_line_width);
} }
for (int j = 0; j < 4; ++j) { for (int j = 0; j < 4; ++j) {
cv::line(*image, landmarks[kFaceMeshLeftIris[j][0]], cv::line(*image, landmarks[kFaceMeshLeftIris[j][0]],
landmarks[kFaceMeshLeftIris[j][1]], cv::Scalar(48, 255, 48), landmarks[kFaceMeshLeftIris[j][1]], kLeftEyeColor,
draw_line_width); draw_line_width);
} }
for (int j = 0; j < 16; ++j) { for (int j = 0; j < 16; ++j) {
cv::line(*image, landmarks[kFaceMeshRightEye[j][0]], cv::line(*image, landmarks[kFaceMeshRightEye[j][0]],
landmarks[kFaceMeshRightEye[j][1]], cv::Scalar(48, 48, 255), landmarks[kFaceMeshRightEye[j][1]], kRightEyeColor,
draw_line_width); draw_line_width);
} }
for (int j = 0; j < 8; ++j) { for (int j = 0; j < 8; ++j) {
cv::line(*image, landmarks[kFaceMeshRightEyebrow[j][0]], cv::line(*image, landmarks[kFaceMeshRightEyebrow[j][0]],
landmarks[kFaceMeshRightEyebrow[j][1]], cv::Scalar(48, 48, 255), landmarks[kFaceMeshRightEyebrow[j][1]], kRightEyeColor,
draw_line_width); draw_line_width);
} }
for (int j = 0; j < 4; ++j) { for (int j = 0; j < 4; ++j) {
cv::line(*image, landmarks[kFaceMeshRightIris[j][0]], cv::line(*image, landmarks[kFaceMeshRightIris[j][0]],
landmarks[kFaceMeshRightIris[j][1]], cv::Scalar(48, 48, 255), landmarks[kFaceMeshRightIris[j][1]], kRightEyeColor,
draw_line_width); draw_line_width);
} }
} }