mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 22:06:30 +00:00
add autodetection
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Input;
|
||||
using Azaion.Annotator.DTO;
|
||||
using LibVLCSharp.Shared;
|
||||
@@ -95,7 +96,7 @@ public class MainWindowEventHandler :
|
||||
await ControlPlayback(value);
|
||||
|
||||
if (key == Key.A)
|
||||
await _mediator.Send( new AIDetectEvent(), cancellationToken);
|
||||
_mainWindow.AutoDetect(null!, null!);
|
||||
|
||||
await VolumeControl(key);
|
||||
}
|
||||
@@ -141,7 +142,7 @@ public class MainWindowEventHandler :
|
||||
switch (controlEnum)
|
||||
{
|
||||
case PlaybackControlEnum.Play:
|
||||
await Play();
|
||||
Play();
|
||||
break;
|
||||
case PlaybackControlEnum.Pause:
|
||||
_mediaPlayer.Pause();
|
||||
@@ -152,19 +153,16 @@ public class MainWindowEventHandler :
|
||||
_mediaPlayer.Stop();
|
||||
break;
|
||||
case PlaybackControlEnum.PreviousFrame:
|
||||
_mediaPlayer.SetPause(true);
|
||||
_mediaPlayer.Time -= step;
|
||||
_mainWindow.VideoSlider.Value = _mediaPlayer.Position * 100;
|
||||
_mainWindow.SeekTo(_mediaPlayer.Time - step);
|
||||
break;
|
||||
case PlaybackControlEnum.NextFrame:
|
||||
_mediaPlayer.SetPause(true);
|
||||
_mediaPlayer.Time += step;
|
||||
_mainWindow.VideoSlider.Value = _mediaPlayer.Position * 100;
|
||||
_mainWindow.SeekTo(_mediaPlayer.Time + step);
|
||||
break;
|
||||
case PlaybackControlEnum.SaveAnnotations:
|
||||
await SaveAnnotations();
|
||||
break;
|
||||
case PlaybackControlEnum.RemoveSelectedAnns:
|
||||
|
||||
_mainWindow.Editor.RemoveSelectedAnns();
|
||||
break;
|
||||
case PlaybackControlEnum.RemoveAllAnns:
|
||||
@@ -182,10 +180,10 @@ public class MainWindowEventHandler :
|
||||
_mediaPlayer.Volume = 0;
|
||||
break;
|
||||
case PlaybackControlEnum.Previous:
|
||||
await NextMedia(isPrevious: true);
|
||||
NextMedia(isPrevious: true);
|
||||
break;
|
||||
case PlaybackControlEnum.Next:
|
||||
await NextMedia();
|
||||
NextMedia();
|
||||
break;
|
||||
case PlaybackControlEnum.None:
|
||||
break;
|
||||
@@ -195,12 +193,12 @@ public class MainWindowEventHandler :
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
_logger.LogError(e, e.Message);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task NextMedia(bool isPrevious = false)
|
||||
private void NextMedia(bool isPrevious = false)
|
||||
{
|
||||
var increment = isPrevious ? -1 : 1;
|
||||
var check = isPrevious ? -1 : _mainWindow.LvFiles.Items.Count;
|
||||
@@ -208,7 +206,7 @@ public class MainWindowEventHandler :
|
||||
return;
|
||||
|
||||
_mainWindow.LvFiles.SelectedIndex += increment;
|
||||
await Play();
|
||||
Play();
|
||||
}
|
||||
|
||||
public async Task Handle(VolumeChangedEvent notification, CancellationToken cancellationToken)
|
||||
@@ -223,7 +221,7 @@ public class MainWindowEventHandler :
|
||||
_mediaPlayer.Volume = volume;
|
||||
}
|
||||
|
||||
private async Task Play()
|
||||
private void Play()
|
||||
{
|
||||
if (_mainWindow.LvFiles.SelectedItem == null)
|
||||
return;
|
||||
@@ -242,7 +240,7 @@ public class MainWindowEventHandler :
|
||||
return;
|
||||
|
||||
var time = TimeSpan.FromMilliseconds(_mediaPlayer.Time);
|
||||
var fName = _formState.GetTimeName(time);
|
||||
var fName = _formState.GetTimeName(time);
|
||||
|
||||
var currentAnns = _mainWindow.Editor.CurrentAnns
|
||||
.Select(x => new YoloLabel(x.Info, _mainWindow.Editor.RenderSize, _formState.CurrentVideoSize))
|
||||
@@ -252,7 +250,7 @@ public class MainWindowEventHandler :
|
||||
|
||||
var resultHeight = (uint)Math.Round(RESULT_WIDTH / _formState.CurrentVideoSize.Width * _formState.CurrentVideoSize.Height);
|
||||
|
||||
await _mainWindow.AddAnnotation(time, currentAnns);
|
||||
await _mainWindow.AddAnnotations(time, currentAnns);
|
||||
|
||||
_formState.CurrentMedia.HasAnnotations = _mainWindow.Annotations.Count != 0;
|
||||
_mainWindow.LvFiles.Items.Refresh();
|
||||
@@ -269,13 +267,11 @@ public class MainWindowEventHandler :
|
||||
else
|
||||
{
|
||||
File.Copy(_formState.CurrentMedia.Path, destinationPath, overwrite: true);
|
||||
await NextMedia();
|
||||
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);
|
||||
if (thumbnailDto != null)
|
||||
_datasetExplorer.AddThumbnail(thumbnailDto, currentAnns.Select(x => x.ClassNumber));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user