Range
This commit is contained in:
@ -10,18 +10,23 @@ namespace View_by_Distance.Distance.Models;
|
||||
public class MapLogicSupport : Shared.Models.Methods.IMapLogicSupport
|
||||
{
|
||||
|
||||
private int _Area;
|
||||
private int _Days;
|
||||
private int _Distance;
|
||||
private int _Confidence;
|
||||
|
||||
private readonly int _FaceConfidencePercent;
|
||||
private readonly int _FaceDistancePermyriad;
|
||||
private readonly int _SortingDaysDeltaTolerance;
|
||||
private readonly double _FaceDistanceMinimumConfidence;
|
||||
private readonly int _FaceDistanceAreaPermilleTolerance;
|
||||
private readonly int[] _RangeDaysDeltaTolerance;
|
||||
private readonly int[] _RangeFaceAreaPermilleTolerance;
|
||||
private readonly int _SortingMaximumPerFaceShouldBeHigh;
|
||||
|
||||
public MapLogicSupport(int faceDistanceAreaPermilleTolerance, double faceDistanceMinimumConfidence, int faceDistancePermyriad, int sortingDaysDeltaTolerance, int sortingMaximumPerFaceShouldBeHigh)
|
||||
public MapLogicSupport(int faceConfidencePercent, int faceDistancePermyriad, int[] rangeDaysDeltaTolerance, int[] rangeFaceAreaPermilleTolerance, int sortingMaximumPerFaceShouldBeHigh)
|
||||
{
|
||||
_FaceConfidencePercent = faceConfidencePercent;
|
||||
_FaceDistancePermyriad = faceDistancePermyriad;
|
||||
_SortingDaysDeltaTolerance = sortingDaysDeltaTolerance;
|
||||
_FaceDistanceMinimumConfidence = faceDistanceMinimumConfidence;
|
||||
_FaceDistanceAreaPermilleTolerance = faceDistanceAreaPermilleTolerance;
|
||||
_RangeDaysDeltaTolerance = rangeDaysDeltaTolerance;
|
||||
_RangeFaceAreaPermilleTolerance = rangeFaceAreaPermilleTolerance;
|
||||
_SortingMaximumPerFaceShouldBeHigh = sortingMaximumPerFaceShouldBeHigh;
|
||||
}
|
||||
|
||||
@ -46,10 +51,10 @@ public class MapLogicSupport : Shared.Models.Methods.IMapLogicSupport
|
||||
double b;
|
||||
double c;
|
||||
double d;
|
||||
double faceAreaPermille;
|
||||
double faceConfidencePercent;
|
||||
double faceDistancePermyriad;
|
||||
double sortingDaysDeltaTolerance;
|
||||
double faceDistanceMinimumConfidence;
|
||||
double faceDistanceAreaPermilleTolerance;
|
||||
double rangeDaysDeltaTolerance;
|
||||
if (useFiltersCounter is null)
|
||||
{
|
||||
a = 1f;
|
||||
@ -87,52 +92,70 @@ public class MapLogicSupport : Shared.Models.Methods.IMapLogicSupport
|
||||
}
|
||||
if (useFiltersCounter is null)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance;
|
||||
rangeDaysDeltaTolerance = _RangeDaysDeltaTolerance[1];
|
||||
faceDistancePermyriad = _FaceDistancePermyriad;
|
||||
faceDistanceMinimumConfidence = _FaceDistanceMinimumConfidence;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance;
|
||||
faceConfidencePercent = _FaceConfidencePercent;
|
||||
faceAreaPermille = _RangeFaceAreaPermilleTolerance[1];
|
||||
}
|
||||
else if (useFiltersCounter.Value is 1 or 5 or 9 or 13)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance * a;
|
||||
rangeDaysDeltaTolerance = _RangeDaysDeltaTolerance[1] * a;
|
||||
faceDistancePermyriad = _FaceDistancePermyriad * c;
|
||||
faceDistanceMinimumConfidence = _FaceDistanceMinimumConfidence * d;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance * d;
|
||||
faceConfidencePercent = _FaceConfidencePercent * d;
|
||||
faceAreaPermille = _RangeFaceAreaPermilleTolerance[1] * d;
|
||||
}
|
||||
else if (useFiltersCounter.Value is 2 or 6 or 10 or 14)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance * c;
|
||||
rangeDaysDeltaTolerance = _RangeDaysDeltaTolerance[1] * c;
|
||||
faceDistancePermyriad = _FaceDistancePermyriad * a;
|
||||
faceDistanceMinimumConfidence = _FaceDistanceMinimumConfidence * d;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance * d;
|
||||
faceConfidencePercent = _FaceConfidencePercent * d;
|
||||
faceAreaPermille = _RangeFaceAreaPermilleTolerance[1] * d;
|
||||
}
|
||||
else if (useFiltersCounter.Value is 3 or 7 or 11 or 15)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance * c;
|
||||
rangeDaysDeltaTolerance = _RangeDaysDeltaTolerance[1] * c;
|
||||
faceDistancePermyriad = _FaceDistancePermyriad * c;
|
||||
faceDistanceMinimumConfidence = _FaceDistanceMinimumConfidence * b;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance * d;
|
||||
faceConfidencePercent = _FaceConfidencePercent * b;
|
||||
faceAreaPermille = _RangeFaceAreaPermilleTolerance[1] * d;
|
||||
}
|
||||
else if (useFiltersCounter.Value is 4 or 8 or 12 or 16)
|
||||
{
|
||||
sortingDaysDeltaTolerance = _SortingDaysDeltaTolerance * c;
|
||||
rangeDaysDeltaTolerance = _RangeDaysDeltaTolerance[1] * c;
|
||||
faceDistancePermyriad = _FaceDistancePermyriad * c;
|
||||
faceDistanceMinimumConfidence = _FaceDistanceMinimumConfidence * d;
|
||||
faceDistanceAreaPermilleTolerance = _FaceDistanceAreaPermilleTolerance * b;
|
||||
faceConfidencePercent = _FaceConfidencePercent * d;
|
||||
faceAreaPermille = _RangeFaceAreaPermilleTolerance[1] * b;
|
||||
}
|
||||
else
|
||||
{
|
||||
sortingDaysDeltaTolerance = int.MaxValue;
|
||||
rangeDaysDeltaTolerance = int.MaxValue;
|
||||
faceDistancePermyriad = int.MaxValue;
|
||||
faceDistanceAreaPermilleTolerance = 0;
|
||||
faceDistanceMinimumConfidence = 0;
|
||||
faceAreaPermille = 0;
|
||||
faceConfidencePercent = 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 || face.Mapping.MappingFromLocation.AreaPermille < faceDistanceAreaPermilleTolerance)
|
||||
if (sorting.DaysDelta > rangeDaysDeltaTolerance)
|
||||
{
|
||||
_Days += 1;
|
||||
continue;
|
||||
}
|
||||
if (sorting.DistancePermyriad > faceDistancePermyriad)
|
||||
{
|
||||
_Distance += 1;
|
||||
continue;
|
||||
}
|
||||
if (face.Mapping.MappingFromLocation.ConfidencePercent < faceConfidencePercent)
|
||||
{
|
||||
_Confidence += 1;
|
||||
continue;
|
||||
}
|
||||
if (face.Mapping.MappingFromLocation.AreaPermille < faceAreaPermille)
|
||||
{
|
||||
_Area += 1;
|
||||
continue;
|
||||
}
|
||||
sortingContainer = new(face.Mapping, sorting);
|
||||
results.Add(sortingContainer);
|
||||
if (results.Count >= _SortingMaximumPerFaceShouldBeHigh)
|
||||
@ -163,7 +186,7 @@ public class MapLogicSupport : Shared.Models.Methods.IMapLogicSupport
|
||||
throw new NotSupportedException();
|
||||
if (face.FaceDistance?.Encoding is not FaceRecognitionDotNet.FaceEncoding faceEncoding)
|
||||
continue;
|
||||
faceDistance = new(face.Mapping.MappingFromLocation.Confidence, faceEncoding, face.Mapping.MappingFromItem.Id, face.Mapping.MappingFromItem.IsWrongYear, face.Mapping.MappingFromItem.MinimumDateTime, face.Mapping.MappingFromLocation.NormalizedPixelPercentage);
|
||||
faceDistance = new(face.Mapping.MappingFromLocation.ConfidencePercent, faceEncoding, face.Mapping.MappingFromItem.Id, face.Mapping.MappingFromItem.IsWrongYear, face.Mapping.MappingFromItem.MinimumDateTime, face.Mapping.MappingFromLocation.NormalizedPixelPercentage);
|
||||
faceDistanceContainer = new(face, faceDistance);
|
||||
collection.Add(faceDistanceContainer);
|
||||
}
|
||||
@ -244,7 +267,7 @@ public class MapLogicSupport : Shared.Models.Methods.IMapLogicSupport
|
||||
return;
|
||||
progressBar.Tick();
|
||||
faceEncoding = FaceRecognition.LoadFaceEncoding(face.FaceEncoding.RawEncoding);
|
||||
FaceDistance faceDistance = new(face.Mapping.MappingFromLocation.Confidence, faceEncoding, face.Mapping.MappingFromItem.Id, face.Mapping.MappingFromItem.IsWrongYear, face.Mapping.MappingFromItem.MinimumDateTime, face.Mapping.MappingFromLocation.NormalizedPixelPercentage);
|
||||
FaceDistance faceDistance = new(face.Mapping.MappingFromLocation.ConfidencePercent, faceEncoding, face.Mapping.MappingFromItem.Id, face.Mapping.MappingFromItem.IsWrongYear, face.Mapping.MappingFromItem.MinimumDateTime, face.Mapping.MappingFromLocation.NormalizedPixelPercentage);
|
||||
lock (face)
|
||||
face.SetFaceDistance(faceDistance);
|
||||
});
|
||||
@ -317,4 +340,18 @@ public class MapLogicSupport : Shared.Models.Methods.IMapLogicSupport
|
||||
return results;
|
||||
}
|
||||
|
||||
string Shared.Models.Methods.IMapLogicSupport.GetCounts()
|
||||
{
|
||||
string result;
|
||||
List<(int Value, string Name)> results = new()
|
||||
{
|
||||
new(_Area, nameof(_Area)),
|
||||
new(_Confidence, nameof(_Confidence)),
|
||||
new(_Days, nameof(_Days)),
|
||||
new(_Distance, nameof(_Distance))
|
||||
};
|
||||
result = string.Join(' ', from l in results orderby l.Value descending select $"{l.Name}_{l.Value};");
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user