Internal change
PiperOrigin-RevId: 477863040
This commit is contained in:
parent
e7acc0a857
commit
8af4cca413
|
@ -184,6 +184,17 @@ absl::Status LabelsToRenderDataCalculator::Process(CalculatorContext* cc) {
|
||||||
text->set_left(label_left_px_);
|
text->set_left(label_left_px_);
|
||||||
text->set_baseline(label_baseline_px + i * label_height_px_);
|
text->set_baseline(label_baseline_px + i * label_height_px_);
|
||||||
text->set_font_face(options_.font_face());
|
text->set_font_face(options_.font_face());
|
||||||
|
if (options_.outline_thickness() > 0) {
|
||||||
|
text->set_outline_thickness(options_.outline_thickness());
|
||||||
|
if (options_.outline_color_size() > 0) {
|
||||||
|
*(text->mutable_outline_color()) =
|
||||||
|
options_.outline_color(i % options_.outline_color_size());
|
||||||
|
} else {
|
||||||
|
text->mutable_outline_color()->set_r(0);
|
||||||
|
text->mutable_outline_color()->set_g(0);
|
||||||
|
text->mutable_outline_color()->set_b(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
cc->Outputs()
|
cc->Outputs()
|
||||||
.Tag(kRenderDataTag)
|
.Tag(kRenderDataTag)
|
||||||
|
|
|
@ -30,6 +30,13 @@ message LabelsToRenderDataCalculatorOptions {
|
||||||
// Thickness for drawing the label(s).
|
// Thickness for drawing the label(s).
|
||||||
optional double thickness = 2 [default = 2];
|
optional double thickness = 2 [default = 2];
|
||||||
|
|
||||||
|
// Color of outline around each character, if any. One per label, as with
|
||||||
|
// color attribute.
|
||||||
|
repeated Color outline_color = 12;
|
||||||
|
|
||||||
|
// Thickness of outline around each character.
|
||||||
|
optional double outline_thickness = 11;
|
||||||
|
|
||||||
// The font height in absolute pixels.
|
// The font height in absolute pixels.
|
||||||
optional int32 font_height_px = 3 [default = 50];
|
optional int32 font_height_px = 3 [default = 50];
|
||||||
|
|
||||||
|
|
|
@ -552,6 +552,16 @@ void AnnotationRenderer::DrawText(const RenderAnnotation& annotation) {
|
||||||
origin.y += text_size.height / 2;
|
origin.y += text_size.height / 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (text.outline_thickness() > 0.0) {
|
||||||
|
const int background_thickness = ClampThickness(
|
||||||
|
round((annotation.thickness() + 2.0 * text.outline_thickness()) *
|
||||||
|
scale_factor_));
|
||||||
|
const cv::Scalar outline_color =
|
||||||
|
MediapipeColorToOpenCVColor(text.outline_color());
|
||||||
|
cv::putText(mat_image_, text.display_text(), origin, font_face, font_scale,
|
||||||
|
outline_color, background_thickness, /*lineType=*/8,
|
||||||
|
/*bottomLeftOrigin=*/flip_text_vertically_);
|
||||||
|
}
|
||||||
cv::putText(mat_image_, text.display_text(), origin, font_face, font_scale,
|
cv::putText(mat_image_, text.display_text(), origin, font_face, font_scale,
|
||||||
color, thickness, /*lineType=*/8,
|
color, thickness, /*lineType=*/8,
|
||||||
/*bottomLeftOrigin=*/flip_text_vertically_);
|
/*bottomLeftOrigin=*/flip_text_vertically_);
|
||||||
|
|
|
@ -168,6 +168,12 @@ message RenderAnnotation {
|
||||||
// [left, baseline] represent [center_x, center_y].
|
// [left, baseline] represent [center_x, center_y].
|
||||||
optional bool center_horizontally = 7 [default = false];
|
optional bool center_horizontally = 7 [default = false];
|
||||||
optional bool center_vertically = 8 [default = false];
|
optional bool center_vertically = 8 [default = false];
|
||||||
|
|
||||||
|
// Thickness of the text outline.
|
||||||
|
optional double outline_thickness = 11 [default = 0.0];
|
||||||
|
|
||||||
|
// Color of the text outline.
|
||||||
|
optional Color outline_color = 12;
|
||||||
}
|
}
|
||||||
|
|
||||||
// The RenderAnnotation can be one of the below formats.
|
// The RenderAnnotation can be one of the below formats.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user