mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:56:31 +00:00
Errors sending to UI
notifying client of AI model conversion
This commit is contained in:
@@ -4,6 +4,7 @@ using System.Windows.Input;
|
||||
using Azaion.Annotator.DTO;
|
||||
using Azaion.Common;
|
||||
using Azaion.Common.DTO;
|
||||
using Azaion.Common.DTO.Config;
|
||||
using Azaion.Common.Events;
|
||||
using Azaion.Common.Extensions;
|
||||
using Azaion.Common.Services;
|
||||
@@ -21,16 +22,18 @@ public class AnnotatorEventHandler(
|
||||
MediaPlayer mediaPlayer,
|
||||
Annotator mainWindow,
|
||||
FormState formState,
|
||||
AnnotationService annotationService,
|
||||
IAnnotationService annotationService,
|
||||
ILogger<AnnotatorEventHandler> logger,
|
||||
IOptions<DirectoriesConfig> dirConfig,
|
||||
IOptions<AnnotationConfig> annotationConfig,
|
||||
IInferenceService inferenceService)
|
||||
:
|
||||
INotificationHandler<KeyEvent>,
|
||||
INotificationHandler<AnnClassSelectedEvent>,
|
||||
INotificationHandler<AnnotatorControlEvent>,
|
||||
INotificationHandler<VolumeChangedEvent>,
|
||||
INotificationHandler<AnnotationsDeletedEvent>
|
||||
INotificationHandler<AnnotationsDeletedEvent>,
|
||||
INotificationHandler<AnnotationAddedEvent>
|
||||
{
|
||||
private const int STEP = 20;
|
||||
private const int LARGE_STEP = 5000;
|
||||
@@ -81,7 +84,7 @@ public class AnnotatorEventHandler(
|
||||
await ControlPlayback(value, cancellationToken);
|
||||
|
||||
if (key == Key.R)
|
||||
mainWindow.AutoDetect(null!, null!);
|
||||
await mainWindow.AutoDetect();
|
||||
|
||||
#region Volume
|
||||
switch (key)
|
||||
@@ -128,10 +131,6 @@ public class AnnotatorEventHandler(
|
||||
break;
|
||||
case PlaybackControlEnum.Pause:
|
||||
mediaPlayer.Pause();
|
||||
if (mainWindow.IsInferenceNow)
|
||||
mainWindow.FollowAI = false;
|
||||
if (!mediaPlayer.IsPlaying)
|
||||
mainWindow.BlinkHelp(HelpTexts.HelpTextsDict[HelpTextEnum.AnnotationHelp]);
|
||||
|
||||
if (formState.BackgroundTime.HasValue)
|
||||
{
|
||||
@@ -225,7 +224,6 @@ public class AnnotatorEventHandler(
|
||||
await Task.Delay(100, ct);
|
||||
mediaPlayer.Stop();
|
||||
mainWindow.Title = $"Azaion Annotator - {mediaInfo.Name}";
|
||||
mainWindow.BlinkHelp(HelpTexts.HelpTextsDict[HelpTextEnum.PauseForAnnotations]);
|
||||
mediaPlayer.Play(new Media(libVLC, mediaInfo.Path));
|
||||
if (formState.CurrentMedia.MediaType == MediaTypes.Image)
|
||||
mediaPlayer.SetPause(true);
|
||||
@@ -301,4 +299,28 @@ public class AnnotatorEventHandler(
|
||||
}
|
||||
await Task.CompletedTask;
|
||||
}
|
||||
|
||||
public Task Handle(AnnotationAddedEvent e, CancellationToken cancellationToken)
|
||||
{
|
||||
mainWindow.Dispatcher.Invoke(() =>
|
||||
{
|
||||
mainWindow.AddAnnotation(e.Annotation);
|
||||
|
||||
var log = string.Join(Environment.NewLine, e.Annotation.Detections.Select(det =>
|
||||
$"Розпізнавання: {annotationConfig.Value.DetectionClassesDict[det.ClassNumber].ShortName}: " +
|
||||
$"xy=({det.CenterX:F2},{det.CenterY:F2}), " +
|
||||
$"розмір=({det.Width:F2}, {det.Height:F2}), " +
|
||||
$"conf: {det.Confidence*100:F0}%"));
|
||||
|
||||
mainWindow.LvFiles.Items.Refresh();
|
||||
|
||||
var media = mainWindow.MediaFilesDict.GetValueOrDefault(e.Annotation.OriginalMediaName);
|
||||
if (media != null)
|
||||
media.HasAnnotations = true;
|
||||
|
||||
mainWindow.LvFiles.Items.Refresh();
|
||||
mainWindow.StatusHelp.Text = log;
|
||||
});
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user