switcher dataset explorer

lat lon -> geopoint
correct location for gps if small keypoints number
This commit is contained in:
Alex Bezdieniezhnykh
2025-06-23 20:47:28 +03:00
parent c5e72669c5
commit 253f811125
31 changed files with 469 additions and 192 deletions
+44 -8
View File
@@ -1,4 +1,5 @@
using System.Windows;
using System.Drawing;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;
using System.Windows.Media;
@@ -7,7 +8,9 @@ using Azaion.Annotator.DTO;
using Azaion.Common.DTO;
using MediatR;
using Color = System.Windows.Media.Color;
using Point = System.Windows.Point;
using Rectangle = System.Windows.Shapes.Rectangle;
using Size = System.Windows.Size;
namespace Azaion.Common.Controls;
@@ -160,7 +163,7 @@ public class CanvasEditor : Canvas
return;
var time = GetTimeFunc();
CreateDetectionControl(CurrentAnnClass, time, new CanvasLabel
var control = CreateDetectionControl(CurrentAnnClass, time, new CanvasLabel
{
Width = width,
Height = height,
@@ -168,12 +171,44 @@ public class CanvasEditor : Canvas
Y = Math.Min(endPos.Y, _newAnnotationStartPos.Y),
Confidence = 1
});
control.UpdateLayout();
CheckLabelBoundaries(control);
SelectionState = SelectionState.None;
e.Handled = true;
}
else
{
CheckLabelBoundaries(_curAnn);
SelectionState = SelectionState.None;
e.Handled = true;
}
SelectionState = SelectionState.None;
e.Handled = true;
}
private void CheckLabelBoundaries(DetectionControl detectionControl)
{
var lb = detectionControl.DetectionLabelContainer;
var origin = lb.TranslatePoint(new Point(0, 0), this);
lb.Children[0].Measure(new Size(double.PositiveInfinity, double.PositiveInfinity));
var size = lb.Children[0].DesiredSize;
var lbRect = new RectangleF((float)origin.X, (float)origin.Y, (float)size.Width, (float)size.Height);
foreach (var c in CurrentDetections)
{
if (c == detectionControl)
continue;
var detRect = new RectangleF((float)GetLeft(c), (float)GetTop(c), (float)c.Width, (float)c.Height);
detRect.Intersect(lbRect);
// var intersect = detections[i].ToRectangle();
// intersect.Intersect(detections[j].ToRectangle());
// detectionControl.
// var otherControls = allControls.Where(c => c != control);
// control.UpdateLabelPosition(otherControls);
}
}
private void CanvasResized(object sender, SizeChangedEventArgs e)
{
_horizontalLine.X2 = e.NewSize.Width;
@@ -253,7 +288,7 @@ public class CanvasEditor : Canvas
ClearSelections();
_curAnn.IsSelected = true;
SelectionState = SelectionState.AnnMoving;
e.Handled = true;
}
@@ -315,7 +350,7 @@ public class CanvasEditor : Canvas
}
}
private void CreateDetectionControl(DetectionClass detectionClass, TimeSpan time, CanvasLabel canvasLabel)
private DetectionControl CreateDetectionControl(DetectionClass detectionClass, TimeSpan time, CanvasLabel canvasLabel)
{
var detectionControl = new DetectionControl(detectionClass, time, AnnotationResizeStart, canvasLabel);
detectionControl.MouseDown += AnnotationPositionStart;
@@ -324,6 +359,7 @@ public class CanvasEditor : Canvas
Children.Add(detectionControl);
CurrentDetections.Add(detectionControl);
_newAnnotationRect.Fill = new SolidColorBrush(detectionClass.Color);
return detectionControl;
}
#endregion
+15 -7
View File
@@ -16,6 +16,8 @@ public class DetectionControl : Border
private readonly Grid _grid;
private readonly Label _detectionLabel;
public readonly Canvas DetectionLabelContainer;
public TimeSpan Time { get; set; }
private readonly double _confidence;
private List<Rectangle> _resizedRectangles = new();
@@ -51,6 +53,16 @@ public class DetectionControl : Border
}
}
public (HorizontalAlignment Horizontal, VerticalAlignment Vertical) DetectionLabelPosition
{
get => (DetectionLabelContainer.HorizontalAlignment, DetectionLabelContainer.VerticalAlignment);
set
{
DetectionLabelContainer.HorizontalAlignment = value.Horizontal;
DetectionLabelContainer.VerticalAlignment = value.Vertical;
}
}
private string _detectionLabelText(string detectionClassName) =>
_confidence >= 0.995 ? detectionClassName : $"{detectionClassName}: {_confidence * 100:F0}%"; //double
@@ -62,23 +74,19 @@ public class DetectionControl : Border
_resizeStart = resizeStart;
_confidence = canvasLabel.Confidence;
var labelContainer = new Canvas
DetectionLabelContainer = new Canvas
{
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Top,
ClipToBounds = false,
Margin = new Thickness(0, 0, 32, 0)
};
_detectionLabel = new Label
{
Content = _detectionLabelText(detectionClass.Name),
HorizontalAlignment = HorizontalAlignment.Right,
VerticalAlignment = VerticalAlignment.Top,
Margin = new Thickness(0, -32, 0, 0),
FontSize = 16,
Visibility = Visibility.Visible
};
labelContainer.Children.Add(_detectionLabel);
DetectionLabelContainer.Children.Add(_detectionLabel);
_selectionFrame = new Rectangle
{
@@ -108,7 +116,7 @@ public class DetectionControl : Border
};
foreach (var rect in _resizedRectangles)
_grid.Children.Add(rect);
_grid.Children.Add(labelContainer);
_grid.Children.Add(DetectionLabelContainer);
Child = _grid;
Cursor = Cursors.SizeAll;