SegmentB, personKey,
personKeyFormatted and Sorting
This commit is contained in:
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