mirror of
https://github.com/azaion/annotations.git
synced 2026-04-23 01:36:30 +00:00
add results pane
differentiate videos which already has annotations
This commit is contained in:
@@ -1,29 +1,72 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Windows.Media;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Azaion.Annotator.DTO;
|
||||
|
||||
public class AnnotationResult
|
||||
{
|
||||
private readonly Config _config = null!;
|
||||
|
||||
[JsonProperty(PropertyName = "f")]
|
||||
public string Image { get; set; } = null!;
|
||||
|
||||
[JsonProperty(PropertyName = "t")]
|
||||
public TimeSpan Time { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public string TimeStr => $"{Time:h\\:mm\\:ss}";
|
||||
|
||||
[JsonProperty(PropertyName = "p")]
|
||||
public double Percentage { get; set; }
|
||||
|
||||
|
||||
public double Lat { get; set; }
|
||||
public double Lon { get; set; }
|
||||
public List<YoloLabel> Labels { get; set; } = new();
|
||||
|
||||
|
||||
#region For Display in the grid
|
||||
|
||||
[JsonIgnore]
|
||||
//For XAML Form
|
||||
public string TimeStr => $"{Time:h\\:mm\\:ss}";
|
||||
|
||||
[JsonIgnore]
|
||||
//For XAML Form
|
||||
public string ClassName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Labels.Count == 0)
|
||||
return "";
|
||||
|
||||
var groups = Labels.Select(x => x.ClassNumber).GroupBy(x => x).ToList();
|
||||
return groups.Count > 1
|
||||
? string.Join(",", groups.Select(x => x.Key + 1))
|
||||
: _config.AnnotationClassesDict[groups.FirstOrDefault().Key].Name;
|
||||
}
|
||||
}
|
||||
|
||||
[JsonIgnore]
|
||||
//For XAML Form
|
||||
public Color ClassColor
|
||||
{
|
||||
get
|
||||
{
|
||||
var defaultColor = (Color)ColorConverter.ConvertFromString("#404040");
|
||||
if (Labels.Count == 0)
|
||||
return defaultColor;
|
||||
|
||||
var groups = Labels.Select(x => x.ClassNumber).GroupBy(x => x).ToList();
|
||||
|
||||
return groups.Count > 1
|
||||
? defaultColor
|
||||
: _config.AnnotationClassesDict[groups.FirstOrDefault().Key].Color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
public AnnotationResult() { }
|
||||
public AnnotationResult(TimeSpan time, string timeName, List<YoloLabel> labels)
|
||||
public AnnotationResult(TimeSpan time, string timeName, List<YoloLabel> labels, Config config)
|
||||
{
|
||||
_config = config;
|
||||
Labels = labels;
|
||||
Time = time;
|
||||
Image = $"{timeName}.jpg";
|
||||
|
||||
@@ -27,6 +27,10 @@ public class Config
|
||||
public string ResultsDirectory { get; set; } = DEFAULT_RESULTS_DIR;
|
||||
|
||||
public List<AnnotationClass> AnnotationClasses { get; set; } = [];
|
||||
|
||||
private Dictionary<int, AnnotationClass>? _annotationClassesDict;
|
||||
public Dictionary<int, AnnotationClass> AnnotationClassesDict => _annotationClassesDict ??= AnnotationClasses.ToDictionary(x => x.Id);
|
||||
|
||||
public Size WindowSize { get; set; }
|
||||
public Point WindowLocation { get; set; }
|
||||
public bool ShowHelpOnStart { get; set; }
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Globalization;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
|
||||
@@ -13,7 +14,7 @@ public class FormState
|
||||
public string VideoName => Path.GetFileNameWithoutExtension(CurrentFile).Replace(" ", "");
|
||||
public TimeSpan CurrentVideoLength { get; set; }
|
||||
public int CurrentVolume { get; set; } = 100;
|
||||
public List<AnnotationResult> AnnotationResults { get; set; } = [];
|
||||
public ObservableCollection<AnnotationResult> AnnotationResults { get; set; } = [];
|
||||
|
||||
public string GetTimeName(TimeSpan ts) => $"{VideoName}_{ts:hmmssf}";
|
||||
|
||||
|
||||
@@ -38,8 +38,8 @@ public class CanvasLabel : Label
|
||||
|
||||
ClassNumber = label.ClassNumber;
|
||||
|
||||
var left = X - Width / 2;
|
||||
var top = Y - Height / 2;
|
||||
var left = label.CenterX - label.Width / 2;
|
||||
var top = label.CenterY - label.Height / 2;
|
||||
|
||||
if (videoAr > canvasAr) //100% width
|
||||
{
|
||||
@@ -89,7 +89,6 @@ public class YoloLabel : Label
|
||||
|
||||
public YoloLabel(CanvasLabel canvasLabel, Size canvasSize, Size videoSize)
|
||||
{
|
||||
|
||||
var cw = canvasSize.Width;
|
||||
var ch = canvasSize.Height;
|
||||
var canvasAr = cw / ch;
|
||||
@@ -117,8 +116,8 @@ public class YoloLabel : Label
|
||||
Width = canvasLabel.Width / realWidth;
|
||||
}
|
||||
|
||||
CenterX = left + canvasLabel.Width / 2.0;
|
||||
CenterY = top + canvasLabel.Height / 2.0;
|
||||
CenterX = left + Width / 2.0;
|
||||
CenterY = top + Height / 2.0;
|
||||
}
|
||||
|
||||
public static YoloLabel? Parse(string s)
|
||||
|
||||
Reference in New Issue
Block a user