Face Distance Area Permille Tolerance
This commit is contained in:
parent
abe6c80d82
commit
152612bacb
1
.vscode/settings.json
vendored
1
.vscode/settings.json
vendored
@ -22,6 +22,7 @@
|
||||
"Niépce",
|
||||
"nosj",
|
||||
"paramref",
|
||||
"permille",
|
||||
"permyriad",
|
||||
"Phares",
|
||||
"Phgtv",
|
||||
|
@ -18,9 +18,10 @@ public class E_Distance : Shared.Models.Methods.IFaceDistance
|
||||
private readonly bool _DistanceMoveUnableToMatch;
|
||||
private readonly int _DistancePixelDistanceTolerance;
|
||||
private readonly double _FaceDistanceMinimumConfidence;
|
||||
private readonly int _FaceDistanceAreaPermilleTolerance;
|
||||
private readonly int _SortingMaximumPerFaceShouldBeHigh;
|
||||
|
||||
public E_Distance(bool distanceMoveUnableToMatch, int distancePixelDistanceTolerance, double faceDistanceMinimumConfidence, int faceDistancePermyriad, double faceDistanceTolerance, string resultAllInOne, int sortingDaysDeltaTolerance, int sortingMaximumPerFaceShouldBeHigh)
|
||||
public E_Distance(bool distanceMoveUnableToMatch, int distancePixelDistanceTolerance, int faceDistanceAreaPermilleTolerance, double faceDistanceMinimumConfidence, int faceDistancePermyriad, double faceDistanceTolerance, string resultAllInOne, int sortingDaysDeltaTolerance, int sortingMaximumPerFaceShouldBeHigh)
|
||||
{
|
||||
_ResultAllInOne = resultAllInOne;
|
||||
_Log = Serilog.Log.ForContext<E_Distance>();
|
||||
@ -30,6 +31,7 @@ public class E_Distance : Shared.Models.Methods.IFaceDistance
|
||||
_SortingDaysDeltaTolerance = sortingDaysDeltaTolerance;
|
||||
_FaceDistanceMinimumConfidence = faceDistanceMinimumConfidence;
|
||||
_DistancePixelDistanceTolerance = distancePixelDistanceTolerance;
|
||||
_FaceDistanceAreaPermilleTolerance = faceDistanceAreaPermilleTolerance;
|
||||
_SortingMaximumPerFaceShouldBeHigh = sortingMaximumPerFaceShouldBeHigh;
|
||||
}
|
||||
|
||||
@ -63,77 +65,89 @@ public class E_Distance : Shared.Models.Methods.IFaceDistance
|
||||
double faceDistancePermyriad;
|
||||
double sortingDaysDeltaTolerance;
|
||||
double faceDistanceMinimumConfidence;
|
||||
double faceDistanceAreaPermilleTolerance;
|
||||
if (useFiltersCounter is null)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance;
|
||||
faceDistancePermyriad = _FaceDistancePermyriad;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance;
|
||||
faceDistanceMinimumConfidence = _FaceDistanceMinimumConfidence;
|
||||
}
|
||||
else if (useFiltersCounter.Value == 1)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance * 1.5;
|
||||
faceDistancePermyriad = _FaceDistancePermyriad;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance;
|
||||
faceDistanceMinimumConfidence = _FaceDistanceMinimumConfidence;
|
||||
}
|
||||
else if (useFiltersCounter.Value == 2)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance;
|
||||
faceDistancePermyriad = _FaceDistancePermyriad * 1.5;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance;
|
||||
faceDistanceMinimumConfidence = _FaceDistanceMinimumConfidence;
|
||||
}
|
||||
else if (useFiltersCounter.Value == 3)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance;
|
||||
faceDistancePermyriad = _FaceDistancePermyriad;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance;
|
||||
faceDistanceMinimumConfidence = _FaceDistanceMinimumConfidence * .5;
|
||||
}
|
||||
else if (useFiltersCounter.Value == 4)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance * 2;
|
||||
faceDistancePermyriad = _FaceDistancePermyriad * 1.5;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance;
|
||||
faceDistanceMinimumConfidence = _FaceDistanceMinimumConfidence * .5;
|
||||
}
|
||||
else if (useFiltersCounter.Value == 5)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance * 1.5;
|
||||
faceDistancePermyriad = _FaceDistancePermyriad * 2;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance;
|
||||
faceDistanceMinimumConfidence = _FaceDistanceMinimumConfidence * .5;
|
||||
}
|
||||
else if (useFiltersCounter.Value == 6)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance * 1.5;
|
||||
faceDistancePermyriad = _FaceDistancePermyriad * 1.5;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance;
|
||||
faceDistanceMinimumConfidence = _FaceDistanceMinimumConfidence * .25;
|
||||
}
|
||||
else if (useFiltersCounter.Value == 7)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance * 2.5;
|
||||
faceDistancePermyriad = _FaceDistancePermyriad * 2;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance;
|
||||
faceDistanceMinimumConfidence = _FaceDistanceMinimumConfidence * .25;
|
||||
}
|
||||
else if (useFiltersCounter.Value == 8)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance * 2;
|
||||
faceDistancePermyriad = _FaceDistancePermyriad * 2.5;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance;
|
||||
faceDistanceMinimumConfidence = _FaceDistanceMinimumConfidence * .25;
|
||||
}
|
||||
else if (useFiltersCounter.Value == 9)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance * 2;
|
||||
faceDistancePermyriad = _FaceDistancePermyriad * 2;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance;
|
||||
faceDistanceMinimumConfidence = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
sortingDaysDeltaTolerance = int.MaxValue;
|
||||
faceDistancePermyriad = int.MaxValue;
|
||||
faceDistanceAreaPermilleTolerance = 0;
|
||||
faceDistanceMinimumConfidence = 0;
|
||||
}
|
||||
foreach (Sorting sorting in collection)
|
||||
{
|
||||
if (face.Mapping is null || faceDistanceEncoding.NormalizedPixelPercentage is null)
|
||||
throw new NotSupportedException();
|
||||
if (sorting.DaysDelta > sortingDaysDeltaTolerance || sorting.DistancePermyriad > faceDistancePermyriad || face.Mapping.MappingFromLocation.Confidence < faceDistanceMinimumConfidence)
|
||||
if (sorting.DaysDelta > sortingDaysDeltaTolerance || sorting.DistancePermyriad > faceDistancePermyriad || face.Mapping.MappingFromLocation.Confidence < faceDistanceMinimumConfidence || face.Mapping.MappingFromLocation.AreaPermille < faceDistanceAreaPermilleTolerance)
|
||||
continue;
|
||||
sortingContainer = new(face, sorting);
|
||||
results.Add(sortingContainer);
|
||||
@ -433,7 +447,7 @@ public class E_Distance : Shared.Models.Methods.IFaceDistance
|
||||
return results;
|
||||
}
|
||||
|
||||
private static List<(Face Face, double Length)> GetValues(double faceDistanceTolerance, MappingFromItem mappingFromItem, List<Face> faces, string json)
|
||||
private List<(Face Face, double Length)> GetValues(MappingFromItem mappingFromItem, List<Face> faces, string json)
|
||||
{
|
||||
List<(Face Face, double Length)> results = new();
|
||||
Face face;
|
||||
@ -459,17 +473,17 @@ public class E_Distance : Shared.Models.Methods.IFaceDistance
|
||||
faceDistanceLength = faceDistanceLengths[i];
|
||||
if (faceDistanceLength.Length is null)
|
||||
throw new NotSupportedException();
|
||||
if (faceDistanceLength.Length.Value > faceDistanceTolerance)
|
||||
if (faceDistanceLength.Length.Value > _FaceDistanceTolerance)
|
||||
continue;
|
||||
results.Add(new(face, faceDistanceLength.Length.Value));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private static Face[] GetMatchingFaces(double faceDistanceTolerance, MappingFromItem mappingFromItem, List<Face> faces, string json)
|
||||
private Face[] GetMatchingFaces(MappingFromItem mappingFromItem, List<Face> faces, string json)
|
||||
{
|
||||
Face[] results;
|
||||
List<(Face Face, double Length)> collection = GetValues(faceDistanceTolerance, mappingFromItem, faces, json);
|
||||
List<(Face Face, double Length)> collection = GetValues(mappingFromItem, faces, json);
|
||||
if (!collection.Any())
|
||||
results = Array.Empty<Face>();
|
||||
else
|
||||
@ -623,7 +637,7 @@ public class E_Distance : Shared.Models.Methods.IFaceDistance
|
||||
checkFaces.Clear();
|
||||
if (json is null)
|
||||
throw new NotSupportedException();
|
||||
checkFaces.AddRange(GetMatchingFaces(_FaceDistanceTolerance, mappingFromItem, faces, json));
|
||||
checkFaces.AddRange(GetMatchingFaces(mappingFromItem, faces, json));
|
||||
}
|
||||
if (checkFaces.Count != 1 && _DistancePixelDistanceTolerance > 0)
|
||||
{
|
||||
|
@ -34,6 +34,7 @@ public class D_Face
|
||||
private readonly bool _RetryImagesWithoutAFace;
|
||||
private readonly Configuration _Configuration;
|
||||
private readonly int _NumberOfTimesToUpsample;
|
||||
private readonly int _FaceDistanceAreaPermilleTolerance;
|
||||
private readonly ImageCodecInfo _ImageCodecInfo;
|
||||
private readonly ModelParameter _ModelParameter;
|
||||
private readonly PredictorModel _PredictorModel;
|
||||
@ -52,6 +53,7 @@ public class D_Face
|
||||
bool checkDFaceAndUpWriteDates,
|
||||
Configuration configuration,
|
||||
EncoderParameters encoderParameters,
|
||||
int faceDistanceAreaPermilleTolerance,
|
||||
int faceDistanceHiddenImageFactor,
|
||||
string filenameExtension,
|
||||
bool forceFaceLastWriteTimeToCreationTime,
|
||||
@ -87,6 +89,7 @@ public class D_Face
|
||||
_NumberOfTimesToUpsample = numberOfTimesToUpsample;
|
||||
_CheckDFaceAndUpWriteDates = checkDFaceAndUpWriteDates;
|
||||
_PropertiesChangedForFaces = propertiesChangedForFaces;
|
||||
_FaceDistanceAreaPermilleTolerance = faceDistanceAreaPermilleTolerance;
|
||||
_FaceDistanceHiddenImageFactor = faceDistanceHiddenImageFactor;
|
||||
_ForceFaceLastWriteTimeToCreationTime = forceFaceLastWriteTimeToCreationTime;
|
||||
ConstructorInfo? constructorInfo = typeof(PropertyItem).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, Array.Empty<Type>(), null);
|
||||
|
@ -75,6 +75,7 @@ public partial class DlibDotNet
|
||||
_Distance = new(
|
||||
configuration.DistanceMoveUnableToMatch,
|
||||
configuration.DistancePixelDistanceTolerance,
|
||||
configuration.FaceDistanceAreaPermilleTolerance,
|
||||
configuration.FaceDistanceMinimumConfidence,
|
||||
configuration.FaceDistancePermyriad,
|
||||
configuration.FaceDistanceTolerance,
|
||||
@ -98,6 +99,7 @@ public partial class DlibDotNet
|
||||
configuration.CheckDFaceAndUpWriteDates,
|
||||
configuration.PropertyConfiguration,
|
||||
encoderParameters,
|
||||
configuration.FaceDistanceAreaPermilleTolerance,
|
||||
configuration.FaceDistanceHiddenImageFactor,
|
||||
filenameExtension,
|
||||
configuration.ForceFaceLastWriteTimeToCreationTime,
|
||||
@ -324,6 +326,7 @@ public partial class DlibDotNet
|
||||
private static Map.Models.Configuration Get(Models.Configuration configuration)
|
||||
{
|
||||
Map.Models.Configuration result = new(
|
||||
configuration.FaceDistanceAreaPermilleTolerance,
|
||||
configuration.FaceDistanceHiddenImageFactor,
|
||||
configuration.FaceDistancePermyriad,
|
||||
configuration.FaceDistanceMinimumConfidence,
|
||||
@ -843,6 +846,7 @@ public partial class DlibDotNet
|
||||
{
|
||||
List<Shared.Models.Face> results = new();
|
||||
Mapping mapping;
|
||||
int areaPermille;
|
||||
bool? isWrongYear;
|
||||
Item[] filteredItems;
|
||||
DateTime minimumDateTime;
|
||||
@ -875,10 +879,11 @@ public partial class DlibDotNet
|
||||
break;
|
||||
if (face.FaceEncoding is null || face.Location is null || face.OutputResolution is null)
|
||||
continue;
|
||||
areaPermille = Shared.Models.Stateless.Methods.IMapping.GetAreaPermille(face.Location, face.OutputResolution);
|
||||
mappingFromPerson = new(approximateYears: null, by: null, displayDirectoryName: string.Empty, personBirthday: null, segmentB: string.Empty);
|
||||
normalizedPixelPercentage = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(face.Location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, face.OutputResolution);
|
||||
deterministicHashCodeKey = Shared.Models.Stateless.Methods.IMapping.GetDeterministicHashCodeKey(item.Property.Id.Value, face.Location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, face.OutputResolution);
|
||||
mappingFromLocation = new(face.Location.Confidence, deterministicHashCodeKey, normalizedPixelPercentage);
|
||||
mappingFromLocation = new(areaPermille, face.Location.Confidence, deterministicHashCodeKey, normalizedPixelPercentage);
|
||||
mapping = new(mappingFromItem, mappingFromLocation, mappingFromPerson);
|
||||
face.SetMapping(mapping);
|
||||
results.Add(face);
|
||||
|
@ -16,6 +16,7 @@ public class Configuration
|
||||
[Display(Name = "Distance Factor"), Required] public int? DistanceFactor { get; set; }
|
||||
[Display(Name = "Distance Move Unable to Match by 1 Tick"), Required] public bool? DistanceMoveUnableToMatch { get; set; }
|
||||
[Display(Name = "Distance Pixel Distance Tolerance"), Required] public int? DistancePixelDistanceTolerance { get; set; }
|
||||
[Display(Name = "Face Area Permille Tolerance"), Required] public int? FaceDistanceAreaPermilleTolerance { get; set; }
|
||||
[Display(Name = "Face Distance Hidden Image Factor"), Required] public int? FaceDistanceHiddenImageFactor { get; set; }
|
||||
[Display(Name = "Location Minimum Confidence"), Required] public double? FaceDistanceMinimumConfidence { get; set; }
|
||||
[Display(Name = "Face Distance Permyriad"), Required] public int? FaceDistancePermyriad { get; set; }
|
||||
@ -99,6 +100,8 @@ public class Configuration
|
||||
throw new NullReferenceException(nameof(configuration.DistanceMoveUnableToMatch));
|
||||
if (configuration.DistancePixelDistanceTolerance is null)
|
||||
throw new NullReferenceException(nameof(configuration.DistancePixelDistanceTolerance));
|
||||
if (configuration.FaceDistanceAreaPermilleTolerance is null)
|
||||
throw new NullReferenceException(nameof(configuration.FaceDistanceAreaPermilleTolerance));
|
||||
if (configuration.FaceDistanceHiddenImageFactor is null)
|
||||
throw new NullReferenceException(nameof(configuration.FaceDistanceHiddenImageFactor));
|
||||
if (configuration.FaceDistanceMinimumConfidence is null)
|
||||
@ -220,6 +223,7 @@ public class Configuration
|
||||
configuration.DistanceFactor.Value,
|
||||
configuration.DistanceMoveUnableToMatch.Value,
|
||||
configuration.DistancePixelDistanceTolerance.Value,
|
||||
configuration.FaceDistanceAreaPermilleTolerance.Value,
|
||||
configuration.FaceDistanceHiddenImageFactor.Value,
|
||||
configuration.FaceDistanceMinimumConfidence.Value,
|
||||
configuration.FaceDistancePermyriad.Value,
|
||||
|
@ -15,6 +15,7 @@ public class Configuration
|
||||
public int DistanceFactor { init; get; }
|
||||
public bool DistanceMoveUnableToMatch { init; get; }
|
||||
public int DistancePixelDistanceTolerance { init; get; }
|
||||
public int FaceDistanceAreaPermilleTolerance { init; get; }
|
||||
public int FaceDistanceHiddenImageFactor { init; get; }
|
||||
public double FaceDistanceMinimumConfidence { init; get; }
|
||||
public int FaceDistancePermyriad { init; get; }
|
||||
@ -82,6 +83,7 @@ public class Configuration
|
||||
int distanceFactor,
|
||||
bool distanceMoveUnableToMatch,
|
||||
int distancePixelDistanceTolerance,
|
||||
int faceDistanceAreaPermilleTolerance,
|
||||
int faceDistanceHiddenImageFactor,
|
||||
double faceDistanceMinimumConfidence,
|
||||
int faceDistancePermyriad,
|
||||
@ -148,6 +150,7 @@ public class Configuration
|
||||
DistanceFactor = distanceFactor;
|
||||
DistanceMoveUnableToMatch = distanceMoveUnableToMatch;
|
||||
DistancePixelDistanceTolerance = distancePixelDistanceTolerance;
|
||||
FaceDistanceAreaPermilleTolerance = faceDistanceAreaPermilleTolerance;
|
||||
FaceDistanceHiddenImageFactor = faceDistanceHiddenImageFactor;
|
||||
FaceDistanceMinimumConfidence = faceDistanceMinimumConfidence;
|
||||
FaceDistancePermyriad = faceDistancePermyriad;
|
||||
|
@ -57,6 +57,7 @@
|
||||
"DistanceFactor": 8,
|
||||
"DistanceMoveUnableToMatch": false,
|
||||
"DistancePixelDistanceTolerance": 1,
|
||||
"FaceDistanceAreaPermilleTolerance": 250,
|
||||
"FaceDistanceHiddenImageFactor": 2,
|
||||
"FaceDistanceMinimumConfidence": 0.8,
|
||||
"FaceDistancePermyriad": 10000,
|
||||
|
@ -57,6 +57,7 @@
|
||||
"DistanceFactor": 8,
|
||||
"DistanceMoveUnableToMatch": false,
|
||||
"DistancePixelDistanceTolerance": 1,
|
||||
"FaceDistanceAreaPermilleTolerance": 250,
|
||||
"FaceDistanceHiddenImageFactor": 2,
|
||||
"FaceDistanceMinimumConfidence": 0.8,
|
||||
"FaceDistancePermyriad": 10000,
|
||||
|
@ -57,6 +57,7 @@
|
||||
"DistanceFactor": 8,
|
||||
"DistanceMoveUnableToMatch": false,
|
||||
"DistancePixelDistanceTolerance": 1,
|
||||
"FaceDistanceAreaPermilleTolerance": 250,
|
||||
"FaceDistanceHiddenImageFactor": 2,
|
||||
"FaceDistanceMinimumConfidence": 0.8,
|
||||
"FaceDistancePermyriad": 10000,
|
||||
|
@ -6,6 +6,7 @@ namespace View_by_Distance.Map.Models;
|
||||
public class Configuration
|
||||
{
|
||||
|
||||
public int FaceDistanceAreaPermilleTolerance { init; get; }
|
||||
public int FaceDistanceHiddenImageFactor { init; get; }
|
||||
public int FaceDistancePermyriad { init; get; }
|
||||
public double FaceDistanceMinimumConfidence { init; get; }
|
||||
@ -26,7 +27,8 @@ public class Configuration
|
||||
public int SortingSigma { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public Configuration(int faceDistanceHiddenImageFactor,
|
||||
public Configuration(int faceDistanceAreaPermilleTolerance,
|
||||
int faceDistanceHiddenImageFactor,
|
||||
int faceDistancePermyriad,
|
||||
double faceDistanceMinimumConfidence,
|
||||
double faceDistanceTolerance,
|
||||
@ -45,6 +47,7 @@ public class Configuration
|
||||
int sortingMaximumPerKey,
|
||||
int sortingSigma)
|
||||
{
|
||||
FaceDistanceAreaPermilleTolerance = faceDistanceAreaPermilleTolerance;
|
||||
FaceDistanceHiddenImageFactor = faceDistanceHiddenImageFactor;
|
||||
FaceDistancePermyriad = faceDistancePermyriad;
|
||||
FaceDistanceMinimumConfidence = faceDistanceMinimumConfidence;
|
||||
|
@ -35,13 +35,15 @@ public class MappingFromItem : Properties.IMappingFromItem
|
||||
public class MappingFromLocation : Properties.IMappingFromLocation
|
||||
{
|
||||
|
||||
public double AreaPermille { init; get; }
|
||||
public double Confidence { init; get; }
|
||||
public string DeterministicHashCodeKey { init; get; }
|
||||
public int NormalizedPixelPercentage { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public MappingFromLocation(double confidence, string deterministicHashCodeKey, int normalizedPixelPercentage)
|
||||
public MappingFromLocation(int areaPermille, double confidence, string deterministicHashCodeKey, int normalizedPixelPercentage)
|
||||
{
|
||||
AreaPermille = areaPermille;
|
||||
Confidence = confidence;
|
||||
DeterministicHashCodeKey = deterministicHashCodeKey;
|
||||
NormalizedPixelPercentage = normalizedPixelPercentage;
|
||||
|
@ -15,6 +15,7 @@ public interface IMappingFromItem
|
||||
public interface IMappingFromLocation
|
||||
{
|
||||
|
||||
public double AreaPermille { init; get; }
|
||||
public double Confidence { init; get; }
|
||||
public string DeterministicHashCodeKey { init; get; }
|
||||
public int NormalizedPixelPercentage { init; get; }
|
||||
|
@ -8,6 +8,21 @@ public interface IMapping
|
||||
static (string?, string?, string?, bool?) GetSegments(string facesFileNameExtension, string fileName)
|
||||
=> Mapping.GetSegments(facesFileNameExtension, fileName);
|
||||
|
||||
int TestStatic_GetAreaPermille(int height, Models.Location location, int width)
|
||||
=> GetAreaPermille(height, location, width);
|
||||
static int GetAreaPermille(int height, Models.Location location, int width)
|
||||
=> Mapping.GetAreaPermille(location.Bottom, height, location.Left, location.Right, location.Top, width);
|
||||
|
||||
int TestStatic_GetAreaPermille(int bottom, int height, int left, int right, int top, int width)
|
||||
=> GetAreaPermille(bottom, height, left, right, top, width);
|
||||
static int GetAreaPermille(int bottom, int height, int left, int right, int top, int width)
|
||||
=> Mapping.GetAreaPermille(bottom, height, left, right, top, width);
|
||||
|
||||
int TestStatic_GetAreaPermille(Models.Location location, OutputResolution outputResolution)
|
||||
=> GetAreaPermille(location, outputResolution);
|
||||
static int GetAreaPermille(Models.Location location, OutputResolution outputResolution)
|
||||
=> Mapping.GetAreaPermille(location.Bottom, outputResolution.Height, location.Left, location.Right, location.Top, outputResolution.Width);
|
||||
|
||||
string TestStatic_GetDeterministicHashCodeKey(int id, Models.Location location, int locationDigits, int locationFactor, OutputResolution outputResolution)
|
||||
=> GetDeterministicHashCodeKey(id, location, locationDigits, locationFactor, outputResolution);
|
||||
static string GetDeterministicHashCodeKey(int id, Models.Location location, int locationDigits, int locationFactor, OutputResolution outputResolution)
|
||||
|
@ -78,4 +78,13 @@ internal abstract class Mapping
|
||||
return new(id, normalizedPixelPercentage, faces);
|
||||
}
|
||||
|
||||
internal static int GetAreaPermille(int bottom, int height, int left, int right, int top, int width)
|
||||
{
|
||||
int result;
|
||||
double area = width * height;
|
||||
double locationArea = (right - left) * (bottom - top);
|
||||
result = (int)Math.Round(locationArea / area * 1000, 0);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -203,6 +203,41 @@ public class UnitTestCalculations
|
||||
_ = new Location(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestAreaPermille()
|
||||
{
|
||||
Location location;
|
||||
double confidence = 0.1D;
|
||||
int areaPermille, left, top, right, bottom, width, height;
|
||||
left = 0;
|
||||
right = 100;
|
||||
top = 0;
|
||||
bottom = 100;
|
||||
width = 100;
|
||||
height = 100;
|
||||
areaPermille = IMapping.GetAreaPermille(bottom, height, left, right, top, width);
|
||||
Assert.IsTrue(areaPermille == 1000);
|
||||
left = 0;
|
||||
right = 50;
|
||||
top = 0;
|
||||
bottom = 50;
|
||||
width = 100;
|
||||
height = 100;
|
||||
location = new(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
||||
areaPermille = IMapping.GetAreaPermille(height, location, width);
|
||||
Assert.IsTrue(areaPermille == 250);
|
||||
left = 0;
|
||||
right = 25;
|
||||
top = 0;
|
||||
bottom = 25;
|
||||
width = 100;
|
||||
height = 100;
|
||||
location = new(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
||||
OutputResolution outputResolution = new(height, 0, width);
|
||||
areaPermille = IMapping.GetAreaPermille(location, outputResolution);
|
||||
Assert.IsTrue(areaPermille == 62);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void TestGetPixelPercentageA()
|
||||
{
|
||||
|
@ -16,6 +16,7 @@ public class Configuration
|
||||
[Display(Name = "Distance Factor"), Required] public int? DistanceFactor { get; set; }
|
||||
[Display(Name = "Distance Move Unable to Match by 1 Tick"), Required] public bool? DistanceMoveUnableToMatch { get; set; }
|
||||
[Display(Name = "Distance Pixel Distance Tolerance"), Required] public int? DistancePixelDistanceTolerance { get; set; }
|
||||
[Display(Name = "Face Area Permille Tolerance"), Required] public int? FaceDistanceAreaPermilleTolerance { get; set; }
|
||||
[Display(Name = "Face Distance Hidden Image Factor"), Required] public int? FaceDistanceHiddenImageFactor { get; set; }
|
||||
[Display(Name = "Location Minimum Confidence"), Required] public double? FaceDistanceMinimumConfidence { get; set; }
|
||||
[Display(Name = "Face Distance Permyriad"), Required] public int? FaceDistancePermyriad { get; set; }
|
||||
@ -99,6 +100,8 @@ public class Configuration
|
||||
throw new NullReferenceException(nameof(configuration.DistanceMoveUnableToMatch));
|
||||
if (configuration.DistancePixelDistanceTolerance is null)
|
||||
throw new NullReferenceException(nameof(configuration.DistancePixelDistanceTolerance));
|
||||
if (configuration.FaceDistanceAreaPermilleTolerance is null)
|
||||
throw new NullReferenceException(nameof(configuration.FaceDistanceAreaPermilleTolerance));
|
||||
if (configuration.FaceDistanceHiddenImageFactor is null)
|
||||
throw new NullReferenceException(nameof(configuration.FaceDistanceHiddenImageFactor));
|
||||
if (configuration.FaceDistanceMinimumConfidence is null)
|
||||
@ -220,6 +223,7 @@ public class Configuration
|
||||
configuration.DistanceFactor.Value,
|
||||
configuration.DistanceMoveUnableToMatch.Value,
|
||||
configuration.DistancePixelDistanceTolerance.Value,
|
||||
configuration.FaceDistanceAreaPermilleTolerance.Value,
|
||||
configuration.FaceDistanceHiddenImageFactor.Value,
|
||||
configuration.FaceDistanceMinimumConfidence.Value,
|
||||
configuration.FaceDistancePermyriad.Value,
|
||||
|
@ -15,6 +15,7 @@ public class Configuration
|
||||
public int DistanceFactor { init; get; }
|
||||
public bool DistanceMoveUnableToMatch { init; get; }
|
||||
public int DistancePixelDistanceTolerance { init; get; }
|
||||
public int FaceDistanceAreaPermilleTolerance { init; get; }
|
||||
public int FaceDistanceHiddenImageFactor { init; get; }
|
||||
public double FaceDistanceMinimumConfidence { init; get; }
|
||||
public int FaceDistancePermyriad { init; get; }
|
||||
@ -82,6 +83,7 @@ public class Configuration
|
||||
int distanceFactor,
|
||||
bool distanceMoveUnableToMatch,
|
||||
int distancePixelDistanceTolerance,
|
||||
int faceDistanceAreaPermilleTolerance,
|
||||
int faceDistanceHiddenImageFactor,
|
||||
double faceDistanceMinimumConfidence,
|
||||
int faceDistancePermyriad,
|
||||
@ -148,6 +150,7 @@ public class Configuration
|
||||
DistanceFactor = distanceFactor;
|
||||
DistanceMoveUnableToMatch = distanceMoveUnableToMatch;
|
||||
DistancePixelDistanceTolerance = distancePixelDistanceTolerance;
|
||||
FaceDistanceAreaPermilleTolerance = faceDistanceAreaPermilleTolerance;
|
||||
FaceDistanceHiddenImageFactor = faceDistanceHiddenImageFactor;
|
||||
FaceDistanceMinimumConfidence = faceDistanceMinimumConfidence;
|
||||
FaceDistancePermyriad = faceDistancePermyriad;
|
||||
|
Loading…
x
Reference in New Issue
Block a user