add ai recognition: stage 1, works, but doesn't show

This commit is contained in:
Alex Bezdieniezhnykh
2024-10-25 00:17:24 +03:00
parent d2186eb326
commit 596f6db217
13 changed files with 591 additions and 336 deletions
@@ -19,6 +19,9 @@ public class MainWindowEventHandler :
private readonly MainWindow _mainWindow;
private readonly FormState _formState;
private readonly Config _config;
private readonly IMediator _mediator;
private readonly IGalleryManager _galleryManager;
private readonly DatasetExplorer _datasetExplorer;
private readonly ILogger<MainWindowEventHandler> _logger;
private const int STEP = 20;
@@ -42,6 +45,9 @@ public class MainWindowEventHandler :
MainWindow mainWindow,
FormState formState,
Config config,
IMediator mediator,
IGalleryManager galleryManager,
DatasetExplorer datasetExplorer,
ILogger<MainWindowEventHandler> logger)
{
_libVLC = libVLC;
@@ -49,6 +55,9 @@ public class MainWindowEventHandler :
_mainWindow = mainWindow;
_formState = formState;
_config = config;
_mediator = mediator;
_galleryManager = galleryManager;
_datasetExplorer = datasetExplorer;
_logger = logger;
}
@@ -85,6 +94,9 @@ public class MainWindowEventHandler :
if (_keysControlEnumDict.TryGetValue(key, out var value))
await ControlPlayback(value);
if (key == Key.A)
await _mediator.Send( new AIDetectEvent(), cancellationToken);
await VolumeControl(key);
}
@@ -259,5 +271,11 @@ public class MainWindowEventHandler :
File.Copy(_formState.CurrentMedia.Path, destinationPath, overwrite: true);
await NextMedia();
}
var thumbnailDto = await _galleryManager.CreateThumbnail(destinationPath);
var selectedClass = ((AnnotationClass?)_datasetExplorer.LvClasses.SelectedItem)?.Id;
if (selectedClass != null && (selectedClass == -1 || currentAnns.Any(x => x.ClassNumber == selectedClass)))
_datasetExplorer.ThumbnailsDtos.Insert(0, thumbnailDto);
}
}