mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:36:30 +00:00
add publish script, check its work
This commit is contained in:
@@ -14,7 +14,6 @@ using Azaion.Common.DTO.Config;
|
||||
using Azaion.Common.Events;
|
||||
using Azaion.Common.Extensions;
|
||||
using Azaion.Common.Services;
|
||||
using Azaion.CommonSecurity.Services;
|
||||
using LibVLCSharp.Shared;
|
||||
using MediatR;
|
||||
using Microsoft.WindowsAPICodePack.Dialogs;
|
||||
@@ -520,7 +519,7 @@ public partial class Annotator
|
||||
var files = new List<string>();
|
||||
await Dispatcher.Invoke(async () =>
|
||||
{
|
||||
//Take not annotated medias
|
||||
//Take not annotataed medias
|
||||
files = (LvFiles.ItemsSource as IEnumerable<MediaFileInfo>)?.Skip(LvFiles.SelectedIndex)
|
||||
.Take(Constants.DETECTION_BATCH_SIZE)
|
||||
.Where(x => !x.HasAnnotations)
|
||||
@@ -532,16 +531,16 @@ public partial class Annotator
|
||||
await ReloadAnnotations();
|
||||
}
|
||||
});
|
||||
|
||||
if (files.Count == 0)
|
||||
break;
|
||||
|
||||
await _inferenceService.RunInference(files, async annotationImage => await ProcessDetection(annotationImage), ct);
|
||||
await _inferenceService.RunInference(files, async annotationImage => await ProcessDetection(annotationImage, ct), ct);
|
||||
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
if (LvFiles.SelectedIndex + files.Count >= LvFiles.Items.Count)
|
||||
DetectionCancellationSource.Cancel();
|
||||
LvFiles.SelectedIndex += files.Count;
|
||||
LvFiles.Items.Refresh();
|
||||
});
|
||||
}
|
||||
Dispatcher.Invoke(() =>
|
||||
@@ -553,15 +552,28 @@ public partial class Annotator
|
||||
});
|
||||
}
|
||||
|
||||
private async Task ProcessDetection(AnnotationImage annotationImage)
|
||||
private async Task ProcessDetection(AnnotationImage annotationImage, CancellationToken ct = default)
|
||||
{
|
||||
await Dispatcher.Invoke(async () =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var annotation = await _annotationService.SaveAnnotation(annotationImage);
|
||||
var annotation = await _annotationService.SaveAnnotation(annotationImage, ct);
|
||||
if (annotation.OriginalMediaName != _formState.CurrentMedia?.FName)
|
||||
return;
|
||||
{
|
||||
var nextFile = (LvFiles.ItemsSource as IEnumerable<MediaFileInfo>)?
|
||||
.Select((info, i) => new
|
||||
{
|
||||
MediaInfo = info,
|
||||
Index = i
|
||||
})
|
||||
.FirstOrDefault(x => x.MediaInfo.FName == annotation.OriginalMediaName);
|
||||
if (nextFile != null)
|
||||
{
|
||||
LvFiles.SelectedIndex = nextFile.Index;
|
||||
await _mediator.Publish(new AnnotatorControlEvent(PlaybackControlEnum.Play), ct);
|
||||
}
|
||||
}
|
||||
AddAnnotation(annotation);
|
||||
|
||||
if (FollowAI)
|
||||
@@ -573,7 +585,13 @@ public partial class Annotator
|
||||
$"size=({det.Width:F2}, {det.Height:F2}), " +
|
||||
$"prob: {det.Probability*100:F0}%"));
|
||||
|
||||
Dispatcher.Invoke(() => StatusHelp.Text = log);
|
||||
Dispatcher.Invoke(() =>
|
||||
{
|
||||
if (_formState.CurrentMedia != null)
|
||||
_formState.CurrentMedia.HasAnnotations = true;
|
||||
LvFiles.Items.Refresh();
|
||||
StatusHelp.Text = log;
|
||||
});
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -123,7 +123,7 @@ public class AnnotatorEventHandler(
|
||||
switch (controlEnum)
|
||||
{
|
||||
case PlaybackControlEnum.Play:
|
||||
Play();
|
||||
await Play(cancellationToken);
|
||||
break;
|
||||
case PlaybackControlEnum.Pause:
|
||||
mediaPlayer.Pause();
|
||||
@@ -170,10 +170,10 @@ public class AnnotatorEventHandler(
|
||||
mediaPlayer.Volume = 0;
|
||||
break;
|
||||
case PlaybackControlEnum.Previous:
|
||||
NextMedia(isPrevious: true);
|
||||
await NextMedia(isPrevious: true, ct: cancellationToken);
|
||||
break;
|
||||
case PlaybackControlEnum.Next:
|
||||
NextMedia();
|
||||
await NextMedia(ct: cancellationToken);
|
||||
break;
|
||||
case PlaybackControlEnum.None:
|
||||
break;
|
||||
@@ -188,7 +188,7 @@ public class AnnotatorEventHandler(
|
||||
}
|
||||
}
|
||||
|
||||
private void NextMedia(bool isPrevious = false)
|
||||
private async Task NextMedia(bool isPrevious = false, CancellationToken ct = default)
|
||||
{
|
||||
var increment = isPrevious ? -1 : 1;
|
||||
var check = isPrevious ? -1 : mainWindow.LvFiles.Items.Count;
|
||||
@@ -196,7 +196,7 @@ public class AnnotatorEventHandler(
|
||||
return;
|
||||
|
||||
mainWindow.LvFiles.SelectedIndex += increment;
|
||||
Play();
|
||||
await Play(ct);
|
||||
}
|
||||
|
||||
public async Task Handle(VolumeChangedEvent notification, CancellationToken cancellationToken)
|
||||
@@ -211,7 +211,7 @@ public class AnnotatorEventHandler(
|
||||
mediaPlayer.Volume = volume;
|
||||
}
|
||||
|
||||
private void Play()
|
||||
private async Task Play(CancellationToken ct = default)
|
||||
{
|
||||
if (mainWindow.LvFiles.SelectedItem == null)
|
||||
return;
|
||||
@@ -219,6 +219,8 @@ public class AnnotatorEventHandler(
|
||||
mainWindow.Editor.ResetBackground();
|
||||
|
||||
formState.CurrentMedia = mediaInfo;
|
||||
//need to wait a bit for correct VLC playback event handling
|
||||
await Task.Delay(100, ct);
|
||||
mediaPlayer.Stop();
|
||||
mainWindow.Title = $"Azaion Annotator - {mediaInfo.Name}";
|
||||
mainWindow.BlinkHelp(HelpTexts.HelpTextsDict[HelpTextEnum.PauseForAnnotations]);
|
||||
@@ -269,7 +271,7 @@ public class AnnotatorEventHandler(
|
||||
else
|
||||
{
|
||||
File.Copy(formState.CurrentMedia.Path, imgPath, overwrite: true);
|
||||
NextMedia();
|
||||
await NextMedia(ct: cancellationToken);
|
||||
}
|
||||
var annotation = await annotationService.SaveAnnotation(formState.VideoName, time, imageExtension, currentDetections, SourceEnum.Manual, token: cancellationToken);
|
||||
mainWindow.AddAnnotation(annotation);
|
||||
|
||||
Reference in New Issue
Block a user