mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 13:26:30 +00:00
add db WIP 2, 80%
refactor, renames
This commit is contained in:
@@ -2,15 +2,16 @@
|
||||
using System.Windows.Input;
|
||||
using Azaion.Common.DTO;
|
||||
using Azaion.Common.DTO.Config;
|
||||
using Azaion.Common.DTO.Queue;
|
||||
using Azaion.Common.Services;
|
||||
using MediatR;
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace Azaion.Dataset;
|
||||
|
||||
public class DatasetExplorerEventHandler(DatasetExplorer datasetExplorer, IGalleryManager galleryManager, IOptions<DirectoriesConfig> directoriesConfig)
|
||||
:
|
||||
INotificationHandler<KeyEvent>,
|
||||
INotificationHandler<ImageCreatedEvent>
|
||||
public class DatasetExplorerEventHandler(
|
||||
DatasetExplorer datasetExplorer,
|
||||
AnnotationService annotationService) : INotificationHandler<KeyEvent>
|
||||
{
|
||||
private readonly Dictionary<Key, PlaybackControlEnum> _keysControlEnumDict = new()
|
||||
{
|
||||
@@ -48,14 +49,13 @@ public class DatasetExplorerEventHandler(DatasetExplorer datasetExplorer, IGalle
|
||||
if (datasetExplorer.ThumbnailLoading)
|
||||
return;
|
||||
|
||||
var currentAnns = datasetExplorer.ExplorerEditor.CurrentAnns
|
||||
.Select(x => new YoloLabel(x.Info, datasetExplorer.ExplorerEditor.RenderSize, datasetExplorer.ExplorerEditor.RenderSize))
|
||||
.ToList();
|
||||
var fName = Path.GetFileNameWithoutExtension(datasetExplorer.CurrentAnnotation!.Annotation.ImagePath);
|
||||
var extension = Path.GetExtension(fName);
|
||||
|
||||
await YoloLabel.WriteToFile(currentAnns, Path.Combine(directoriesConfig.Value.LabelsDirectory, datasetExplorer.CurrentThumbnail!.LabelPath));
|
||||
await galleryManager.CreateThumbnail(datasetExplorer.CurrentThumbnail.ImagePath);
|
||||
await galleryManager.SaveLabelsCache();
|
||||
datasetExplorer.CurrentThumbnail.UpdateImage();
|
||||
var detections = datasetExplorer.ExplorerEditor.CurrentDetections
|
||||
.Select(x => new Detection(fName, x.GetLabel(datasetExplorer.ExplorerEditor.RenderSize)))
|
||||
.ToList();
|
||||
await annotationService.SaveAnnotation(fName, extension, detections, SourceEnum.Manual);
|
||||
datasetExplorer.SwitchTab(toEditor: false);
|
||||
break;
|
||||
case PlaybackControlEnum.RemoveSelectedAnns:
|
||||
@@ -69,12 +69,4 @@ public class DatasetExplorerEventHandler(DatasetExplorer datasetExplorer, IGalle
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task Handle(ImageCreatedEvent imageCreatedEvent, CancellationToken cancellationToken)
|
||||
{
|
||||
var (thumbnailDto, detections) = await galleryManager.CreateThumbnail(imageCreatedEvent.ImagePath, cancellationToken);
|
||||
if (thumbnailDto != null && detections != null)
|
||||
datasetExplorer.AddThumbnail(thumbnailDto, detections);
|
||||
await galleryManager.SaveLabelsCache();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user