Skip to content

Commit

Permalink
Draw label background opacity by confidence
Browse files Browse the repository at this point in the history
  • Loading branch information
dme-compunet committed Sep 29, 2024
1 parent c6f022e commit f2421b5
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Source/YoloV8/Plotting/PlottingExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public static Image PlotImage(this YoloResult<Pose> result, Image image, PosePlo
target.Mutate(context =>
{
context.DrawBox(points, color, boxBorderThickness, .1f);
context.DrawLabel(label, textLocation, color, boxBorderThickness, textPadding, textOptions);
context.DrawLabel(label,box.Confidence, textLocation, color, boxBorderThickness, textPadding, textOptions);

// Draw lines
for (var i = 0; i < options.Skeleton.Connections.Length; i++)
Expand Down Expand Up @@ -109,7 +109,7 @@ public static Image PlotImage(this YoloResult<Detection> result, Image image, De
target.Mutate(context =>
{
context.DrawBox(points, color, thickness, .1f);
context.DrawLabel(label, textLocation, color, thickness, textPadding, textOptions);
context.DrawLabel(label, box.Confidence, textLocation, color, thickness, textPadding, textOptions);
});
}

Expand Down Expand Up @@ -142,7 +142,7 @@ public static Image PlotImage(this YoloResult<ObbDetection> result, Image image,
target.Mutate(context =>
{
context.DrawBox(points, color, thickness, .1f);
context.DrawLabel(label, textLocation, color, thickness, textPadding, textOptions);
context.DrawLabel(label, box.Confidence, textLocation, color, thickness, textPadding, textOptions);
});
}

Expand Down Expand Up @@ -216,7 +216,7 @@ public static Image PlotImage(this YoloResult<Segmentation> result, Image image,
target.Mutate(context =>
{
context.DrawBox(points, color, thickness, .1f);
context.DrawLabel(label, textLocation, color, thickness, textPadding, textOptions);
context.DrawLabel(label, box.Confidence, textLocation, color, thickness, textPadding, textOptions);
});
}

Expand Down Expand Up @@ -267,7 +267,7 @@ private static void DrawBox(this IImageProcessingContext context, PointF[] point
}
}

private static void DrawLabel(this IImageProcessingContext context, string text, PointF location, Color color, float thickness, Vector2 padding, TextOptions options)
private static void DrawLabel(this IImageProcessingContext context, string text, float confidence, PointF location, Color color, float thickness, Vector2 padding, TextOptions options)
{
var xPadding = padding.X;
var yPadding = padding.Y;
Expand All @@ -283,7 +283,7 @@ private static void DrawLabel(this IImageProcessingContext context, string text,
// Fix text position
textLocation.Offset(0, -(yPadding * .1f));

context.Fill(color, textBoxPolygon);
context.Fill(color.WithAlpha(confidence), textBoxPolygon);
context.Draw(color, thickness, textBoxPolygon);

context.DrawText(text, options.Font, Color.White, textLocation);
Expand Down

0 comments on commit f2421b5

Please sign in to comment.