SegmentB, personKey,
personKeyFormatted and Sorting
This commit is contained in:
@ -10,21 +10,25 @@ public class Face : Properties.IFace
|
||||
protected List<FaceDistance> _FaceDistances;
|
||||
protected FaceEncoding? _FaceEncoding;
|
||||
protected Dictionary<Stateless.FacePart, FacePoint[]>? _FaceParts;
|
||||
protected List<int[]>? _FaceNumbers;
|
||||
protected readonly OutputResolution? _OutputResolution;
|
||||
protected Location? _Location;
|
||||
protected readonly int? _LocationIndex;
|
||||
protected readonly string _RelativePath;
|
||||
protected List<object> _Tags;
|
||||
public DateTime DateTime => _DateTime;
|
||||
public List<FaceDistance> FaceDistances => _FaceDistances;
|
||||
public FaceEncoding? FaceEncoding => _FaceEncoding;
|
||||
public Dictionary<Stateless.FacePart, FacePoint[]>? FaceParts => _FaceParts;
|
||||
public List<int[]>? FaceNumbers => _FaceNumbers;
|
||||
public Location? Location => _Location;
|
||||
public int? LocationIndex => _LocationIndex;
|
||||
public OutputResolution? OutputResolution => _OutputResolution;
|
||||
public string RelativePath => _RelativePath;
|
||||
public List<object> Tags => _Tags;
|
||||
|
||||
[JsonConstructor]
|
||||
public Face(DateTime dateTime, List<FaceDistance> faceDistances, FaceEncoding? faceEncoding, Dictionary<Stateless.FacePart, FacePoint[]>? faceParts, Location? location, int? locationIndex, OutputResolution? outputResolution, string relativePath)
|
||||
public Face(DateTime dateTime, List<FaceDistance> faceDistances, FaceEncoding? faceEncoding, Dictionary<Stateless.FacePart, FacePoint[]>? faceParts, List<int[]>? faceNumbers, Location? location, int? locationIndex, OutputResolution? outputResolution, string relativePath)
|
||||
{
|
||||
if (faceDistances is null)
|
||||
faceDistances = new();
|
||||
@ -32,36 +36,38 @@ public class Face : Properties.IFace
|
||||
_FaceDistances = faceDistances;
|
||||
_FaceEncoding = faceEncoding;
|
||||
_FaceParts = faceParts;
|
||||
_FaceNumbers = faceNumbers;
|
||||
_Location = location;
|
||||
_LocationIndex = locationIndex;
|
||||
_OutputResolution = outputResolution;
|
||||
_RelativePath = relativePath;
|
||||
_Tags = new();
|
||||
}
|
||||
|
||||
public Face() :
|
||||
this(DateTime.MinValue, new(), null, null, null, null, null, string.Empty)
|
||||
this(DateTime.MinValue, new(), null, null, null, null, null, null, string.Empty)
|
||||
{ }
|
||||
|
||||
public Face(Location location) :
|
||||
this(DateTime.MinValue, new(), null, null, location, null, null, string.Empty)
|
||||
this(DateTime.MinValue, new(), null, null, null, location, null, null, string.Empty)
|
||||
{ }
|
||||
|
||||
public Face(int facesCount, Face face) :
|
||||
this(face.DateTime, new(), face.FaceEncoding, face.FaceParts, face.Location, face.LocationIndex, face.OutputResolution, face.RelativePath)
|
||||
this(face.DateTime, new(), face.FaceEncoding, face.FaceParts, null, face.Location, face.LocationIndex, face.OutputResolution, face.RelativePath)
|
||||
{
|
||||
if (face.Location?.Confidence is not null && face.OutputResolution is not null)
|
||||
_Location = new(face.Location.Confidence, face.OutputResolution.Height, face.Location, face.OutputResolution.Width, facesCount);
|
||||
}
|
||||
|
||||
public Face(int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation, Face face) :
|
||||
this(face.DateTime, new(), face.FaceEncoding, face.FaceParts, face.Location, face.LocationIndex, null, face.RelativePath)
|
||||
this(face.DateTime, new(), face.FaceEncoding, face.FaceParts, null, face.Location, face.LocationIndex, null, face.RelativePath)
|
||||
{
|
||||
if (outputResolutionHeight > 0)
|
||||
_OutputResolution = new(outputResolutionHeight, outputResolutionOrientation, outputResolutionWidth);
|
||||
}
|
||||
|
||||
public Face(Property property, int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation, string relativePath, int? i, Location? location) :
|
||||
this(DateTime.MinValue, new(), null, null, location, i, null, relativePath)
|
||||
this(DateTime.MinValue, new(), null, null, null, location, i, null, relativePath)
|
||||
{
|
||||
DateTime?[] dateTimes;
|
||||
_OutputResolution = new(outputResolutionHeight, outputResolutionOrientation, outputResolutionWidth);
|
||||
@ -78,4 +84,7 @@ public class Face : Properties.IFace
|
||||
public void SetFaceEncoding(FaceEncoding faceEncoding) => _FaceEncoding = faceEncoding;
|
||||
|
||||
public void SetFaceParts(Dictionary<Stateless.FacePart, FacePoint[]> faceParts) => _FaceParts = faceParts;
|
||||
|
||||
public void SetFaceNumbers(List<int[]> faceNumbers) => _FaceNumbers = faceNumbers;
|
||||
|
||||
}
|
@ -12,15 +12,17 @@ public class Mapping : Properties.IMapping
|
||||
protected bool _Forced;
|
||||
protected readonly int? _NormalizedPixelPercentage;
|
||||
protected PersonBirthday _PersonBirthday;
|
||||
protected readonly string _SegmentB;
|
||||
public int? ApproximateYears => _ApproximateYears;
|
||||
public string DisplayDirectoryName => _DisplayDirectoryName;
|
||||
public bool? Filtered => _Filtered;
|
||||
public bool Forced => _Forced;
|
||||
public int? NormalizedPixelPercentage => _NormalizedPixelPercentage;
|
||||
public PersonBirthday PersonBirthday => _PersonBirthday;
|
||||
public string SegmentB => _SegmentB;
|
||||
|
||||
[JsonConstructor]
|
||||
public Mapping(int? approximateYears, string displayDirectoryName, bool? filtered, bool forced, int? normalizedPixelPercentage, PersonBirthday personBirthday)
|
||||
public Mapping(int? approximateYears, string displayDirectoryName, bool? filtered, bool forced, int? normalizedPixelPercentage, PersonBirthday personBirthday, string segmentB)
|
||||
{
|
||||
_ApproximateYears = approximateYears;
|
||||
_DisplayDirectoryName = displayDirectoryName;
|
||||
@ -28,14 +30,15 @@ public class Mapping : Properties.IMapping
|
||||
_Forced = forced;
|
||||
_NormalizedPixelPercentage = normalizedPixelPercentage;
|
||||
_PersonBirthday = personBirthday;
|
||||
_SegmentB = segmentB;
|
||||
}
|
||||
|
||||
public Mapping(int? approximateYears, string displayDirectoryName, bool forced, int? normalizedPixelPercentage, PersonBirthday personBirthday) :
|
||||
this(approximateYears, displayDirectoryName, null, forced, normalizedPixelPercentage, personBirthday)
|
||||
public Mapping(int? approximateYears, string displayDirectoryName, bool forced, int? normalizedPixelPercentage, PersonBirthday personBirthday, string segmentB) :
|
||||
this(approximateYears, displayDirectoryName, null, forced, normalizedPixelPercentage, personBirthday, segmentB)
|
||||
{ }
|
||||
|
||||
public Mapping(int? approximateYears, string displayDirectoryName, bool forced, PersonBirthday personBirthday) :
|
||||
this(approximateYears, displayDirectoryName, null, forced, null, personBirthday)
|
||||
public Mapping(int? approximateYears, string displayDirectoryName, bool forced, PersonBirthday personBirthday, string segmentB) :
|
||||
this(approximateYears, displayDirectoryName, null, forced, null, personBirthday, segmentB)
|
||||
{ }
|
||||
|
||||
public override string ToString()
|
||||
|
@ -7,6 +7,7 @@ public interface IFace
|
||||
public List<FaceDistance> FaceDistances { get; }
|
||||
public FaceEncoding? FaceEncoding { get; }
|
||||
public Dictionary<Stateless.FacePart, FacePoint[]>? FaceParts { get; }
|
||||
public List<int[]>? FaceNumbers { get; }
|
||||
public Location? Location { get; }
|
||||
public int? LocationIndex { get; }
|
||||
public OutputResolution? OutputResolution { get; }
|
||||
|
@ -9,5 +9,6 @@ public interface IMapping
|
||||
public bool Forced { get; }
|
||||
public int? NormalizedPixelPercentage { get; }
|
||||
public PersonBirthday PersonBirthday { get; }
|
||||
public string SegmentB { get; }
|
||||
|
||||
}
|
12
Shared/Models/Properties/ISorting.cs
Normal file
12
Shared/Models/Properties/ISorting.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace View_by_Distance.Shared.Models.Properties;
|
||||
|
||||
public interface ISorting
|
||||
{
|
||||
|
||||
public double? Confidence { init; get; }
|
||||
public double? Distance { init; get; }
|
||||
public int? FaceEncoding { init; get; }
|
||||
public int Id { init; get; }
|
||||
public int? NormalizedPixelPercentage { init; get; }
|
||||
|
||||
}
|
49
Shared/Models/Sorting.cs
Normal file
49
Shared/Models/Sorting.cs
Normal file
@ -0,0 +1,49 @@
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public class Sorting : Properties.ISorting
|
||||
{
|
||||
|
||||
public double? Confidence { init; get; }
|
||||
public double? Distance { init; get; }
|
||||
public int? FaceEncoding { init; get; }
|
||||
public int Id { init; get; }
|
||||
public int? NormalizedPixelPercentage { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public Sorting(double? confidence, double? distance, int? faceEncoding, int id, int? normalizedPixelPercentage)
|
||||
{
|
||||
Confidence = confidence;
|
||||
Distance = distance;
|
||||
FaceEncoding = faceEncoding;
|
||||
Id = id;
|
||||
NormalizedPixelPercentage = normalizedPixelPercentage;
|
||||
}
|
||||
|
||||
public Sorting(double? confidence, int id, int? normalizedPixelPercentage)
|
||||
{
|
||||
Confidence = confidence;
|
||||
Distance = null;
|
||||
FaceEncoding = int.MaxValue;
|
||||
Id = id;
|
||||
NormalizedPixelPercentage = normalizedPixelPercentage;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
public Sorting(Sorting sorting, double? distance)
|
||||
{
|
||||
Confidence = sorting.Confidence;
|
||||
Distance = distance;
|
||||
FaceEncoding = null;
|
||||
Id = sorting.Id;
|
||||
NormalizedPixelPercentage = sorting.NormalizedPixelPercentage;
|
||||
}
|
||||
|
||||
}
|
@ -37,6 +37,21 @@ internal abstract class Face
|
||||
return jsonElements;
|
||||
}
|
||||
|
||||
internal static List<Models.Sorting> GetSortingCollection(Models.Face face)
|
||||
{
|
||||
List<Models.Sorting> results = new();
|
||||
Models.Sorting sorting;
|
||||
if (face.FaceNumbers is not null)
|
||||
{
|
||||
foreach (int[] numbers in face.FaceNumbers)
|
||||
{
|
||||
sorting = Sorting.Get(numbers);
|
||||
results.Add(sorting);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private static List<Models.Face> GetFaces(string jsonFileFullName, int? maximum)
|
||||
{
|
||||
List<Models.Face> results = new();
|
||||
|
@ -18,7 +18,11 @@ public interface IFace
|
||||
Models.Face[] TestStatic_Getα(Dictionary<FacePart, Models.FacePoint[]> faceParts);
|
||||
static double? Getα(Dictionary<FacePart, Models.FacePoint[]> faceParts) => Face.Getα(faceParts);
|
||||
|
||||
List<Models.Sorting> TestStatic_GetSortingCollection(Models.Face face);
|
||||
static List<Models.Sorting> GetSortingCollection(Models.Face face) => Face.GetSortingCollection(face);
|
||||
|
||||
int?[] TestStatic_GetInts(List<Models.Face> faces);
|
||||
static int?[] GetInts(List<Models.Face> faces) => (from l in faces where l.FaceEncoding is not null && l.Location?.NormalizedPixelPercentage is not null select l.Location?.NormalizedPixelPercentage).ToArray();
|
||||
static int?[] GetInts(List<Models.Face> faces) =>
|
||||
(from l in faces where l.FaceEncoding is not null && l.Location?.NormalizedPixelPercentage is not null select l.Location?.NormalizedPixelPercentage).ToArray();
|
||||
|
||||
}
|
12
Shared/Models/Stateless/Methods/ISorting.cs
Normal file
12
Shared/Models/Stateless/Methods/ISorting.cs
Normal file
@ -0,0 +1,12 @@
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
public interface ISorting
|
||||
{ // ...
|
||||
|
||||
Models.Sorting TestStatic_GetSorting(int[] numbers);
|
||||
static Models.Sorting GetSorting(int[] numbers) => Sorting.Get(numbers);
|
||||
|
||||
List<int[]> TestStatic_GetFaceNumbers(List<Models.Sorting> collection);
|
||||
static List<int[]> GetFaceNumbers(List<Models.Sorting> collection) => Sorting.GetFaceNumbers(collection);
|
||||
|
||||
}
|
50
Shared/Models/Stateless/Methods/Sorting.cs
Normal file
50
Shared/Models/Stateless/Methods/Sorting.cs
Normal file
@ -0,0 +1,50 @@
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
internal abstract class Sorting
|
||||
{
|
||||
|
||||
internal static Models.Sorting Get(int[] collection)
|
||||
{
|
||||
if (collection.Length != 5)
|
||||
throw new Exception();
|
||||
Models.Sorting result;
|
||||
int id = collection[3];
|
||||
int distance = collection[1];
|
||||
int confidence = collection[2];
|
||||
int faceEncoding = collection[0];
|
||||
int normalizedPixelPercentage = collection[4];
|
||||
result = new(confidence, distance, faceEncoding, id, normalizedPixelPercentage);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static List<int[]> GetFaceNumbers(List<Models.Sorting> collection)
|
||||
{
|
||||
List<int[]> results = new();
|
||||
List<int> faceNumbers;
|
||||
collection = (from l in collection orderby l.FaceEncoding is not null, l.Distance, l.Confidence descending, l.Id, l.NormalizedPixelPercentage select l).ToList();
|
||||
foreach (Models.Sorting sorting in collection)
|
||||
{
|
||||
faceNumbers = new();
|
||||
if (sorting.FaceEncoding is null)
|
||||
faceNumbers.Add(Stateless.ILocation.Factor);
|
||||
else
|
||||
faceNumbers.Add(Stateless.ILocation.Factor * 2);
|
||||
if (sorting.Distance is null)
|
||||
faceNumbers.Add(Stateless.ILocation.Factor);
|
||||
else
|
||||
faceNumbers.Add((int)(Math.Round(sorting.Distance.Value, Stateless.ILocation.Digits) * Stateless.ILocation.Factor));
|
||||
if (sorting.Confidence is null)
|
||||
faceNumbers.Add(Stateless.ILocation.Factor);
|
||||
else
|
||||
faceNumbers.Add((int)(Math.Round(sorting.Confidence.Value, Stateless.ILocation.Digits) * Stateless.ILocation.Factor));
|
||||
faceNumbers.Add(sorting.Id);
|
||||
if (sorting.NormalizedPixelPercentage is null)
|
||||
faceNumbers.Add(Stateless.ILocation.Factor);
|
||||
else
|
||||
faceNumbers.Add(sorting.NormalizedPixelPercentage.Value);
|
||||
results.Add(faceNumbers.ToArray());
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user