mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 14:46:31 +00:00
rework to Azaion.Suite
This commit is contained in:
@@ -1,13 +1,14 @@
|
||||
using System.Windows.Media;
|
||||
using Azaion.Annotator.Extensions;
|
||||
using Azaion.Common.DTO;
|
||||
using Azaion.Common.DTO.Config;
|
||||
using Azaion.Common.Extensions;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Azaion.Annotator.DTO;
|
||||
|
||||
public class AnnotationResult
|
||||
{
|
||||
private readonly Config _config = null!;
|
||||
|
||||
[JsonProperty(PropertyName = "f")]
|
||||
public string Image { get; set; } = null!;
|
||||
|
||||
@@ -18,61 +19,26 @@ public class AnnotationResult
|
||||
public double Lon { get; set; }
|
||||
public List<Detection> Detections { get; set; } = new();
|
||||
|
||||
#region For Display in the grid
|
||||
#region For XAML Form
|
||||
|
||||
[JsonIgnore]
|
||||
//For XAML Form
|
||||
public string TimeStr => $"{Time:h\\:mm\\:ss}";
|
||||
|
||||
private List<int>? _detectionClasses = null!;
|
||||
|
||||
//For Form
|
||||
[JsonIgnore]
|
||||
public string ClassName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (Detections.Count == 0)
|
||||
return "";
|
||||
_detectionClasses ??= Detections.Select(x => x.ClassNumber).Distinct().ToList();
|
||||
|
||||
return _detectionClasses.Count > 1
|
||||
? string.Join(", ", _detectionClasses.Select(x => _config.AnnotationClassesDict[x].ShortName))
|
||||
: _config.AnnotationClassesDict[_detectionClasses.FirstOrDefault()].Name;
|
||||
}
|
||||
}
|
||||
|
||||
public string ClassName { get; set; } = null!;
|
||||
|
||||
[JsonIgnore]
|
||||
public Color ClassColor1 => GetAnnotationClass(0);
|
||||
public Color ClassColor0 { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Color ClassColor2 => GetAnnotationClass(1);
|
||||
public Color ClassColor1 { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Color ClassColor3 => GetAnnotationClass(2);
|
||||
public Color ClassColor2 { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public Color ClassColor4 => GetAnnotationClass(3);
|
||||
|
||||
private Color GetAnnotationClass(int colorNumber)
|
||||
{
|
||||
if (Detections.Count == 0)
|
||||
return (-1).ToColor();
|
||||
|
||||
_detectionClasses ??= Detections.Select(x => x.ClassNumber).Distinct().ToList();
|
||||
|
||||
return colorNumber >= _detectionClasses.Count
|
||||
? _config.AnnotationClassesDict[_detectionClasses.LastOrDefault()].Color
|
||||
: _config.AnnotationClassesDict[_detectionClasses[colorNumber]].Color;
|
||||
}
|
||||
|
||||
public Color ClassColor3 { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
public AnnotationResult() { }
|
||||
public AnnotationResult(TimeSpan time, string timeName, List<Detection> detections, Config config)
|
||||
{
|
||||
_config = config;
|
||||
Detections = detections;
|
||||
Time = time;
|
||||
Image = $"{timeName}.jpg";
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user