add results pane

differentiate already processed videos
This commit is contained in:
Oleksandr Bezdieniezhnykh
2024-07-18 21:40:15 +03:00
parent 71006a2462
commit 288a34e992
6 changed files with 63 additions and 45 deletions
+4
View File
@@ -6,9 +6,13 @@ public class AnnotationResult
{ {
[JsonProperty(PropertyName = "f")] [JsonProperty(PropertyName = "f")]
public string Image { get; set; } = null!; public string Image { get; set; } = null!;
[JsonProperty(PropertyName = "t")] [JsonProperty(PropertyName = "t")]
public TimeSpan Time { get; set; } public TimeSpan Time { get; set; }
[JsonIgnore]
public string TimeStr => $"{Time:h\\:mm\\:ss}";
[JsonProperty(PropertyName = "p")] [JsonProperty(PropertyName = "p")]
public double Percentage { get; set; } public double Percentage { get; set; }
+4 -3
View File
@@ -2,7 +2,8 @@
public class VideoFileInfo public class VideoFileInfo
{ {
public string Name { get; set; } = null!; public string Name { get; set; } = null!;
public string Path { get; set; } = null!; public string Path { get; set; } = null!;
public TimeSpan Duration { get; set; } public TimeSpan Duration { get; set; }
public bool HasAnnotations { get; set; }
} }
+15 -10
View File
@@ -108,6 +108,15 @@
Background="Black" Background="Black"
SelectedItem="{Binding Path=SelectedVideo}" Foreground="#FFA4AFCC" SelectedItem="{Binding Path=SelectedVideo}" Foreground="#FFA4AFCC"
> >
<ListView.Resources>
<Style TargetType="{x:Type ListViewItem}">
<Style.Triggers>
<DataTrigger Binding="{Binding HasAnnotations}" Value="true">
<Setter Property="Background" Value="Gray"/>
</DataTrigger>
</Style.Triggers>
</Style>
</ListView.Resources>
<ListView.View> <ListView.View>
<GridView> <GridView>
<GridViewColumn Width="Auto" <GridViewColumn Width="Auto"
@@ -197,21 +206,17 @@
CanUserResizeRows="False" CanUserResizeRows="False"
CanUserResizeColumns="False"> CanUserResizeColumns="False">
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTemplateColumn <DataGridTextColumn
Width="120" Width="120"
Header="Кадр" Header="Кадр"
CanUserSort="False"> CanUserSort="False"
<DataGridTemplateColumn.HeaderStyle> Binding="{Binding Path=TimeStr}">
<DataGridTextColumn.HeaderStyle>
<Style TargetType="DataGridColumnHeader"> <Style TargetType="DataGridColumnHeader">
<Setter Property="Background" Value="#252525"></Setter> <Setter Property="Background" Value="#252525"></Setter>
</Style> </Style>
</DataGridTemplateColumn.HeaderStyle> </DataGridTextColumn.HeaderStyle>
<DataGridTemplateColumn.CellTemplate> </DataGridTextColumn>
<DataTemplate>
<TextBlock Text="{Binding Path=ClassNumber}"></TextBlock>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
<DataGridTextColumn <DataGridTextColumn
Width="*" Width="*"
Header="Клас" Header="Клас"
+9 -1
View File
@@ -153,6 +153,7 @@ public partial class MainWindow
{ {
Annotations = LoadAnnotations(); Annotations = LoadAnnotations();
_formState.AnnotationResults = LoadAnnotationResults(); _formState.AnnotationResults = LoadAnnotationResults();
DgAnnotations.ItemsSource = _formState.AnnotationResults;
} }
private Dictionary<TimeSpan, List<YoloLabel>> LoadAnnotations() private Dictionary<TimeSpan, List<YoloLabel>> LoadAnnotations()
@@ -206,6 +207,12 @@ public partial class MainWindow
if (!dir.Exists) if (!dir.Exists)
return; return;
var labelNames = new DirectoryInfo(_config.LabelsDirectory).GetFiles()
.Select(x => x.Name[..^11])
.GroupBy(x => x)
.Select(gr => gr.Key)
.ToDictionary(x => x);
var files = dir.GetFiles("mp4", "mov").Select(x => var files = dir.GetFiles("mp4", "mov").Select(x =>
{ {
_mediaPlayer.Media = new Media(_libVLC, x.FullName); _mediaPlayer.Media = new Media(_libVLC, x.FullName);
@@ -214,7 +221,8 @@ public partial class MainWindow
{ {
Name = x.Name, Name = x.Name,
Path = x.FullName, Path = x.FullName,
Duration = TimeSpan.FromMilliseconds(_mediaPlayer.Media.Duration) Duration = TimeSpan.FromMilliseconds(_mediaPlayer.Media.Duration),
HasAnnotations = labelNames.ContainsKey(Path.GetFileNameWithoutExtension(x.Name).Replace(" ", ""))
}; };
}).ToList(); }).ToList();
+5 -5
View File
@@ -9,10 +9,10 @@ using Newtonsoft.Json;
namespace Azaion.Annotator; namespace Azaion.Annotator;
public class PlayerControlHandler(LibVLC libVLC, MediaPlayer mediaPlayer, MainWindow mainWindow, FormState formState, Config config) : public class PlayerControlHandler(LibVLC libVLC, MediaPlayer mediaPlayer, MainWindow mainWindow, FormState formState, Config config) :
INotificationHandler<KeyEvent>, INotificationHandler<KeyEvent>,
INotificationHandler<AnnClassSelectedEvent>, INotificationHandler<AnnClassSelectedEvent>,
INotificationHandler<PlaybackControlEvent>, INotificationHandler<PlaybackControlEvent>,
INotificationHandler<VolumeChangedEvent> INotificationHandler<VolumeChangedEvent>
{ {
private const int STEP = 20; private const int STEP = 20;
private const int LARGE_STEP = 5000; private const int LARGE_STEP = 5000;
@@ -23,7 +23,7 @@ public class PlayerControlHandler(LibVLC libVLC, MediaPlayer mediaPlayer, MainWi
private readonly Dictionary<Key, PlaybackControlEnum> KeysControlEnumDict = new() private readonly Dictionary<Key, PlaybackControlEnum> KeysControlEnumDict = new()
{ {
{ Key.Space, PlaybackControlEnum.Pause }, { Key.Space, PlaybackControlEnum.Pause },
{ Key.Left, PlaybackControlEnum.PreviousFrame }, { Key.Left, PlaybackControlEnum.PreviousFrame },
{ Key.Right, PlaybackControlEnum.NextFrame }, { Key.Right, PlaybackControlEnum.NextFrame },
{ Key.Enter, PlaybackControlEnum.SaveAnnotations }, { Key.Enter, PlaybackControlEnum.SaveAnnotations },
{ Key.Delete, PlaybackControlEnum.RemoveSelectedAnns }, { Key.Delete, PlaybackControlEnum.RemoveSelectedAnns },
+1 -1
View File
@@ -1,5 +1,5 @@
{ {
"VideosDirectory": "E:\\Azaion3\\Videos", "VideosDirectory": "E:\\Azaion3\\VideosDone",
"LabelsDirectory": "E:\\labels", "LabelsDirectory": "E:\\labels",
"ImagesDirectory": "E:\\images", "ImagesDirectory": "E:\\images",
"ResultsDirectory": "E:\\results", "ResultsDirectory": "E:\\results",