Merge branch 'dev' into stage

This commit is contained in:
Alex Bezdieniezhnykh
2025-07-03 13:09:38 +03:00
4 changed files with 41 additions and 21 deletions
+14 -14
View File
@@ -41,7 +41,6 @@ public partial class Annotator
private readonly IInferenceService _inferenceService; private readonly IInferenceService _inferenceService;
private readonly IInferenceClient _inferenceClient; private readonly IInferenceClient _inferenceClient;
private ObservableCollection<DetectionClass> AnnotationClasses { get; set; } = new();
private bool _suspendLayout; private bool _suspendLayout;
private bool _gpsPanelVisible = false; private bool _gpsPanelVisible = false;
@@ -182,20 +181,21 @@ public partial class Annotator
if (_formState.CurrentMrl == _mediaPlayer.Media?.Mrl) if (_formState.CurrentMrl == _mediaPlayer.Media?.Mrl)
return; //already loaded all the info return; //already loaded all the info
await Dispatcher.Invoke(async () => await ReloadAnnotations());
//show image
if (_formState.CurrentMedia?.MediaType == MediaTypes.Image)
{
await Task.Delay(100); //wait to load the frame and set on pause
ShowTimeAnnotations(TimeSpan.FromMilliseconds(_mediaPlayer.Time), showImage: true);
return;
}
_formState.CurrentMrl = _mediaPlayer.Media?.Mrl ?? ""; _formState.CurrentMrl = _mediaPlayer.Media?.Mrl ?? "";
uint vw = 0, vh = 0; uint vw = 0, vh = 0;
_mediaPlayer.Size(0, ref vw, ref vh); _mediaPlayer.Size(0, ref vw, ref vh);
_formState.CurrentVideoSize = new Size(vw, vh); _formState.CurrentVideoSize = new Size(vw, vh);
_formState.CurrentVideoLength = TimeSpan.FromMilliseconds(_mediaPlayer.Length); _formState.CurrentVideoLength = TimeSpan.FromMilliseconds(_mediaPlayer.Length);
await Dispatcher.Invoke(async () => await ReloadAnnotations());
if (_formState.CurrentMedia?.MediaType == MediaTypes.Image)
{
await Task.Delay(100); //wait to load the frame and set on pause
ShowTimeAnnotations(TimeSpan.FromMilliseconds(_mediaPlayer.Time));
_mediaPlayer.SetPause(true);
}
}; };
LvFiles.MouseDoubleClick += async (_, _) => LvFiles.MouseDoubleClick += async (_, _) =>
@@ -268,7 +268,7 @@ public partial class Annotator
Editor.ClearExpiredAnnotations(res.Annotation.Time); Editor.ClearExpiredAnnotations(res.Annotation.Time);
}); });
ShowAnnotations(res.Annotation, showImage: true); ShowAnnotation(res.Annotation, showImage: true);
} }
private void SaveUserSettings() private void SaveUserSettings()
{ {
@@ -281,7 +281,7 @@ public partial class Annotator
_configUpdater.Save(_appConfig); _configUpdater.Save(_appConfig);
} }
private void ShowTimeAnnotations(TimeSpan time) private void ShowTimeAnnotations(TimeSpan time, bool showImage = false)
{ {
Dispatcher.Invoke(() => Dispatcher.Invoke(() =>
{ {
@@ -290,10 +290,10 @@ public partial class Annotator
Editor.ClearExpiredAnnotations(time); Editor.ClearExpiredAnnotations(time);
}); });
ShowAnnotations(TimedAnnotations.Query(time).FirstOrDefault()); ShowAnnotation(TimedAnnotations.Query(time).FirstOrDefault(), showImage);
} }
private void ShowAnnotations(Annotation? annotation, bool showImage = false) private void ShowAnnotation(Annotation? annotation, bool showImage = false)
{ {
if (annotation == null) if (annotation == null)
return; return;
+3 -3
View File
@@ -229,13 +229,13 @@ public class AnnotatorEventHandler(
mainWindow.Editor.ResetBackground(); mainWindow.Editor.ResetBackground();
formState.CurrentMedia = mediaInfo; formState.CurrentMedia = mediaInfo;
mainWindow.Title = $"Azaion Annotator - {mediaInfo.Name}";
//need to wait a bit for correct VLC playback event handling //need to wait a bit for correct VLC playback event handling
await Task.Delay(100, ct); await Task.Delay(100, ct);
mediaPlayer.Stop(); mediaPlayer.Stop();
mainWindow.Title = $"Azaion Annotator - {mediaInfo.Name}";
mediaPlayer.Play(new Media(libVLC, mediaInfo.Path)); mediaPlayer.Play(new Media(libVLC, mediaInfo.Path));
if (formState.CurrentMedia.MediaType == MediaTypes.Image)
mediaPlayer.SetPause(true);
} }
//SAVE: MANUAL //SAVE: MANUAL
+3
View File
@@ -149,6 +149,9 @@ public class CanvasEditor : Canvas
_matrixTransform.Matrix = matrix; _matrixTransform.Matrix = matrix;
_isZoomedIn = true; _isZoomedIn = true;
} }
foreach (var detection in CurrentDetections)
detection.UpdateAdornerScale(scale: _matrixTransform.Matrix.M11);
} }
private void Init(object sender, RoutedEventArgs e) private void Init(object sender, RoutedEventArgs e)
+18 -1
View File
@@ -43,6 +43,7 @@ public class DetectionControl : Border
private readonly Rectangle _selectionFrame; private readonly Rectangle _selectionFrame;
private bool _isSelected; private bool _isSelected;
public bool IsSelected public bool IsSelected
{ {
get => _isSelected; get => _isSelected;
@@ -53,6 +54,21 @@ public class DetectionControl : Border
} }
} }
public void UpdateAdornerScale(double scale)
{
if (Math.Abs(scale) < 0.0001)
return;
var inverseScale = 1.0 / scale;
BorderThickness = new Thickness(4 * inverseScale);
foreach (var rect in _resizedRectangles)
{
rect.Width = 2 * RESIZE_RECT_SIZE * inverseScale;
rect.Height = 2 * RESIZE_RECT_SIZE * inverseScale;;
rect.Margin = new Thickness(-RESIZE_RECT_SIZE * 0.7);
}
}
public (HorizontalAlignment Horizontal, VerticalAlignment Vertical) DetectionLabelPosition public (HorizontalAlignment Horizontal, VerticalAlignment Vertical) DetectionLabelPosition
{ {
get => (DetectionLabelContainer.HorizontalAlignment, DetectionLabelContainer.VerticalAlignment); get => (DetectionLabelContainer.HorizontalAlignment, DetectionLabelContainer.VerticalAlignment);
@@ -66,7 +82,8 @@ public class DetectionControl : Border
private string _detectionLabelText(string detectionClassName) => private string _detectionLabelText(string detectionClassName) =>
_confidence >= 0.995 ? detectionClassName : $"{detectionClassName}: {_confidence * 100:F0}%"; //double _confidence >= 0.995 ? detectionClassName : $"{detectionClassName}: {_confidence * 100:F0}%"; //double
public DetectionControl(DetectionClass detectionClass, TimeSpan time, Action<object, MouseButtonEventArgs> resizeStart, CanvasLabel canvasLabel) public DetectionControl(DetectionClass detectionClass, TimeSpan time, Action<object,
MouseButtonEventArgs> resizeStart, CanvasLabel canvasLabel)
{ {
Width = canvasLabel.Width; Width = canvasLabel.Width;
Height = canvasLabel.Height; Height = canvasLabel.Height;