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