mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 15:06:29 +00:00
polish autodetection
This commit is contained in:
@@ -489,9 +489,10 @@ public partial class MainWindow
|
||||
return;
|
||||
|
||||
_mediator.Publish(new PlaybackControlEvent(PlaybackControlEnum.Play));
|
||||
_mediaPlayer.SetPause(true);
|
||||
|
||||
var mediaInfo = (MediaFileInfo)LvFiles.SelectedItem;
|
||||
_formState.CurrentMedia = mediaInfo;
|
||||
_mediaPlayer.Stop();
|
||||
var path = mediaInfo.Path;
|
||||
|
||||
var manualCancellationSource = new CancellationTokenSource();
|
||||
@@ -505,20 +506,28 @@ public partial class MainWindow
|
||||
_autoDetectDialog.Closing += (_, _) =>
|
||||
{
|
||||
manualCancellationSource.Cancel();
|
||||
_mediaPlayer.Stop();
|
||||
_mediaPlayer.SeekTo(TimeSpan.Zero);
|
||||
Editor.RemoveAllAnns();
|
||||
};
|
||||
_autoDetectDialog.Top = Height - _autoDetectDialog.Height - 80;
|
||||
_autoDetectDialog.Left = 5;
|
||||
|
||||
_ = Task.Run(async () =>
|
||||
{
|
||||
using var detector = new YOLODetector(_config);
|
||||
Dispatcher.Invoke(() => _autoDetectDialog.Log("Ініціалізація AI..."));
|
||||
var prevSeekTime = 0.0;
|
||||
|
||||
await foreach (var timeframe in _vlcFrameExtractor.ExtractFrames(path, token))
|
||||
{
|
||||
try
|
||||
{
|
||||
var detections = _aiDetector.Detect(timeframe.Stream);
|
||||
if (timeframe.Time.TotalSeconds > prevSeekTime + 1)
|
||||
{
|
||||
Dispatcher.Invoke(() => SeekTo(timeframe.Time));
|
||||
prevSeekTime = timeframe.Time.TotalSeconds;
|
||||
}
|
||||
|
||||
if (!IsValidDetection(timeframe.Time, detections))
|
||||
continue;
|
||||
@@ -533,9 +542,8 @@ public partial class MainWindow
|
||||
}
|
||||
_autoDetectDialog.Close();
|
||||
}, token);
|
||||
|
||||
|
||||
_autoDetectDialog.ShowDialog();
|
||||
|
||||
Dispatcher.Invoke(() => Editor.Background = new SolidColorBrush(Color.FromArgb(1, 0, 0, 0)));
|
||||
}
|
||||
|
||||
@@ -613,6 +621,7 @@ public partial class MainWindow
|
||||
$"xy=({det.Label.CenterX:F2},{det.Label.CenterY:F2}), " +
|
||||
$"size=({det.Label.Width:F2}, {det.Label.Height:F2}), " +
|
||||
$"prob: {det.Probability:F1}%"));
|
||||
|
||||
Dispatcher.Invoke(() => _autoDetectDialog.Log(log));
|
||||
|
||||
var thumbnailDto = await _galleryManager.CreateThumbnail(imgPath, token);
|
||||
|
||||
Reference in New Issue
Block a user