mirror of
https://github.com/azaion/annotations.git
synced 2026-04-22 10:46:30 +00:00
add altitude + camera spec component and calc tile size by this
also restrict detections to be no bigger than in classes.json
This commit is contained in:
@@ -6,10 +6,8 @@ using Azaion.Common.DTO.Config;
|
||||
using Azaion.Common.Extensions;
|
||||
using LinqToDB;
|
||||
using LinqToDB.DataProvider.SQLite;
|
||||
using LinqToDB.Mapping;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.Extensions.Options;
|
||||
using Newtonsoft.Json;
|
||||
using Serilog;
|
||||
|
||||
namespace Azaion.Common.Database;
|
||||
@@ -64,7 +62,12 @@ public class DbFactory : IDbFactory
|
||||
|
||||
_fileConnection.Open();
|
||||
using var db = new AnnotationsDb(_fileDataOptions);
|
||||
SchemaMigrator.EnsureSchemaUpdated(db, typeof(Annotation), typeof(Detection));
|
||||
var entityTypes = typeof(AnnotationsDb)
|
||||
.GetProperties()
|
||||
.Where(p => p.PropertyType.IsGenericType && p.PropertyType.GetGenericTypeDefinition() == typeof(ITable<>))
|
||||
.Select(p => p.PropertyType.GetGenericArguments()[0])
|
||||
.ToArray();
|
||||
SchemaMigrator.EnsureSchemaUpdated(db, entityTypes);
|
||||
_fileConnection.BackupDatabase(_memoryConnection, "main", "main", -1, null, -1);
|
||||
}
|
||||
|
||||
@@ -145,41 +148,4 @@ public class DbFactory : IDbFactory
|
||||
_logger.LogInformation($"Deleted {detDeleted} detections, {annDeleted} annotations");
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public static class AnnotationsDbSchemaHolder
|
||||
{
|
||||
public static readonly MappingSchema MappingSchema;
|
||||
|
||||
static AnnotationsDbSchemaHolder()
|
||||
{
|
||||
MappingSchema = new MappingSchema();
|
||||
var builder = new FluentMappingBuilder(MappingSchema);
|
||||
|
||||
var annotationBuilder = builder.Entity<Annotation>();
|
||||
annotationBuilder.HasTableName(Constants.ANNOTATIONS_TABLENAME)
|
||||
.HasPrimaryKey(x => x.Name)
|
||||
.Association(a => a.Detections, (a, d) => a.Name == d.AnnotationName)
|
||||
.Property(x => x.Time).HasDataType(DataType.Int64).HasConversion(ts => ts.Ticks, t => new TimeSpan(t));
|
||||
|
||||
annotationBuilder
|
||||
.Ignore(x => x.Milliseconds)
|
||||
.Ignore(x => x.Classes)
|
||||
.Ignore(x => x.Classes)
|
||||
.Ignore(x => x.ImagePath)
|
||||
.Ignore(x => x.LabelPath)
|
||||
.Ignore(x => x.ThumbPath);
|
||||
|
||||
builder.Entity<Detection>()
|
||||
.HasTableName(Constants.DETECTIONS_TABLENAME);
|
||||
|
||||
builder.Entity<AnnotationQueueRecord>()
|
||||
.HasTableName(Constants.ANNOTATIONS_QUEUE_TABLENAME)
|
||||
.HasPrimaryKey(x => x.Id)
|
||||
.Property(x => x.AnnotationNames)
|
||||
.HasDataType(DataType.NVarChar)
|
||||
.HasConversion(list => JsonConvert.SerializeObject(list), str => JsonConvert.DeserializeObject<List<string>>(str) ?? new List<string>());
|
||||
|
||||
builder.Build();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user