mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 11:26:31 +00:00
fix saving scale for datasetexplorer and annotation
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user