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
+5 -3
View File
@@ -313,11 +313,13 @@ public class AnnotatorEventHandler(
private async Task<List<Annotation>> SaveAnnotationInner(string imgPath, CancellationToken cancellationToken = default)
{
var canvasDetections = mainWindow.Editor.CurrentDetections.Select(x => x.ToCanvasLabel()).ToList();
var source = (mainWindow.Editor.BackgroundImage.Source as BitmapSource)!;
var mediaSize = new Size(source.PixelWidth, source.PixelHeight);
var annotationsResult = new List<Annotation>();
if (!File.Exists(imgPath))
{
var source = (mainWindow.Editor.BackgroundImage.Source as BitmapSource)!;
if (new Size(source.PixelWidth, source.PixelHeight).FitSizeForAI())
if (mediaSize.FitSizeForAI())
await source.SaveImage(imgPath, cancellationToken);
else
{
@@ -356,7 +358,7 @@ public class AnnotatorEventHandler(
var timeImg = formState.BackgroundTime ?? TimeSpan.FromMilliseconds(mediaPlayer.Time);
var annName = formState.MediaName.ToTimeName(timeImg);
var currentDetections = canvasDetections.Select(x =>
new Detection(annName, new YoloLabel(x, mainWindow.Editor.RenderSize)))
new Detection(annName, new YoloLabel(x, mainWindow.Editor.RenderSize, mediaSize)))
.ToList();
var annotation = await annotationService.SaveAnnotation(formState.MediaName, annName, timeImg, currentDetections, token: cancellationToken);
return [annotation];