mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 09:36:30 +00:00
2cf69f4e4e
fix creation new anns bug
78 lines
2.2 KiB
C#
78 lines
2.2 KiB
C#
using System.Windows.Media;
|
|
using Azaion.Annotator.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!;
|
|
|
|
[JsonProperty(PropertyName = "t")]
|
|
public TimeSpan Time { get; set; }
|
|
|
|
public double Lat { get; set; }
|
|
public double Lon { get; set; }
|
|
public List<Detection> Detections { get; set; } = new();
|
|
|
|
#region For Display in the grid
|
|
|
|
[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;
|
|
}
|
|
}
|
|
|
|
|
|
[JsonIgnore]
|
|
public Color ClassColor1 => GetAnnotationClass(0);
|
|
[JsonIgnore]
|
|
public Color ClassColor2 => GetAnnotationClass(1);
|
|
[JsonIgnore]
|
|
public Color ClassColor3 => GetAnnotationClass(2);
|
|
[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;
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
public AnnotationResult() { }
|
|
public AnnotationResult(TimeSpan time, string timeName, List<Detection> detections, Config config)
|
|
{
|
|
_config = config;
|
|
Detections = detections;
|
|
Time = time;
|
|
Image = $"{timeName}.jpg";
|
|
}
|
|
} |