fix saving scale for datasetexplorer and annotation

This commit is contained in:
Oleksandr Bezdieniezhnykh
2025-10-01 14:29:23 +03:00
parent 9b80eaf435
commit 99b9058187
4 changed files with 38 additions and 23 deletions
+19 -17
View File
@@ -1,4 +1,5 @@
using System.Windows.Input;
using System.Windows.Media.Imaging;
using Azaion.Common.Database;
using Azaion.Common.DTO;
using Azaion.Common.Events;
@@ -66,8 +67,9 @@ public class DatasetExplorerEventHandler(
var a = datasetExplorer.CurrentAnnotation!.Annotation;
var mediaSize = ((BitmapImage)datasetExplorer.ExplorerEditor.BackgroundImage.Source).Size();
var detections = datasetExplorer.ExplorerEditor.CurrentDetections
.Select(x => new Detection(a.Name, x.ToYoloLabel(datasetExplorer.ExplorerEditor.RenderSize)))
.Select(x => new Detection(a.Name, x.ToYoloLabel(datasetExplorer.ExplorerEditor.RenderSize, mediaSize)))
.ToList();
var index = datasetExplorer.ThumbnailsView.SelectedIndex;
var annotation = await annotationService.SaveAnnotation(a.OriginalMediaName, a.Name, a.Time, detections, token: token);
@@ -125,24 +127,24 @@ public class DatasetExplorerEventHandler(
var selectedClass = datasetExplorer.LvClasses.CurrentClassNumber;
datasetExplorer.AddAnnotationToDict(annotation);
if (annotation.Classes.Contains(selectedClass) || selectedClass == -1)
{
var index = 0;
var annThumb = new AnnotationThumbnail(annotation, azaionApi.CurrentUser.Role.IsValidator());
if (datasetExplorer.SelectedAnnotationDict.ContainsKey(annThumb.Annotation.Name))
{
datasetExplorer.SelectedAnnotationDict.Remove(annThumb.Annotation.Name);
var ann = datasetExplorer.SelectedAnnotations.FirstOrDefault(x => x.Annotation.Name == annThumb.Annotation.Name);
if (ann != null)
{
index = datasetExplorer.SelectedAnnotations.IndexOf(ann);
datasetExplorer.SelectedAnnotations.Remove(ann);
}
}
if (!annotation.Classes.Contains(selectedClass) && selectedClass != -1)
return;
datasetExplorer.SelectedAnnotations.Insert(index, annThumb);
datasetExplorer.SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
var index = 0;
var annThumb = new AnnotationThumbnail(annotation, azaionApi.CurrentUser.Role.IsValidator());
if (datasetExplorer.SelectedAnnotationDict.ContainsKey(annThumb.Annotation.Name))
{
datasetExplorer.SelectedAnnotationDict.Remove(annThumb.Annotation.Name);
var ann = datasetExplorer.SelectedAnnotations.FirstOrDefault(x => x.Annotation.Name == annThumb.Annotation.Name);
if (ann != null)
{
index = datasetExplorer.SelectedAnnotations.IndexOf(ann);
datasetExplorer.SelectedAnnotations.Remove(ann);
}
}
datasetExplorer.SelectedAnnotations.Insert(index, annThumb);
datasetExplorer.SelectedAnnotationDict.Add(annThumb.Annotation.Name, annThumb);
});
return Task.CompletedTask;
}