mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 15:56:30 +00:00
add manual Tile Processor
zoom on video on pause (temp image)
This commit is contained in:
@@ -12,15 +12,15 @@ namespace Azaion.Common.Controls;
|
||||
public class DetectionControl : Border
|
||||
{
|
||||
private readonly Action<object, MouseButtonEventArgs> _resizeStart;
|
||||
private const double RESIZE_RECT_SIZE = 12;
|
||||
private const double RESIZE_RECT_SIZE = 10;
|
||||
|
||||
private readonly Grid _grid;
|
||||
private readonly Label _detectionLabel;
|
||||
private readonly DetectionLabelPanel _detectionLabelPanel;
|
||||
//private readonly Label _detectionLabel;
|
||||
public readonly Canvas DetectionLabelContainer;
|
||||
|
||||
public TimeSpan Time { get; set; }
|
||||
private readonly double _confidence;
|
||||
private List<Rectangle> _resizedRectangles = new();
|
||||
private readonly List<Rectangle> _resizedRectangles = new();
|
||||
|
||||
private DetectionClass _detectionClass = null!;
|
||||
public DetectionClass DetectionClass
|
||||
@@ -33,9 +33,8 @@ public class DetectionControl : Border
|
||||
BorderThickness = new Thickness(3);
|
||||
foreach (var rect in _resizedRectangles)
|
||||
rect.Stroke = brush;
|
||||
|
||||
_detectionLabel.Background = new SolidColorBrush(value.Color.ToConfidenceColor(_confidence));
|
||||
_detectionLabel.Content = _detectionLabelText(value.UIName);
|
||||
|
||||
_detectionLabelPanel.DetectionClass = value;
|
||||
_detectionClass = value;
|
||||
}
|
||||
}
|
||||
@@ -78,10 +77,7 @@ public class DetectionControl : Border
|
||||
DetectionLabelContainer.VerticalAlignment = value.Vertical;
|
||||
}
|
||||
}
|
||||
|
||||
private string _detectionLabelText(string detectionClassName) =>
|
||||
_confidence >= 0.995 ? detectionClassName : $"{detectionClassName}: {_confidence * 100:F0}%"; //double
|
||||
|
||||
|
||||
public DetectionControl(DetectionClass detectionClass, TimeSpan time, Action<object,
|
||||
MouseButtonEventArgs> resizeStart, CanvasLabel canvasLabel)
|
||||
{
|
||||
@@ -89,7 +85,6 @@ public class DetectionControl : Border
|
||||
Height = canvasLabel.Height;
|
||||
Time = time;
|
||||
_resizeStart = resizeStart;
|
||||
_confidence = canvasLabel.Confidence;
|
||||
|
||||
DetectionLabelContainer = new Canvas
|
||||
{
|
||||
@@ -97,16 +92,16 @@ public class DetectionControl : Border
|
||||
VerticalAlignment = VerticalAlignment.Top,
|
||||
ClipToBounds = false,
|
||||
};
|
||||
_detectionLabel = new Label
|
||||
_detectionLabelPanel = new DetectionLabelPanel
|
||||
{
|
||||
Content = _detectionLabelText(detectionClass.Name),
|
||||
FontSize = 16,
|
||||
Visibility = Visibility.Visible
|
||||
Confidence = canvasLabel.Confidence
|
||||
};
|
||||
DetectionLabelContainer.Children.Add(_detectionLabel);
|
||||
|
||||
DetectionLabelContainer.Children.Add(_detectionLabelPanel);
|
||||
|
||||
_selectionFrame = new Rectangle
|
||||
{
|
||||
Margin = new Thickness(-3),
|
||||
HorizontalAlignment = HorizontalAlignment.Stretch,
|
||||
VerticalAlignment = VerticalAlignment.Stretch,
|
||||
Stroke = new SolidColorBrush(Colors.Black),
|
||||
@@ -146,12 +141,13 @@ public class DetectionControl : Border
|
||||
var rect = new Rectangle() // small rectangles at the corners and sides
|
||||
{
|
||||
ClipToBounds = false,
|
||||
Margin = new Thickness(-RESIZE_RECT_SIZE * 0.7),
|
||||
Margin = new Thickness(-RESIZE_RECT_SIZE),
|
||||
HorizontalAlignment = ha,
|
||||
VerticalAlignment = va,
|
||||
Width = RESIZE_RECT_SIZE,
|
||||
Height = RESIZE_RECT_SIZE,
|
||||
Stroke = new SolidColorBrush(Color.FromArgb(230, 20, 20, 20)), // small rectangles color
|
||||
StrokeThickness = 0.8,
|
||||
Fill = new SolidColorBrush(Color.FromArgb(150, 80, 80, 80)),
|
||||
Cursor = crs,
|
||||
Name = name,
|
||||
@@ -160,9 +156,9 @@ public class DetectionControl : Border
|
||||
return rect;
|
||||
}
|
||||
|
||||
public YoloLabel GetLabel(Size canvasSize, Size? videoSize = null)
|
||||
{
|
||||
var label = new CanvasLabel(DetectionClass.YoloId, Canvas.GetLeft(this), Canvas.GetTop(this), Width, Height);
|
||||
return new YoloLabel(label, canvasSize, videoSize);
|
||||
}
|
||||
public CanvasLabel ToCanvasLabel() =>
|
||||
new(DetectionClass.YoloId, Canvas.GetLeft(this), Canvas.GetTop(this), Width, Height);
|
||||
|
||||
public YoloLabel ToYoloLabel(Size canvasSize, Size? videoSize = null) =>
|
||||
new(ToCanvasLabel(), canvasSize, videoSize);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user