mirror of
https://github.com/azaion/annotations.git
synced 2026-04-23 00:16:30 +00:00
splitting python complete
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.IO;
|
||||
using System.Windows.Media;
|
||||
using Azaion.Common.DTO;
|
||||
using Azaion.Common.DTO.Config;
|
||||
using Azaion.Common.DTO.Queue;
|
||||
@@ -12,12 +13,14 @@ public class Annotation
|
||||
private static string _labelsDir = null!;
|
||||
private static string _imagesDir = null!;
|
||||
private static string _thumbDir = null!;
|
||||
|
||||
public static void InitializeDirs(DirectoriesConfig config)
|
||||
private static Dictionary<int, DetectionClass> _detectionClassesDict;
|
||||
|
||||
public static void Init(DirectoriesConfig config, Dictionary<int, DetectionClass> detectionClassesDict)
|
||||
{
|
||||
_labelsDir = config.LabelsDirectory;
|
||||
_imagesDir = config.ImagesDirectory;
|
||||
_thumbDir = config.ThumbnailsDirectory;
|
||||
_detectionClassesDict = detectionClassesDict;
|
||||
}
|
||||
|
||||
[Key("n")] public string Name { get; set; } = null!;
|
||||
@@ -40,12 +43,64 @@ public class Annotation
|
||||
[Key("lon")]public double Lon { get; set; }
|
||||
|
||||
#region Calculated
|
||||
[IgnoreMember]public List<int> Classes => Detections.Select(x => x.ClassNumber).ToList();
|
||||
[IgnoreMember]public string ImagePath => Path.Combine(_imagesDir, $"{Name}{ImageExtension}");
|
||||
[IgnoreMember]public string LabelPath => Path.Combine(_labelsDir, $"{Name}.txt");
|
||||
[IgnoreMember]public string ThumbPath => Path.Combine(_thumbDir, $"{Name}{Constants.THUMBNAIL_PREFIX}.jpg");
|
||||
[IgnoreMember] public List<int> Classes => Detections.Select(x => x.ClassNumber).ToList();
|
||||
[IgnoreMember] public string ImagePath => Path.Combine(_imagesDir, $"{Name}{ImageExtension}");
|
||||
[IgnoreMember] public string LabelPath => Path.Combine(_labelsDir, $"{Name}.txt");
|
||||
[IgnoreMember] public string ThumbPath => Path.Combine(_thumbDir, $"{Name}{Constants.THUMBNAIL_PREFIX}.jpg");
|
||||
[IgnoreMember] public bool IsSplit => Name.Contains(Constants.SPLIT_SUFFIX);
|
||||
|
||||
private CanvasLabel? _splitTile;
|
||||
[IgnoreMember] public CanvasLabel? SplitTile
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!IsSplit)
|
||||
return null;
|
||||
if (_splitTile != null)
|
||||
return _splitTile;
|
||||
|
||||
var startCoordIndex = Name.IndexOf(Constants.SPLIT_SUFFIX, StringComparison.Ordinal) + Constants.SPLIT_SUFFIX.Length;
|
||||
var coordsStr = Name.Substring(startCoordIndex, 9).Split('_');
|
||||
_splitTile = new CanvasLabel
|
||||
{
|
||||
Left = double.Parse(coordsStr[0]),
|
||||
Top = double.Parse(coordsStr[1]),
|
||||
Width = Constants.AI_TILE_SIZE,
|
||||
Height = Constants.AI_TILE_SIZE
|
||||
};
|
||||
return _splitTile;
|
||||
}
|
||||
}
|
||||
|
||||
[IgnoreMember] public string TimeStr => $"{Time:h\\:mm\\:ss}";
|
||||
|
||||
private List<(Color Color, double Confidence)>? _colors;
|
||||
[IgnoreMember] public List<(Color Color, double Confidence)> Colors => _colors ??= Detections
|
||||
.Select(d => (_detectionClassesDict[d.ClassNumber].Color, d.Confidence))
|
||||
.ToList();
|
||||
|
||||
private string _className;
|
||||
[IgnoreMember] public string ClassName
|
||||
{
|
||||
get
|
||||
{
|
||||
if (string.IsNullOrEmpty(_className))
|
||||
{
|
||||
var detectionClasses = Detections.Select(x => x.ClassNumber).Distinct().ToList();
|
||||
_className = detectionClasses.Count > 1
|
||||
? string.Join(", ", detectionClasses.Select(x => _detectionClassesDict[x].UIName))
|
||||
: _detectionClassesDict[detectionClasses.FirstOrDefault()].UIName;
|
||||
}
|
||||
return _className;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion Calculated
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
[MessagePackObject]
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Data.SQLite;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using Azaion.Common.DTO;
|
||||
using Azaion.Common.DTO.Config;
|
||||
@@ -48,7 +49,7 @@ public class DbFactory : IDbFactory
|
||||
.UseDataProvider(SQLiteTools.GetDataProvider())
|
||||
.UseConnection(_memoryConnection)
|
||||
.UseMappingSchema(AnnotationsDbSchemaHolder.MappingSchema)
|
||||
;//.UseTracing(TraceLevel.Info, t => logger.LogInformation(t.SqlText));
|
||||
.UseTracing(TraceLevel.Info, t => logger.LogInformation(t.SqlText));
|
||||
|
||||
|
||||
_fileConnection = new SQLiteConnection(FileConnStr);
|
||||
|
||||
Reference in New Issue
Block a user