add rgbaToGray at ColorConvertCalculator

This commit is contained in:
mapleyuan 2020-11-05 20:20:51 +08:00
parent f15da632de
commit 03de94d3a4

View File

@ -57,6 +57,8 @@ constexpr char kGrayOutTag[] = "GRAY_OUT";
// RGB -> RGBA
// RGBA -> BGRA
// BGRA -> RGBA
// RGBA -> GRAY
//
// This calculator only supports a single input stream and output stream at a
// time. If more than one input stream or output stream is present, the
@ -196,6 +198,12 @@ REGISTER_CALCULATOR(ColorConvertCalculator);
cv::COLOR_RGBA2BGRA, cc);
}
// RGBA -> GRAY
if (cc->Inputs().HasTag(kRgbaInTag) && cc->Outputs().HasTag(kGrayOutTag)) {
return ConvertAndOutput(kRgbaInTag, kGrayOutTag, ImageFormat::GRAY8,
cv::COLOR_RGBA2GRAY, cc);
}
return ::mediapipe::InvalidArgumentErrorBuilder(MEDIAPIPE_LOC)
<< "Unsupported image format conversion.";
}