Change to the Normalized Pixel Percentage Formula
This commit is contained in:
parent
192d2ad776
commit
fb1c68e1f5
@ -273,7 +273,6 @@ public partial class DlibDotNet
|
|||||||
configuration.MapLogicSigma,
|
configuration.MapLogicSigma,
|
||||||
configuration.MappingDefaultName,
|
configuration.MappingDefaultName,
|
||||||
configuration.MappingMoveUnableToMatch,
|
configuration.MappingMoveUnableToMatch,
|
||||||
configuration.MappingSaveFaceEncoding,
|
|
||||||
configuration.MappingSaveNotMapped,
|
configuration.MappingSaveNotMapped,
|
||||||
configuration.MappingSaveMapped,
|
configuration.MappingSaveMapped,
|
||||||
configuration.MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping,
|
configuration.MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping,
|
||||||
@ -282,8 +281,6 @@ public partial class DlibDotNet
|
|||||||
configuration.PersonBirthdayFormat,
|
configuration.PersonBirthdayFormat,
|
||||||
configuration.PersonKeyFormat,
|
configuration.PersonKeyFormat,
|
||||||
configuration.SortingDaysDeltaTolerance,
|
configuration.SortingDaysDeltaTolerance,
|
||||||
configuration.SortingFacesToSkipAfterSortBeforeLoad,
|
|
||||||
configuration.SortingFacesToTakeAfterSortBeforeLoad,
|
|
||||||
configuration.SortingMaximumPerFaceShouldBeHigh,
|
configuration.SortingMaximumPerFaceShouldBeHigh,
|
||||||
configuration.SortingMaximumPerKey,
|
configuration.SortingMaximumPerKey,
|
||||||
configuration.SortingSigma);
|
configuration.SortingSigma);
|
||||||
@ -740,7 +737,7 @@ public partial class DlibDotNet
|
|||||||
if (string.IsNullOrEmpty(eResultsFullGroupDirectory))
|
if (string.IsNullOrEmpty(eResultsFullGroupDirectory))
|
||||||
throw new NullReferenceException(nameof(eResultsFullGroupDirectory));
|
throw new NullReferenceException(nameof(eResultsFullGroupDirectory));
|
||||||
List<Face> distinctFilteredFaces = SetMappingThenGetDistinctFilteredFacesWithMapping(argZero, containers);
|
List<Face> distinctFilteredFaces = SetMappingThenGetDistinctFilteredFacesWithMapping(argZero, containers);
|
||||||
List<Face> selectedFilteredFaces = E_Distance.GetSelectedFilteredFaces(_MapConfiguration, distinctFilteredFaces);
|
List<Face> selectedFilteredFaces = E_Distance.GetSelectedFilteredFaces(distinctFilteredFaces);
|
||||||
E_Distance.SetFaceDistances(_AppSettings.MaxDegreeOfParallelism, ticks, selectedFilteredFaces);
|
E_Distance.SetFaceDistances(_AppSettings.MaxDegreeOfParallelism, ticks, selectedFilteredFaces);
|
||||||
MapLogic mapLogic = new(_AppSettings.MaxDegreeOfParallelism, _Configuration.PropertyConfiguration, _MapConfiguration, _Faces.FileNameExtension, _Faces.HiddenFileNameExtension, _FaceParts.FileNameExtension, ticks, personContainers, eResultsFullGroupDirectory, distinctFilteredFaces, distance);
|
MapLogic mapLogic = new(_AppSettings.MaxDegreeOfParallelism, _Configuration.PropertyConfiguration, _MapConfiguration, _Faces.FileNameExtension, _Faces.HiddenFileNameExtension, _FaceParts.FileNameExtension, ticks, personContainers, eResultsFullGroupDirectory, distinctFilteredFaces, distance);
|
||||||
SortingContainer[] sortingContainers = E_Distance.SetFaceMappingSortingCollectionThenGetSortingContainers(_AppSettings.MaxDegreeOfParallelism, _MapConfiguration, ticks, mapLogic, selectedFilteredFaces);
|
SortingContainer[] sortingContainers = E_Distance.SetFaceMappingSortingCollectionThenGetSortingContainers(_AppSettings.MaxDegreeOfParallelism, _MapConfiguration, ticks, mapLogic, selectedFilteredFaces);
|
||||||
|
@ -34,7 +34,6 @@ public class Configuration
|
|||||||
[Display(Name = "Mapped Max Index"), Required] public int? MappedMaxIndex { get; set; }
|
[Display(Name = "Mapped Max Index"), Required] public int? MappedMaxIndex { get; set; }
|
||||||
[Display(Name = "Mapping Default Name"), Required] public string MappingDefaultName { get; set; }
|
[Display(Name = "Mapping Default Name"), Required] public string MappingDefaultName { get; set; }
|
||||||
[Display(Name = "Mapping Move Unable to Match by 1 Tick"), Required] public bool? MappingMoveUnableToMatch { get; set; }
|
[Display(Name = "Mapping Move Unable to Match by 1 Tick"), Required] public bool? MappingMoveUnableToMatch { get; set; }
|
||||||
[Display(Name = "Mapping Save Face Encoding"), Required] public bool? MappingSaveFaceEncoding { get; set; }
|
|
||||||
[Display(Name = "Mapping Save Mapped"), Required] public bool? MappingSaveMapped { get; set; }
|
[Display(Name = "Mapping Save Mapped"), Required] public bool? MappingSaveMapped { get; set; }
|
||||||
[Display(Name = "Mapping Save Not Mapped"), Required] public bool? MappingSaveNotMapped { get; set; }
|
[Display(Name = "Mapping Save Not Mapped"), Required] public bool? MappingSaveNotMapped { get; set; }
|
||||||
[Display(Name = "Mapping Use Deterministic Hash Code Unknown Face Key Value Pairs for Add to Mapping"), Required] public bool? MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { get; set; }
|
[Display(Name = "Mapping Use Deterministic Hash Code Unknown Face Key Value Pairs for Add to Mapping"), Required] public bool? MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { get; set; }
|
||||||
@ -69,8 +68,6 @@ public class Configuration
|
|||||||
[Display(Name = "Save Shortcuts"), Required] public string[] SaveShortcutsForOutputResolutions { get; set; }
|
[Display(Name = "Save Shortcuts"), Required] public string[] SaveShortcutsForOutputResolutions { get; set; }
|
||||||
[Display(Name = "Skip Search"), Required] public bool? SkipSearch { get; set; }
|
[Display(Name = "Skip Search"), Required] public bool? SkipSearch { get; set; }
|
||||||
[Display(Name = "Sorting Days Delta Tolerance"), Required] public int? SortingDaysDeltaTolerance { get; set; }
|
[Display(Name = "Sorting Days Delta Tolerance"), Required] public int? SortingDaysDeltaTolerance { get; set; }
|
||||||
[Display(Name = "Sorting Faces To Skip After Sort Before Load"), Required] public int? SortingFacesToSkipAfterSortBeforeLoad { get; set; }
|
|
||||||
[Display(Name = "Sorting Faces To Take After Sort Before Load"), Required] public int? SortingFacesToTakeAfterSortBeforeLoad { get; set; }
|
|
||||||
[Display(Name = "SortingMaximumPerFaceShould be High"), Required] public int? SortingMaximumPerFaceShouldBeHigh { get; set; }
|
[Display(Name = "SortingMaximumPerFaceShould be High"), Required] public int? SortingMaximumPerFaceShouldBeHigh { get; set; }
|
||||||
[Display(Name = "Sorting Maximum Per Key"), Required] public int? SortingMaximumPerKey { get; set; }
|
[Display(Name = "Sorting Maximum Per Key"), Required] public int? SortingMaximumPerKey { get; set; }
|
||||||
[Display(Name = "Sorting Sigma"), Required] public int? SortingSigma { get; set; }
|
[Display(Name = "Sorting Sigma"), Required] public int? SortingSigma { get; set; }
|
||||||
@ -132,8 +129,6 @@ public class Configuration
|
|||||||
throw new NullReferenceException(nameof(configuration.MappingDefaultName));
|
throw new NullReferenceException(nameof(configuration.MappingDefaultName));
|
||||||
if (configuration.MappingMoveUnableToMatch is null)
|
if (configuration.MappingMoveUnableToMatch is null)
|
||||||
throw new NullReferenceException(nameof(configuration.MappingMoveUnableToMatch));
|
throw new NullReferenceException(nameof(configuration.MappingMoveUnableToMatch));
|
||||||
if (configuration.MappingSaveFaceEncoding is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.MappingSaveFaceEncoding));
|
|
||||||
if (configuration.MappingSaveNotMapped is null)
|
if (configuration.MappingSaveNotMapped is null)
|
||||||
throw new NullReferenceException(nameof(configuration.MappingSaveNotMapped));
|
throw new NullReferenceException(nameof(configuration.MappingSaveNotMapped));
|
||||||
if (configuration.MappingSaveMapped is null)
|
if (configuration.MappingSaveMapped is null)
|
||||||
@ -194,10 +189,6 @@ public class Configuration
|
|||||||
throw new NullReferenceException(nameof(configuration.SkipSearch));
|
throw new NullReferenceException(nameof(configuration.SkipSearch));
|
||||||
if (configuration.SortingDaysDeltaTolerance is null)
|
if (configuration.SortingDaysDeltaTolerance is null)
|
||||||
throw new NullReferenceException(nameof(configuration.SortingDaysDeltaTolerance));
|
throw new NullReferenceException(nameof(configuration.SortingDaysDeltaTolerance));
|
||||||
if (configuration.SortingFacesToSkipAfterSortBeforeLoad is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.SortingFacesToSkipAfterSortBeforeLoad));
|
|
||||||
if (configuration.SortingFacesToTakeAfterSortBeforeLoad is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.SortingFacesToTakeAfterSortBeforeLoad));
|
|
||||||
if (configuration.SortingMaximumPerFaceShouldBeHigh is null)
|
if (configuration.SortingMaximumPerFaceShouldBeHigh is null)
|
||||||
throw new NullReferenceException(nameof(configuration.SortingMaximumPerFaceShouldBeHigh));
|
throw new NullReferenceException(nameof(configuration.SortingMaximumPerFaceShouldBeHigh));
|
||||||
if (configuration.SortingMaximumPerKey is null)
|
if (configuration.SortingMaximumPerKey is null)
|
||||||
@ -241,7 +232,6 @@ public class Configuration
|
|||||||
configuration.MappedMaxIndex,
|
configuration.MappedMaxIndex,
|
||||||
configuration.MappingDefaultName,
|
configuration.MappingDefaultName,
|
||||||
configuration.MappingMoveUnableToMatch.Value,
|
configuration.MappingMoveUnableToMatch.Value,
|
||||||
configuration.MappingSaveFaceEncoding.Value,
|
|
||||||
configuration.MappingSaveNotMapped.Value,
|
configuration.MappingSaveNotMapped.Value,
|
||||||
configuration.MappingSaveMapped.Value,
|
configuration.MappingSaveMapped.Value,
|
||||||
configuration.MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping.Value,
|
configuration.MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping.Value,
|
||||||
@ -275,8 +265,6 @@ public class Configuration
|
|||||||
configuration.SaveShortcutsForOutputResolutions,
|
configuration.SaveShortcutsForOutputResolutions,
|
||||||
configuration.SkipSearch.Value,
|
configuration.SkipSearch.Value,
|
||||||
configuration.SortingDaysDeltaTolerance.Value,
|
configuration.SortingDaysDeltaTolerance.Value,
|
||||||
configuration.SortingFacesToSkipAfterSortBeforeLoad.Value,
|
|
||||||
configuration.SortingFacesToTakeAfterSortBeforeLoad.Value,
|
|
||||||
configuration.SortingMaximumPerFaceShouldBeHigh.Value,
|
configuration.SortingMaximumPerFaceShouldBeHigh.Value,
|
||||||
configuration.SortingMaximumPerKey.Value,
|
configuration.SortingMaximumPerKey.Value,
|
||||||
configuration.SortingSigma.Value,
|
configuration.SortingSigma.Value,
|
||||||
|
@ -33,7 +33,6 @@ public class Configuration
|
|||||||
public int? MappedMaxIndex { init; get; }
|
public int? MappedMaxIndex { init; get; }
|
||||||
public string MappingDefaultName { init; get; }
|
public string MappingDefaultName { init; get; }
|
||||||
public bool MappingMoveUnableToMatch { init; get; }
|
public bool MappingMoveUnableToMatch { init; get; }
|
||||||
public bool MappingSaveFaceEncoding { init; get; }
|
|
||||||
public bool MappingSaveNotMapped { init; get; }
|
public bool MappingSaveNotMapped { init; get; }
|
||||||
public bool MappingSaveMapped { init; get; }
|
public bool MappingSaveMapped { init; get; }
|
||||||
public bool MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { init; get; }
|
public bool MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { init; get; }
|
||||||
@ -67,8 +66,6 @@ public class Configuration
|
|||||||
public string[] SaveShortcutsForOutputResolutions { init; get; }
|
public string[] SaveShortcutsForOutputResolutions { init; get; }
|
||||||
public bool SkipSearch { init; get; }
|
public bool SkipSearch { init; get; }
|
||||||
public int SortingDaysDeltaTolerance { init; get; }
|
public int SortingDaysDeltaTolerance { init; get; }
|
||||||
public int SortingFacesToSkipAfterSortBeforeLoad { init; get; }
|
|
||||||
public int SortingFacesToTakeAfterSortBeforeLoad { init; get; }
|
|
||||||
public int SortingMaximumPerFaceShouldBeHigh { init; get; }
|
public int SortingMaximumPerFaceShouldBeHigh { init; get; }
|
||||||
public int SortingMaximumPerKey { init; get; }
|
public int SortingMaximumPerKey { init; get; }
|
||||||
public int SortingSigma { init; get; }
|
public int SortingSigma { init; get; }
|
||||||
@ -101,7 +98,6 @@ public class Configuration
|
|||||||
int? mappedMaxIndex,
|
int? mappedMaxIndex,
|
||||||
string mappingDefaultName,
|
string mappingDefaultName,
|
||||||
bool mappingMoveUnableToMatch,
|
bool mappingMoveUnableToMatch,
|
||||||
bool mappingSaveFaceEncoding,
|
|
||||||
bool mappingSaveNotMapped,
|
bool mappingSaveNotMapped,
|
||||||
bool mappingSaveMapped,
|
bool mappingSaveMapped,
|
||||||
bool mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping,
|
bool mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping,
|
||||||
@ -135,8 +131,6 @@ public class Configuration
|
|||||||
string[] saveShortcutsForOutputResolutions,
|
string[] saveShortcutsForOutputResolutions,
|
||||||
bool skipSearch,
|
bool skipSearch,
|
||||||
int sortingDaysDeltaTolerance,
|
int sortingDaysDeltaTolerance,
|
||||||
int sortingFacesToSkipAfterSortBeforeLoad,
|
|
||||||
int sortingFacesToTakeAfterSortBeforeLoad,
|
|
||||||
int sortingMaximumPerFaceShouldBeHigh,
|
int sortingMaximumPerFaceShouldBeHigh,
|
||||||
int sortingMaximumPerKey,
|
int sortingMaximumPerKey,
|
||||||
int sortingSigma,
|
int sortingSigma,
|
||||||
@ -168,7 +162,6 @@ public class Configuration
|
|||||||
MappedMaxIndex = mappedMaxIndex;
|
MappedMaxIndex = mappedMaxIndex;
|
||||||
MappingDefaultName = mappingDefaultName;
|
MappingDefaultName = mappingDefaultName;
|
||||||
MappingMoveUnableToMatch = mappingMoveUnableToMatch;
|
MappingMoveUnableToMatch = mappingMoveUnableToMatch;
|
||||||
MappingSaveFaceEncoding = mappingSaveFaceEncoding;
|
|
||||||
MappingSaveNotMapped = mappingSaveNotMapped;
|
MappingSaveNotMapped = mappingSaveNotMapped;
|
||||||
MappingSaveMapped = mappingSaveMapped;
|
MappingSaveMapped = mappingSaveMapped;
|
||||||
MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping = mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping;
|
MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping = mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping;
|
||||||
@ -202,8 +195,6 @@ public class Configuration
|
|||||||
SaveShortcutsForOutputResolutions = saveShortcutsForOutputResolutions;
|
SaveShortcutsForOutputResolutions = saveShortcutsForOutputResolutions;
|
||||||
SkipSearch = skipSearch;
|
SkipSearch = skipSearch;
|
||||||
SortingDaysDeltaTolerance = sortingDaysDeltaTolerance;
|
SortingDaysDeltaTolerance = sortingDaysDeltaTolerance;
|
||||||
SortingFacesToSkipAfterSortBeforeLoad = sortingFacesToSkipAfterSortBeforeLoad;
|
|
||||||
SortingFacesToTakeAfterSortBeforeLoad = sortingFacesToTakeAfterSortBeforeLoad;
|
|
||||||
SortingMaximumPerFaceShouldBeHigh = sortingMaximumPerFaceShouldBeHigh;
|
SortingMaximumPerFaceShouldBeHigh = sortingMaximumPerFaceShouldBeHigh;
|
||||||
SortingMaximumPerKey = sortingMaximumPerKey;
|
SortingMaximumPerKey = sortingMaximumPerKey;
|
||||||
SortingSigma = sortingSigma;
|
SortingSigma = sortingSigma;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using System.Drawing.Drawing2D;
|
using System.Drawing.Drawing2D;
|
||||||
using System.Drawing.Imaging;
|
using System.Drawing.Imaging;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using System.Text.Json.Serialization;
|
using System.Text.Json.Serialization;
|
||||||
using View_by_Distance.FaceRecognitionDotNet;
|
using View_by_Distance.FaceRecognitionDotNet;
|
||||||
@ -33,6 +34,7 @@ public class D_Face
|
|||||||
private readonly ImageCodecInfo _ImageCodecInfo;
|
private readonly ImageCodecInfo _ImageCodecInfo;
|
||||||
private readonly ModelParameter _ModelParameter;
|
private readonly ModelParameter _ModelParameter;
|
||||||
private readonly PredictorModel _PredictorModel;
|
private readonly PredictorModel _PredictorModel;
|
||||||
|
private readonly ConstructorInfo _ConstructorInfo;
|
||||||
private readonly EncoderParameters _EncoderParameters;
|
private readonly EncoderParameters _EncoderParameters;
|
||||||
private readonly ImageCodecInfo _HiddenImageCodecInfo;
|
private readonly ImageCodecInfo _HiddenImageCodecInfo;
|
||||||
private readonly EncoderParameters _HiddenEncoderParameters;
|
private readonly EncoderParameters _HiddenEncoderParameters;
|
||||||
@ -53,6 +55,10 @@ public class D_Face
|
|||||||
_HiddenImageCodecInfo = hiddenImageCodecInfo;
|
_HiddenImageCodecInfo = hiddenImageCodecInfo;
|
||||||
_HiddenEncoderParameters = hiddenEncoderParameters;
|
_HiddenEncoderParameters = hiddenEncoderParameters;
|
||||||
_HiddenFileNameExtension = hiddenFileNameExtension;
|
_HiddenFileNameExtension = hiddenFileNameExtension;
|
||||||
|
ConstructorInfo? constructorInfo = typeof(PropertyItem).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, Array.Empty<Type>(), null);
|
||||||
|
if (constructorInfo is null)
|
||||||
|
throw new Exception();
|
||||||
|
_ConstructorInfo = constructorInfo;
|
||||||
_WriteIndentedAndWhenWritingNull = new JsonSerializerOptions { WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull };
|
_WriteIndentedAndWhenWritingNull = new JsonSerializerOptions { WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull };
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,31 +150,65 @@ public class D_Face
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static byte[] GetBytes(string value)
|
||||||
|
{
|
||||||
|
byte[] results = new byte[value.Length + 1];
|
||||||
|
for (int i = 0; i < value.Length; i++)
|
||||||
|
results[i] = (byte)value[i];
|
||||||
|
results[value.Length] = 0x00;
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
private PropertyItem GetPropertyItem(int id, string value)
|
||||||
|
{
|
||||||
|
PropertyItem result = (PropertyItem)_ConstructorInfo.Invoke(null);
|
||||||
|
byte[] bytes = GetBytes(value);
|
||||||
|
result.Id = id;
|
||||||
|
result.Len = value.Length + 1;
|
||||||
|
result.Type = 2;
|
||||||
|
result.Value = bytes;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private void SaveFaces(FileHolder resizedFileHolder, List<(Face, FileInfo?, string)> collection)
|
private void SaveFaces(FileHolder resizedFileHolder, List<(Face, FileInfo?, string)> collection)
|
||||||
{
|
{
|
||||||
|
int pixel;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
|
string json;
|
||||||
Bitmap bitmap;
|
Bitmap bitmap;
|
||||||
Graphics graphics;
|
Graphics graphics;
|
||||||
Location? location;
|
Location? location;
|
||||||
Rectangle rectangle;
|
Rectangle rectangle;
|
||||||
|
PropertyItem? propertyItem;
|
||||||
|
int software = (int)IExif.Tags.Software;
|
||||||
|
int userComment = (int)IExif.Tags.UserComment;
|
||||||
using Bitmap source = new(resizedFileHolder.FullName);
|
using Bitmap source = new(resizedFileHolder.FullName);
|
||||||
|
int imageDescription = (int)IExif.Tags.ImageDescription;
|
||||||
foreach ((Face face, FileInfo? fileInfo, string fileName) in collection)
|
foreach ((Face face, FileInfo? fileInfo, string fileName) in collection)
|
||||||
{
|
{
|
||||||
if (fileInfo is null)
|
if (fileInfo is null)
|
||||||
continue;
|
continue;
|
||||||
if (face.FaceEncoding is null || face?.Location is null)
|
if (face.FaceEncoding is null || face?.Location?.NormalizedPixelPercentage is null || face?.OutputResolution is null)
|
||||||
continue;
|
continue;
|
||||||
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(face.Location, _Configuration.LocationDigits, _Configuration.LocationFactor, source.Height, source.Width, collection.Count);
|
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(face.Location, _Configuration.LocationDigits, _Configuration.LocationFactor, source.Height, source.Width, collection.Count);
|
||||||
if (location is null)
|
if (location is null)
|
||||||
continue;
|
continue;
|
||||||
width = location.Right - location.Left;
|
width = location.Right - location.Left;
|
||||||
height = location.Bottom - location.Top;
|
height = location.Bottom - location.Top;
|
||||||
|
json = JsonSerializer.Serialize(face.FaceEncoding);
|
||||||
|
pixel = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(face.Location, _Configuration.LocationDigits, _Configuration.LocationFactor, face.OutputResolution);
|
||||||
rectangle = new Rectangle(location.Left, location.Top, width, height);
|
rectangle = new Rectangle(location.Left, location.Top, width, height);
|
||||||
using (bitmap = new(width, height))
|
using (bitmap = new(width, height))
|
||||||
{
|
{
|
||||||
using (graphics = Graphics.FromImage(bitmap))
|
using (graphics = Graphics.FromImage(bitmap))
|
||||||
graphics.DrawImage(source, new Rectangle(0, 0, width, height), rectangle, GraphicsUnit.Pixel);
|
graphics.DrawImage(source, new Rectangle(0, 0, width, height), rectangle, GraphicsUnit.Pixel);
|
||||||
|
propertyItem = GetPropertyItem(userComment, json);
|
||||||
|
bitmap.SetPropertyItem(propertyItem);
|
||||||
|
propertyItem = GetPropertyItem(imageDescription, pixel.ToString());
|
||||||
|
bitmap.SetPropertyItem(propertyItem);
|
||||||
|
propertyItem = GetPropertyItem(software, face.Location.NormalizedPixelPercentage.Value.ToString());
|
||||||
|
bitmap.SetPropertyItem(propertyItem);
|
||||||
bitmap.Save(fileInfo.FullName, _ImageCodecInfo, _EncoderParameters);
|
bitmap.Save(fileInfo.FullName, _ImageCodecInfo, _EncoderParameters);
|
||||||
}
|
}
|
||||||
if (File.Exists(fileName))
|
if (File.Exists(fileName))
|
||||||
@ -304,7 +344,6 @@ public class D_Face
|
|||||||
results = JsonSerializer.Deserialize<List<Face>>(json);
|
results = JsonSerializer.Deserialize<List<Face>>(json);
|
||||||
if (results is null)
|
if (results is null)
|
||||||
throw new NullReferenceException(nameof(results));
|
throw new NullReferenceException(nameof(results));
|
||||||
results = Shared.Models.Stateless.Methods.IFace.GetVerifiedFaces(_Configuration.LocationDigits, _Configuration.LocationFactor, results);
|
|
||||||
if (!_Configuration.ForceFaceLastWriteTimeToCreationTime)
|
if (!_Configuration.ForceFaceLastWriteTimeToCreationTime)
|
||||||
{
|
{
|
||||||
normalizedPixelPercentageCollection = Shared.Models.Stateless.Methods.IFace.GetInts(results);
|
normalizedPixelPercentageCollection = Shared.Models.Stateless.Methods.IFace.GetInts(results);
|
||||||
|
@ -116,11 +116,11 @@ internal class E_Distance : Shared.Models.Methods.IFaceDistance
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<Face> GetSelectedFilteredFaces(Map.Models.Configuration configuration, List<Face> distinctFilteredFaces)
|
internal static List<Face> GetSelectedFilteredFaces(List<Face> distinctFilteredFaces)
|
||||||
{
|
{
|
||||||
List<Face> results;
|
List<Face> results;
|
||||||
Face[] orderedFilteredFaces = (from l in distinctFilteredFaces orderby l.Mapping is not null, l.Mapping?.MappingFromItem.MinimumDateTime descending select l).ToArray();
|
Face[] orderedFilteredFaces = (from l in distinctFilteredFaces orderby l.Mapping is not null, l.Mapping?.MappingFromItem.MinimumDateTime descending select l).ToArray();
|
||||||
results = orderedFilteredFaces.Skip(configuration.SortingFacesToSkipAfterSortBeforeLoad).Take(configuration.SortingFacesToTakeAfterSortBeforeLoad).ToList();
|
results = orderedFilteredFaces.ToList();
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,8 +66,8 @@
|
|||||||
"ForceResizeLastWriteTimeToCreationTime": false,
|
"ForceResizeLastWriteTimeToCreationTime": false,
|
||||||
"LoadOrCreateThenSaveIndex": false,
|
"LoadOrCreateThenSaveIndex": false,
|
||||||
"LocationConfidenceFactor": 2,
|
"LocationConfidenceFactor": 2,
|
||||||
"LocationDigits": 6,
|
"LocationDigits": 9,
|
||||||
"LocationFactor": 1000000,
|
"LocationFactor": 10000,
|
||||||
"MapLogicSigma": 3,
|
"MapLogicSigma": 3,
|
||||||
"MappedMaxIndex": 1034720,
|
"MappedMaxIndex": 1034720,
|
||||||
"MappingDefaultName": "John Doe~25",
|
"MappingDefaultName": "John Doe~25",
|
||||||
@ -113,8 +113,6 @@
|
|||||||
"SaveResizedSubFiles": true,
|
"SaveResizedSubFiles": true,
|
||||||
"SkipSearch": false,
|
"SkipSearch": false,
|
||||||
"SortingDaysDeltaTolerance": 700,
|
"SortingDaysDeltaTolerance": 700,
|
||||||
"SortingFacesToSkipAfterSortBeforeLoad": 0,
|
|
||||||
"SortingFacesToTakeAfterSortBeforeLoad": 55000,
|
|
||||||
"SortingMaximumPerFaceShouldBeHigh": 1000,
|
"SortingMaximumPerFaceShouldBeHigh": 1000,
|
||||||
"SortingMaximumPerKey": 27,
|
"SortingMaximumPerKey": 27,
|
||||||
"SortingSigma": 3,
|
"SortingSigma": 3,
|
||||||
|
@ -66,8 +66,8 @@
|
|||||||
"ForceResizeLastWriteTimeToCreationTime": false,
|
"ForceResizeLastWriteTimeToCreationTime": false,
|
||||||
"LoadOrCreateThenSaveIndex": false,
|
"LoadOrCreateThenSaveIndex": false,
|
||||||
"LocationConfidenceFactor": 2,
|
"LocationConfidenceFactor": 2,
|
||||||
"LocationDigits": 6,
|
"LocationDigits": 9,
|
||||||
"LocationFactor": 1000000,
|
"LocationFactor": 10000,
|
||||||
"MapLogicSigma": 3,
|
"MapLogicSigma": 3,
|
||||||
"MappedMaxIndex": 1034720,
|
"MappedMaxIndex": 1034720,
|
||||||
"MappingDefaultName": "John Doe~25",
|
"MappingDefaultName": "John Doe~25",
|
||||||
@ -112,8 +112,6 @@
|
|||||||
"SaveResizedSubFiles": true,
|
"SaveResizedSubFiles": true,
|
||||||
"SkipSearch": false,
|
"SkipSearch": false,
|
||||||
"SortingDaysDeltaTolerance": 700,
|
"SortingDaysDeltaTolerance": 700,
|
||||||
"SortingFacesToSkipAfterSortBeforeLoad": 0,
|
|
||||||
"SortingFacesToTakeAfterSortBeforeLoad": 55000,
|
|
||||||
"SortingMaximumPerFaceShouldBeHigh": 1000,
|
"SortingMaximumPerFaceShouldBeHigh": 1000,
|
||||||
"SortingMaximumPerKey": 27,
|
"SortingMaximumPerKey": 27,
|
||||||
"SortingSigma": 3,
|
"SortingSigma": 3,
|
||||||
|
@ -66,8 +66,8 @@
|
|||||||
"ForceResizeLastWriteTimeToCreationTime": false,
|
"ForceResizeLastWriteTimeToCreationTime": false,
|
||||||
"LoadOrCreateThenSaveIndex": false,
|
"LoadOrCreateThenSaveIndex": false,
|
||||||
"LocationConfidenceFactor": 2,
|
"LocationConfidenceFactor": 2,
|
||||||
"LocationDigits": 6,
|
"LocationDigits": 9,
|
||||||
"LocationFactor": 1000000,
|
"LocationFactor": 10000,
|
||||||
"MapLogicSigma": 3,
|
"MapLogicSigma": 3,
|
||||||
"MappedMaxIndex": 1034720,
|
"MappedMaxIndex": 1034720,
|
||||||
"MappingDefaultName": "John Doe~25",
|
"MappingDefaultName": "John Doe~25",
|
||||||
@ -112,8 +112,6 @@
|
|||||||
"SaveResizedSubFiles": true,
|
"SaveResizedSubFiles": true,
|
||||||
"SkipSearch": false,
|
"SkipSearch": false,
|
||||||
"SortingDaysDeltaTolerance": 700,
|
"SortingDaysDeltaTolerance": 700,
|
||||||
"SortingFacesToSkipAfterSortBeforeLoad": 0,
|
|
||||||
"SortingFacesToTakeAfterSortBeforeLoad": 55000,
|
|
||||||
"SortingMaximumPerFaceShouldBeHigh": 1000,
|
"SortingMaximumPerFaceShouldBeHigh": 1000,
|
||||||
"SortingMaximumPerKey": 27,
|
"SortingMaximumPerKey": 27,
|
||||||
"SortingSigma": 3,
|
"SortingSigma": 3,
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Humanizer.Core" Version="2.13.14" />
|
<PackageReference Include="Humanizer.Core" Version="2.13.14" />
|
||||||
|
<PackageReference Include="MetadataExtractor" Version="2.7.1" />
|
||||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||||
<PackageReference Include="ShellProgressBar" Version="5.1.0" />
|
<PackageReference Include="ShellProgressBar" Version="5.1.0" />
|
||||||
<PackageReference Include="WindowsShortcutFactory" Version="1.0.1" />
|
<PackageReference Include="WindowsShortcutFactory" Version="1.0.1" />
|
||||||
|
@ -15,7 +15,6 @@ public class Configuration
|
|||||||
public int MapLogicSigma { init; get; }
|
public int MapLogicSigma { init; get; }
|
||||||
public string MappingDefaultName { init; get; }
|
public string MappingDefaultName { init; get; }
|
||||||
public bool MappingMoveUnableToMatch { init; get; }
|
public bool MappingMoveUnableToMatch { init; get; }
|
||||||
public bool MappingSaveFaceEncoding { init; get; }
|
|
||||||
public bool MappingSaveNotMapped { init; get; }
|
public bool MappingSaveNotMapped { init; get; }
|
||||||
public bool MappingSaveMapped { init; get; }
|
public bool MappingSaveMapped { init; get; }
|
||||||
public bool MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { init; get; }
|
public bool MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { init; get; }
|
||||||
@ -24,8 +23,6 @@ public class Configuration
|
|||||||
public string PersonBirthdayFormat { init; get; }
|
public string PersonBirthdayFormat { init; get; }
|
||||||
public string PersonKeyFormat { init; get; }
|
public string PersonKeyFormat { init; get; }
|
||||||
public int SortingDaysDeltaTolerance { init; get; }
|
public int SortingDaysDeltaTolerance { init; get; }
|
||||||
public int SortingFacesToSkipAfterSortBeforeLoad { init; get; }
|
|
||||||
public int SortingFacesToTakeAfterSortBeforeLoad { init; get; }
|
|
||||||
public int SortingMaximumPerFaceShouldBeHigh { init; get; }
|
public int SortingMaximumPerFaceShouldBeHigh { init; get; }
|
||||||
public int SortingMaximumPerKey { init; get; }
|
public int SortingMaximumPerKey { init; get; }
|
||||||
public int SortingSigma { init; get; }
|
public int SortingSigma { init; get; }
|
||||||
@ -40,7 +37,6 @@ public class Configuration
|
|||||||
int mapLogicSigma,
|
int mapLogicSigma,
|
||||||
string mappingDefaultName,
|
string mappingDefaultName,
|
||||||
bool mappingMoveUnableToMatch,
|
bool mappingMoveUnableToMatch,
|
||||||
bool mappingSaveFaceEncoding,
|
|
||||||
bool mappingSaveNotMapped,
|
bool mappingSaveNotMapped,
|
||||||
bool mappingSaveMapped,
|
bool mappingSaveMapped,
|
||||||
bool mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping,
|
bool mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping,
|
||||||
@ -49,8 +45,6 @@ public class Configuration
|
|||||||
string personBirthdayFormat,
|
string personBirthdayFormat,
|
||||||
string personKeyFormat,
|
string personKeyFormat,
|
||||||
int sortingDaysDeltaTolerance,
|
int sortingDaysDeltaTolerance,
|
||||||
int sortingFacesToSkipAfterSortBeforeLoad,
|
|
||||||
int sortingFacesToTakeAfterSortBeforeLoad,
|
|
||||||
int sortingMaximumPerFaceShouldBeHigh,
|
int sortingMaximumPerFaceShouldBeHigh,
|
||||||
int sortingMaximumPerKey,
|
int sortingMaximumPerKey,
|
||||||
int sortingSigma)
|
int sortingSigma)
|
||||||
@ -64,7 +58,6 @@ public class Configuration
|
|||||||
MapLogicSigma = mapLogicSigma;
|
MapLogicSigma = mapLogicSigma;
|
||||||
MappingDefaultName = mappingDefaultName;
|
MappingDefaultName = mappingDefaultName;
|
||||||
MappingMoveUnableToMatch = mappingMoveUnableToMatch;
|
MappingMoveUnableToMatch = mappingMoveUnableToMatch;
|
||||||
MappingSaveFaceEncoding = mappingSaveFaceEncoding;
|
|
||||||
MappingSaveNotMapped = mappingSaveNotMapped;
|
MappingSaveNotMapped = mappingSaveNotMapped;
|
||||||
MappingSaveMapped = mappingSaveMapped;
|
MappingSaveMapped = mappingSaveMapped;
|
||||||
MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping = mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping;
|
MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping = mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping;
|
||||||
@ -73,8 +66,6 @@ public class Configuration
|
|||||||
PersonBirthdayFormat = personBirthdayFormat;
|
PersonBirthdayFormat = personBirthdayFormat;
|
||||||
PersonKeyFormat = personKeyFormat;
|
PersonKeyFormat = personKeyFormat;
|
||||||
SortingDaysDeltaTolerance = sortingDaysDeltaTolerance;
|
SortingDaysDeltaTolerance = sortingDaysDeltaTolerance;
|
||||||
SortingFacesToSkipAfterSortBeforeLoad = sortingFacesToSkipAfterSortBeforeLoad;
|
|
||||||
SortingFacesToTakeAfterSortBeforeLoad = sortingFacesToTakeAfterSortBeforeLoad;
|
|
||||||
SortingMaximumPerFaceShouldBeHigh = sortingMaximumPerFaceShouldBeHigh;
|
SortingMaximumPerFaceShouldBeHigh = sortingMaximumPerFaceShouldBeHigh;
|
||||||
SortingMaximumPerKey = sortingMaximumPerKey;
|
SortingMaximumPerKey = sortingMaximumPerKey;
|
||||||
SortingSigma = sortingSigma;
|
SortingSigma = sortingSigma;
|
||||||
|
@ -584,7 +584,6 @@ public class MapLogic
|
|||||||
throw new NullReferenceException(nameof(_Configuration));
|
throw new NullReferenceException(nameof(_Configuration));
|
||||||
List<SaveContainer> results = new();
|
List<SaveContainer> results = new();
|
||||||
string by;
|
string by;
|
||||||
string json;
|
|
||||||
string checkFile;
|
string checkFile;
|
||||||
string directory;
|
string directory;
|
||||||
string shortcutFile;
|
string shortcutFile;
|
||||||
@ -643,20 +642,12 @@ public class MapLogic
|
|||||||
faceFileHolder = new(Path.Combine(facesDirectory, $"{face.Mapping.MappingFromLocation.DeterministicHashCodeKey}{face.Mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_FacesFileNameExtension}"));
|
faceFileHolder = new(Path.Combine(facesDirectory, $"{face.Mapping.MappingFromLocation.DeterministicHashCodeKey}{face.Mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_FacesFileNameExtension}"));
|
||||||
hiddenFaceFileHolder = new(Path.Combine(facesDirectory, $"{face.Mapping.MappingFromLocation.DeterministicHashCodeKey}{face.Mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_FacesHiddenFileNameExtension}"));
|
hiddenFaceFileHolder = new(Path.Combine(facesDirectory, $"{face.Mapping.MappingFromLocation.DeterministicHashCodeKey}{face.Mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_FacesHiddenFileNameExtension}"));
|
||||||
facePartsFileHolder = new(Path.Combine(facePartsDirectory, $"{face.Mapping.MappingFromLocation.DeterministicHashCodeKey}{face.Mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_FacePartsFileNameExtension}"));
|
facePartsFileHolder = new(Path.Combine(facePartsDirectory, $"{face.Mapping.MappingFromLocation.DeterministicHashCodeKey}{face.Mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_FacePartsFileNameExtension}"));
|
||||||
if (string.IsNullOrEmpty(personDirectory))
|
if (string.IsNullOrEmpty(personDirectory) || face.Mapping.MappingFromPerson.By == Stateless.IMapLogic.Mapping)
|
||||||
shortcutFile = string.Empty;
|
shortcutFile = string.Empty;
|
||||||
else
|
else
|
||||||
shortcutFile = Path.Combine(personDirectory, $"{face.Mapping.MappingFromLocation.DeterministicHashCodeKey}{face.Mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}.lnk");
|
shortcutFile = Path.Combine(personDirectory, $"{face.Mapping.MappingFromLocation.DeterministicHashCodeKey}{face.Mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}.lnk");
|
||||||
saveContainer = new(checkFile, directory, faceFileHolder, hiddenFaceFileHolder, string.Empty, facePartsFileHolder, face.Mapping.MappingFromItem.ResizedFileHolder, shortcutFile);
|
saveContainer = new(checkFile, directory, faceFileHolder, hiddenFaceFileHolder, string.Empty, facePartsFileHolder, face.Mapping.MappingFromItem.ResizedFileHolder, shortcutFile);
|
||||||
results.Add(saveContainer);
|
results.Add(saveContainer);
|
||||||
if (_Configuration.MappingSaveFaceEncoding)
|
|
||||||
{
|
|
||||||
checkFile = Path.Combine(personDirectory, $"{face.Mapping.MappingFromLocation.DeterministicHashCodeKey}{face.Mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}.json");
|
|
||||||
json = JsonSerializer.Serialize(face.FaceEncoding);
|
|
||||||
saveContainer = new(checkFile, personDirectory, json);
|
|
||||||
results.Add(saveContainer);
|
|
||||||
}
|
|
||||||
results.Add(saveContainer);
|
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
using Humanizer;
|
using Humanizer;
|
||||||
using ShellProgressBar;
|
using ShellProgressBar;
|
||||||
using System.Text.Json;
|
|
||||||
using View_by_Distance.Shared.Models;
|
using View_by_Distance.Shared.Models;
|
||||||
using View_by_Distance.Shared.Models.Stateless.Methods;
|
using View_by_Distance.Shared.Models.Stateless.Methods;
|
||||||
|
|
||||||
@ -74,15 +73,12 @@ internal abstract class MapLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<(string, string[], string, List<Face>?)> DeleteEmptyDirectoriesAndGetCollection(Configuration configuration, string facesFileNameExtension, long ticks, string eDistanceContentDirectory, List<string> personKeyFormattedCollection, Dictionary<int, List<Face>> keyValuePairs)
|
internal static List<(string, string[], string)> DeleteEmptyDirectoriesAndGetCollection(Configuration configuration, string facesFileNameExtension, long ticks, string eDistanceContentDirectory, List<string> personKeyFormattedCollection)
|
||||||
{
|
{
|
||||||
List<(string, string[], string, List<Face>?)> results = new();
|
List<(string, string[], string)> results = new();
|
||||||
int? id;
|
int? id;
|
||||||
bool check;
|
|
||||||
string[] files;
|
string[] files;
|
||||||
List<Face>? faces;
|
|
||||||
const int zero = 0;
|
const int zero = 0;
|
||||||
List<int> checks = new();
|
|
||||||
string[] yearDirectories;
|
string[] yearDirectories;
|
||||||
string personKeyFormatted;
|
string personKeyFormatted;
|
||||||
string ticksDirectoryName;
|
string ticksDirectoryName;
|
||||||
@ -94,7 +90,6 @@ internal abstract class MapLogic
|
|||||||
string[] personNameLinkDirectories;
|
string[] personNameLinkDirectories;
|
||||||
string? personFirstInitialDirectory;
|
string? personFirstInitialDirectory;
|
||||||
string[] personDisplayDirectoryNames;
|
string[] personDisplayDirectoryNames;
|
||||||
bool keyValuePairsAny = keyValuePairs.Any();
|
|
||||||
string manualCopyHumanized = nameof(IMapLogic.ManualCopy).Humanize(LetterCasing.Title);
|
string manualCopyHumanized = nameof(IMapLogic.ManualCopy).Humanize(LetterCasing.Title);
|
||||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||||
string forceSingleImageHumanized = nameof(IMapLogic.ForceSingleImage).Humanize(LetterCasing.Title);
|
string forceSingleImageHumanized = nameof(IMapLogic.ForceSingleImage).Humanize(LetterCasing.Title);
|
||||||
@ -156,31 +151,10 @@ internal abstract class MapLogic
|
|||||||
{
|
{
|
||||||
if (file.EndsWith(".lnk") || file.EndsWith(".json"))
|
if (file.EndsWith(".lnk") || file.EndsWith(".json"))
|
||||||
continue;
|
continue;
|
||||||
(id, normalizedPixelPercentage, faces) = IMapping.GetReversedDeterministicHashCodeKey(configuration.LocationDigits, facesFileNameExtension, keyValuePairsAny, keyValuePairs, file);
|
(id, normalizedPixelPercentage, _) = IMapping.GetReversedDeterministicHashCodeKey(configuration.LocationDigits, facesFileNameExtension, file);
|
||||||
if (id is null || normalizedPixelPercentage is null)
|
if (id is null || normalizedPixelPercentage is null)
|
||||||
continue;
|
continue;
|
||||||
if (configuration.MappingMoveUnableToMatch)
|
results.Add(new(personKeyFormatted, personDisplayDirectoryNames, file));
|
||||||
{
|
|
||||||
if (faces is null)
|
|
||||||
check = false;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
check = false;
|
|
||||||
checks.Clear();
|
|
||||||
foreach (Face face in faces)
|
|
||||||
{
|
|
||||||
if (face.Mapping is null)
|
|
||||||
throw new NotSupportedException();
|
|
||||||
checks.Add(face.Mapping.MappingFromLocation.NormalizedPixelPercentage);
|
|
||||||
if (normalizedPixelPercentage.Value != face.Mapping.MappingFromLocation.NormalizedPixelPercentage)
|
|
||||||
continue;
|
|
||||||
check = true;
|
|
||||||
}
|
|
||||||
if (!check)
|
|
||||||
checks.Add(normalizedPixelPercentage.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
results.Add(new(personKeyFormatted, personDisplayDirectoryNames, file, faces));
|
|
||||||
}
|
}
|
||||||
personNameLinkDirectories = Directory.GetDirectories(personFirstInitialDirectory, "*", SearchOption.TopDirectoryOnly);
|
personNameLinkDirectories = Directory.GetDirectories(personFirstInitialDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
foreach (string personNameLinkDirectory in personNameLinkDirectories)
|
foreach (string personNameLinkDirectory in personNameLinkDirectories)
|
||||||
@ -221,13 +195,10 @@ internal abstract class MapLogic
|
|||||||
|
|
||||||
private static void SetKeyValuePairs(Configuration configuration, long ticks, List<PersonContainer> personContainers, List<Face> distinctFilteredFaces, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers, List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedPixelPercentageToPersonContainers, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges)
|
private static void SetKeyValuePairs(Configuration configuration, long ticks, List<PersonContainer> personContainers, List<Face> distinctFilteredFaces, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers, List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedPixelPercentageToPersonContainers, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges)
|
||||||
{
|
{
|
||||||
string check;
|
|
||||||
const int zero = 0;
|
const int zero = 0;
|
||||||
string rightPadded;
|
|
||||||
PersonBirthday? personBirthday;
|
PersonBirthday? personBirthday;
|
||||||
string newestPersonKeyFormatted;
|
string newestPersonKeyFormatted;
|
||||||
PersonContainer[] distinctPersonContainers;
|
PersonContainer[] distinctPersonContainers;
|
||||||
int normalizedPixelPercentageInDecimalForm;
|
|
||||||
Dictionary<string, PersonContainer> personKeyFormattedToPersonContainer = new();
|
Dictionary<string, PersonContainer> personKeyFormattedToPersonContainer = new();
|
||||||
Dictionary<long, List<PersonContainer>> personKeyToPersonContainerCollection = new();
|
Dictionary<long, List<PersonContainer>> personKeyToPersonContainerCollection = new();
|
||||||
Dictionary<int, Dictionary<int, List<PersonContainer>>> idThenNormalizedPixelPercentageToPersonContainerCollection = new();
|
Dictionary<int, Dictionary<int, List<PersonContainer>>> idThenNormalizedPixelPercentageToPersonContainerCollection = new();
|
||||||
@ -272,22 +243,10 @@ internal abstract class MapLogic
|
|||||||
personDisplayDirectoryTo.Add(personDisplayDirectory, new(personDisplayDirectoryNames, personKeyFormattedToPersonContainer[personKeyFormatted]));
|
personDisplayDirectoryTo.Add(personDisplayDirectory, new(personDisplayDirectoryNames, personKeyFormattedToPersonContainer[personKeyFormatted]));
|
||||||
if (!idThenNormalizedPixelPercentageToPersonContainerCollection.ContainsKey(id))
|
if (!idThenNormalizedPixelPercentageToPersonContainerCollection.ContainsKey(id))
|
||||||
idThenNormalizedPixelPercentageToPersonContainerCollection.Add(id, new());
|
idThenNormalizedPixelPercentageToPersonContainerCollection.Add(id, new());
|
||||||
check = normalizedPixelPercentage.ToString();
|
|
||||||
if (check.Length == configuration.LocationDigits)
|
|
||||||
{
|
|
||||||
if (!idThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentage))
|
if (!idThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentage))
|
||||||
idThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentage, new());
|
idThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentage, new());
|
||||||
idThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
idThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
rightPadded = ILocation.GetRightPadded(configuration.LocationDigits, check);
|
|
||||||
normalizedPixelPercentageInDecimalForm = int.Parse(rightPadded);
|
|
||||||
if (!idThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentageInDecimalForm))
|
|
||||||
idThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentageInDecimalForm, new());
|
|
||||||
idThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (KeyValuePair<string, (string[], PersonContainer)> keyValuePair in personDisplayDirectoryTo)
|
foreach (KeyValuePair<string, (string[], PersonContainer)> keyValuePair in personDisplayDirectoryTo)
|
||||||
possiblyNewPersonDisplayDirectoryNamesAndPersonContainer.Add(keyValuePair.Value);
|
possiblyNewPersonDisplayDirectoryNamesAndPersonContainer.Add(keyValuePair.Value);
|
||||||
}
|
}
|
||||||
@ -311,28 +270,15 @@ internal abstract class MapLogic
|
|||||||
continue;
|
continue;
|
||||||
if (!incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection.ContainsKey(id))
|
if (!incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection.ContainsKey(id))
|
||||||
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection.Add(id, new());
|
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection.Add(id, new());
|
||||||
check = normalizedPixelPercentage.ToString();
|
|
||||||
if (!personKeyFormattedToPersonContainer.ContainsKey(personKeyFormatted))
|
if (!personKeyFormattedToPersonContainer.ContainsKey(personKeyFormatted))
|
||||||
{
|
{
|
||||||
personContainer = new(personBirthday, configuration.MappingDefaultName);
|
personContainer = new(personBirthday, configuration.MappingDefaultName);
|
||||||
personKeyFormattedToPersonContainer.Add(personKeyFormatted, personContainer);
|
personKeyFormattedToPersonContainer.Add(personKeyFormatted, personContainer);
|
||||||
}
|
}
|
||||||
if (check.Length == configuration.LocationDigits)
|
|
||||||
{
|
|
||||||
if (!incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentage))
|
if (!incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentage))
|
||||||
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentage, new());
|
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentage, new());
|
||||||
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
rightPadded = ILocation.GetRightPadded(configuration.LocationDigits, check);
|
|
||||||
normalizedPixelPercentageInDecimalForm = int.Parse(rightPadded);
|
|
||||||
if (!incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentageInDecimalForm))
|
|
||||||
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentageInDecimalForm, new());
|
|
||||||
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
foreach (KeyValuePair<int, Dictionary<int, List<PersonContainer>>> keyValuePair in incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection)
|
foreach (KeyValuePair<int, Dictionary<int, List<PersonContainer>>> keyValuePair in incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection)
|
||||||
{
|
{
|
||||||
@ -358,26 +304,6 @@ internal abstract class MapLogic
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool Valid(string checkFile, List<Face> faces)
|
|
||||||
{
|
|
||||||
bool result = false;
|
|
||||||
string json;
|
|
||||||
foreach (Face face in faces)
|
|
||||||
{
|
|
||||||
if (face.FaceEncoding is null)
|
|
||||||
throw new NotSupportedException();
|
|
||||||
if (faces.Count != 1)
|
|
||||||
break;
|
|
||||||
result = true;
|
|
||||||
if (File.Exists(checkFile))
|
|
||||||
continue;
|
|
||||||
json = JsonSerializer.Serialize(face.FaceEncoding);
|
|
||||||
if (IPath.WriteAllText(checkFile, json, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null))
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void MoveUnableToMatch(Configuration configuration, string eDistanceContentDirectory, string file, string jsonFile)
|
private static void MoveUnableToMatch(Configuration configuration, string eDistanceContentDirectory, string file, string jsonFile)
|
||||||
{
|
{
|
||||||
bool result;
|
bool result;
|
||||||
@ -407,7 +333,11 @@ internal abstract class MapLogic
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(checkDirectoryName) || !directoryNames.Any() || !long.TryParse(directoryNames[^1][1..^1], out long directoryTicks))
|
if (string.IsNullOrEmpty(checkDirectoryName) || !directoryNames.Any() || !long.TryParse(directoryNames[^1][1..^1], out long directoryTicks))
|
||||||
|
{
|
||||||
result = false;
|
result = false;
|
||||||
|
File.Delete(jsonFile);
|
||||||
|
File.Delete(file);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bool jsonFileExists = File.Exists(jsonFile);
|
bool jsonFileExists = File.Exists(jsonFile);
|
||||||
@ -430,28 +360,43 @@ internal abstract class MapLogic
|
|||||||
{ }
|
{ }
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int SetCollectionsAndGetUnableToMatchCount(Configuration configuration, string facesFileNameExtension, long ticks, string eDistanceContentDirectory, Shared.Models.Methods.IFaceDistance? distance, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, string[], string, List<Face>?)> collection)
|
private static int SetCollectionsAndGetUnableToMatchCount(Configuration configuration, string facesFileNameExtension, long ticks, string eDistanceContentDirectory, Shared.Models.Methods.IFaceDistance? distance, Dictionary<int, List<Face>> idToFaces, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, string[], string)> collection)
|
||||||
{
|
{
|
||||||
int? id;
|
int? id;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
bool debugCheck;
|
||||||
string? checkFile;
|
string? checkFile;
|
||||||
|
List<Face>? faces;
|
||||||
|
List<int> debugChecks = new();
|
||||||
List<Face> checkFaces = new();
|
List<Face> checkFaces = new();
|
||||||
int? normalizedPixelPercentage;
|
int? normalizedPixelPercentage;
|
||||||
string newestPersonKeyFormatted;
|
string newestPersonKeyFormatted;
|
||||||
|
List<string> duplicates = new();
|
||||||
string personDisplayDirectoryName;
|
string personDisplayDirectoryName;
|
||||||
|
bool idToFacesAny = idToFaces.Any();
|
||||||
|
List<int> normalizedPixelPercentages;
|
||||||
|
Dictionary<int, List<int>> idToNormalizedPixelPercentages = new();
|
||||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||||
string message = $") {collection.Count:000} join from ticks Director(ies) - B - {totalSeconds} total second(s)";
|
string message = $") {collection.Count:000} join from ticks Director(ies) - B - {totalSeconds} total second(s)";
|
||||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||||
using ProgressBar progressBar = new(collection.Count, message, options);
|
using ProgressBar progressBar = new(collection.Count, message, options);
|
||||||
foreach ((string personKeyFormatted, string[] personDisplayDirectoryNames, string file, List<Face>? faces) in collection)
|
foreach ((string personKeyFormatted, string[] personDisplayDirectoryNames, string file) in collection)
|
||||||
{
|
{
|
||||||
progressBar.Tick();
|
progressBar.Tick();
|
||||||
(id, normalizedPixelPercentage, _) = IMapping.GetReversedDeterministicHashCodeKey(configuration.LocationDigits, facesFileNameExtension, file);
|
(id, normalizedPixelPercentage, faces) = IMapping.GetReversedDeterministicHashCodeKey(
|
||||||
|
configuration.LocationDigits,
|
||||||
|
facesFileNameExtension,
|
||||||
|
idToFacesAny,
|
||||||
|
idToFaces,
|
||||||
|
file);
|
||||||
if (id is null || normalizedPixelPercentage is null)
|
if (id is null || normalizedPixelPercentage is null)
|
||||||
{
|
{
|
||||||
result++;
|
result++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!idToNormalizedPixelPercentages.ContainsKey(id.Value))
|
||||||
|
idToNormalizedPixelPercentages.Add(id.Value, new());
|
||||||
|
normalizedPixelPercentages = idToNormalizedPixelPercentages[id.Value];
|
||||||
checkFile = GetCheckFile(configuration, facesFileNameExtension, file, id.Value, normalizedPixelPercentage.Value);
|
checkFile = GetCheckFile(configuration, facesFileNameExtension, file, id.Value, normalizedPixelPercentage.Value);
|
||||||
if (string.IsNullOrEmpty(checkFile))
|
if (string.IsNullOrEmpty(checkFile))
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
@ -460,20 +405,33 @@ internal abstract class MapLogic
|
|||||||
result++;
|
result++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
debugCheck = false;
|
||||||
checkFaces.Clear();
|
checkFaces.Clear();
|
||||||
|
debugChecks.Clear();
|
||||||
foreach (Face face in faces)
|
foreach (Face face in faces)
|
||||||
{
|
{
|
||||||
if (face.Mapping is null)
|
if (face.Mapping is null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
|
debugChecks.Add(face.Mapping.MappingFromLocation.NormalizedPixelPercentage);
|
||||||
if (normalizedPixelPercentage.Value != face.Mapping.MappingFromLocation.NormalizedPixelPercentage)
|
if (normalizedPixelPercentage.Value != face.Mapping.MappingFromLocation.NormalizedPixelPercentage)
|
||||||
continue;
|
continue;
|
||||||
|
if (normalizedPixelPercentages.Contains(face.Mapping.MappingFromLocation.NormalizedPixelPercentage))
|
||||||
|
{
|
||||||
|
duplicates.Add(string.Concat(id.Value, '.', normalizedPixelPercentage.Value, ".jpg", facesFileNameExtension));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
debugCheck = true;
|
||||||
checkFaces.Add(face);
|
checkFaces.Add(face);
|
||||||
|
if (!debugCheck)
|
||||||
|
debugChecks.Add(normalizedPixelPercentage.Value);
|
||||||
}
|
}
|
||||||
if (checkFaces.Count != 1 && distance is not null && File.Exists(checkFile))
|
if (checkFaces.Count != 1 && distance is not null && File.Exists(checkFile))
|
||||||
{
|
{
|
||||||
checkFaces.Clear();
|
checkFaces.Clear();
|
||||||
checkFaces.AddRange(distance.GetMatchingFaces(configuration.FaceDistanceTolerance, checkFile, faces));
|
checkFaces.AddRange(distance.GetMatchingFaces(configuration.FaceDistanceTolerance, checkFile, faces));
|
||||||
}
|
}
|
||||||
|
if (!checkFaces.Any() && faces.Count == 1)
|
||||||
|
checkFaces.AddRange(faces);
|
||||||
if (!checkFaces.Any())
|
if (!checkFaces.Any())
|
||||||
{
|
{
|
||||||
result++;
|
result++;
|
||||||
@ -488,22 +446,22 @@ internal abstract class MapLogic
|
|||||||
MoveUnableToMatch(configuration, eDistanceContentDirectory, file, checkFile);
|
MoveUnableToMatch(configuration, eDistanceContentDirectory, file, checkFile);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!Valid(checkFile, checkFaces))
|
idToNormalizedPixelPercentages[id.Value].Add(normalizedPixelPercentage.Value);
|
||||||
{
|
|
||||||
result++;
|
|
||||||
if (configuration.MappingMoveUnableToMatch)
|
|
||||||
MoveUnableToMatch(configuration, eDistanceContentDirectory, file, checkFile);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!personKeyFormattedToNewestPersonKeyFormatted.ContainsKey(personKeyFormatted))
|
if (!personKeyFormattedToNewestPersonKeyFormatted.ContainsKey(personKeyFormatted))
|
||||||
newestPersonKeyFormatted = personKeyFormatted;
|
newestPersonKeyFormatted = personKeyFormatted;
|
||||||
else
|
else
|
||||||
newestPersonKeyFormatted = personKeyFormattedToNewestPersonKeyFormatted[personKeyFormatted];
|
newestPersonKeyFormatted = personKeyFormattedToNewestPersonKeyFormatted[personKeyFormatted];
|
||||||
personDisplayDirectoryName = personDisplayDirectoryNames[^1];
|
personDisplayDirectoryName = personDisplayDirectoryNames[^1];
|
||||||
if (!string.IsNullOrEmpty(personDisplayDirectoryName) && personDisplayDirectoryName[0] != '!')
|
if (string.IsNullOrEmpty(personDisplayDirectoryName) || personDisplayDirectoryName[0] == '!')
|
||||||
personKeyFormattedIdThenNormalizedPixelPercentageCollection.Add(new(newestPersonKeyFormatted, personDisplayDirectoryNames, id.Value, normalizedPixelPercentage.Value));
|
|
||||||
else
|
|
||||||
incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection.Add(new(newestPersonKeyFormatted, id.Value, normalizedPixelPercentage.Value));
|
incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection.Add(new(newestPersonKeyFormatted, id.Value, normalizedPixelPercentage.Value));
|
||||||
|
else
|
||||||
|
personKeyFormattedIdThenNormalizedPixelPercentageCollection.Add(new(newestPersonKeyFormatted, personDisplayDirectoryNames, id.Value, normalizedPixelPercentage.Value));
|
||||||
|
}
|
||||||
|
if (duplicates.Any())
|
||||||
|
{
|
||||||
|
duplicates.Sort();
|
||||||
|
if (duplicates.Any())
|
||||||
|
{ }
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -686,18 +644,18 @@ internal abstract class MapLogic
|
|||||||
keyValuePairs.Add(face.Mapping.MappingFromItem.Id, new());
|
keyValuePairs.Add(face.Mapping.MappingFromItem.Id, new());
|
||||||
keyValuePairs[face.Mapping.MappingFromItem.Id].Add(face);
|
keyValuePairs[face.Mapping.MappingFromItem.Id].Add(face);
|
||||||
}
|
}
|
||||||
List<(string, string[], string, List<Face>?)> collection = DeleteEmptyDirectoriesAndGetCollection(configuration,
|
List<(string, string[], string)> collection = DeleteEmptyDirectoriesAndGetCollection(configuration,
|
||||||
facesFileNameExtension,
|
facesFileNameExtension,
|
||||||
ticks,
|
ticks,
|
||||||
eDistanceContentDirectory,
|
eDistanceContentDirectory,
|
||||||
personKeyFormattedCollection,
|
personKeyFormattedCollection);
|
||||||
keyValuePairs);
|
|
||||||
int unableToMatchCount = SetCollectionsAndGetUnableToMatchCount(
|
int unableToMatchCount = SetCollectionsAndGetUnableToMatchCount(
|
||||||
configuration,
|
configuration,
|
||||||
facesFileNameExtension,
|
facesFileNameExtension,
|
||||||
ticks,
|
ticks,
|
||||||
eDistanceContentDirectory,
|
eDistanceContentDirectory,
|
||||||
faceDistance,
|
faceDistance,
|
||||||
|
keyValuePairs,
|
||||||
personKeyFormattedToNewestPersonKeyFormatted,
|
personKeyFormattedToNewestPersonKeyFormatted,
|
||||||
personKeyFormattedIdThenNormalizedPixelPercentageCollection,
|
personKeyFormattedIdThenNormalizedPixelPercentageCollection,
|
||||||
incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection,
|
incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection,
|
||||||
|
@ -153,6 +153,7 @@ public class Container
|
|||||||
Shared.Models.Container[] results;
|
Shared.Models.Container[] results;
|
||||||
Item item;
|
Item item;
|
||||||
int length;
|
int length;
|
||||||
|
int itemCount;
|
||||||
int additional;
|
int additional;
|
||||||
string inferred;
|
string inferred;
|
||||||
List<Item> items;
|
List<Item> items;
|
||||||
@ -170,11 +171,6 @@ public class Container
|
|||||||
{
|
{
|
||||||
foreach (FileHolder sourceDirectoryFileHolder in sourceDirectoryFileHolderCollection)
|
foreach (FileHolder sourceDirectoryFileHolder in sourceDirectoryFileHolderCollection)
|
||||||
{
|
{
|
||||||
if (sourceDirectory.Contains("Facebook"))
|
|
||||||
{
|
|
||||||
if (sourceDirectory.Contains("Facebook"))
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
relativePath = Shared.Models.Stateless.Methods.IPath.GetRelativePath(sourceDirectoryFileHolder.FullName, length, forceExtensionToLower: true);
|
relativePath = Shared.Models.Stateless.Methods.IPath.GetRelativePath(sourceDirectoryFileHolder.FullName, length, forceExtensionToLower: true);
|
||||||
fileHolderKeyValuePairs.Add(relativePath, new(sourceDirectory, sourceDirectoryFileHolder));
|
fileHolderKeyValuePairs.Add(relativePath, new(sourceDirectory, sourceDirectoryFileHolder));
|
||||||
}
|
}
|
||||||
@ -262,9 +258,9 @@ public class Container
|
|||||||
{
|
{
|
||||||
additional = 0;
|
additional = 0;
|
||||||
container = keyValuePairs[sourceDirectory];
|
container = keyValuePairs[sourceDirectory];
|
||||||
length = items.Count;
|
itemCount = items.Count;
|
||||||
existing = (from l in container.Items select l.ImageFileHolder?.FullName).ToArray();
|
existing = (from l in container.Items select l.ImageFileHolder?.FullName).ToArray();
|
||||||
for (int i = 0; i < length; i++)
|
for (int i = 0; i < itemCount; i++)
|
||||||
{
|
{
|
||||||
item = items[i];
|
item = items[i];
|
||||||
if (item.ImageFileHolder is null || existing.Contains(item.ImageFileHolder.FullName))
|
if (item.ImageFileHolder is null || existing.Contains(item.ImageFileHolder.FullName))
|
||||||
|
@ -55,8 +55,8 @@ public class Face : Properties.IFace
|
|||||||
_DateTime = (from l in dateTimes where l.HasValue select l.Value).Min();
|
_DateTime = (from l in dateTimes where l.HasValue select l.Value).Min();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Face(Face face, Location location, int locationDigits, int locationFactor, int zCount) :
|
public Face(Face face, int height, Location location, int locationDigits, int locationFactor, int width, int zCount) :
|
||||||
this(face.DateTime, face.FaceDistance, face.FaceEncoding, face.FaceParts, new(location, locationDigits, locationFactor, zCount), face.LocationIndex, face.Mapping, face.OutputResolution, face.RelativePath)
|
this(face.DateTime, face.FaceDistance, face.FaceEncoding, face.FaceParts, new(height, location, locationDigits, locationFactor, width, zCount), face.LocationIndex, face.Mapping, face.OutputResolution, face.RelativePath)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
|
@ -6,42 +6,54 @@ namespace View_by_Distance.Shared.Models;
|
|||||||
public class Location : Properties.ILocation, IEquatable<Location>
|
public class Location : Properties.ILocation, IEquatable<Location>
|
||||||
{
|
{
|
||||||
|
|
||||||
protected int _Bottom;
|
public int Bottom { init; get; }
|
||||||
protected double _Confidence;
|
public double Confidence { init; get; }
|
||||||
protected int _Left;
|
public int Left { init; get; }
|
||||||
protected readonly int? _NormalizedPixelPercentage;
|
public int? NormalizedPixelPercentage { init; get; }
|
||||||
protected int _Right;
|
public int Right { init; get; }
|
||||||
protected int _Top;
|
public int Top { init; get; }
|
||||||
public double Confidence => _Confidence;
|
|
||||||
public int Bottom => _Bottom;
|
|
||||||
public int Left => _Left;
|
|
||||||
public int? NormalizedPixelPercentage => _NormalizedPixelPercentage;
|
|
||||||
public int Right => _Right;
|
|
||||||
public int Top => _Top;
|
|
||||||
|
|
||||||
[JsonConstructor]
|
[JsonConstructor]
|
||||||
public Location(int bottom, double confidence, int left, int? normalizedPixelPercentage, int right, int top)
|
public Location(int bottom, double confidence, int left, int? normalizedPixelPercentage, int right, int top)
|
||||||
{
|
{
|
||||||
_Confidence = confidence;
|
Confidence = confidence;
|
||||||
_Bottom = bottom;
|
Bottom = bottom;
|
||||||
_Left = left;
|
Left = left;
|
||||||
_NormalizedPixelPercentage = normalizedPixelPercentage;
|
NormalizedPixelPercentage = normalizedPixelPercentage;
|
||||||
_Right = right;
|
Right = right;
|
||||||
_Top = top;
|
Top = top;
|
||||||
Stateless.Methods.Location.Check(bottom, left, normalizedPixelPercentage, right, top, zCount: 1);
|
Stateless.Methods.Location.Check(bottom, left, normalizedPixelPercentage, right, top, zCount: 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Location(double confidence, int height, Location location, int locationDigits, int locationFactor, int width, int zCount) :
|
public Location(double confidence, int height, Location location, int locationDigits, int locationFactor, int width, int zCount) :
|
||||||
this(location.Bottom, confidence, location.Left, Stateless.Methods.Location.GetNormalizedPixelPercentage(location.Bottom, height, location.Left, locationDigits, locationFactor, location.Right, location.Top, width, zCount), location.Right, location.Top) =>
|
this(
|
||||||
Stateless.Methods.Location.Check(_Bottom, _Left, _NormalizedPixelPercentage, _Right, _Top, zCount);
|
location.Bottom,
|
||||||
|
confidence,
|
||||||
|
location.Left,
|
||||||
|
Stateless.Methods.Location.GetNormalizedPixelPercentage(location.Bottom, height, location.Left, locationDigits, locationFactor, location.Right, location.Top, width, zCount),
|
||||||
|
location.Right,
|
||||||
|
location.Top) =>
|
||||||
|
Stateless.Methods.Location.Check(Bottom, Left, NormalizedPixelPercentage, Right, Top, zCount);
|
||||||
|
|
||||||
public Location(int bottom, double confidence, int height, int left, int locationDigits, int locationFactor, int right, int top, int width, int zCount) :
|
public Location(int bottom, double confidence, int height, int left, int locationDigits, int locationFactor, int right, int top, int width, int zCount) :
|
||||||
this(bottom, confidence, left, Stateless.Methods.Location.GetNormalizedPixelPercentage(bottom, height, left, locationDigits, locationFactor, right, top, width, zCount), right, top) =>
|
this(
|
||||||
Stateless.Methods.Location.Check(_Bottom, height, _Left, _NormalizedPixelPercentage, _Right, _Top, width, zCount);
|
bottom,
|
||||||
|
confidence,
|
||||||
|
left,
|
||||||
|
Stateless.Methods.Location.GetNormalizedPixelPercentage(bottom, height, left, locationDigits, locationFactor, right, top, width, zCount),
|
||||||
|
right,
|
||||||
|
top) =>
|
||||||
|
Stateless.Methods.Location.Check(Bottom, height, Left, NormalizedPixelPercentage, Right, Top, width, zCount);
|
||||||
|
|
||||||
public Location(Location location, int locationDigits, int locationFactor, int zCount) :
|
public Location(int height, Location location, int locationDigits, int locationFactor, int width, int zCount) :
|
||||||
this(location.Bottom, location.Confidence, location.Left, Stateless.Methods.Location.GetNormalizedPixelPercentage(location.Bottom, height: location.Bottom - location.Top, location.Left, locationDigits, locationFactor, location.Right, location.Top, width: location.Right - location.Left, zCount), location.Right, location.Top) =>
|
this(
|
||||||
Stateless.Methods.Location.Check(_Bottom, _Left, _NormalizedPixelPercentage, _Right, _Top, zCount);
|
location.Bottom,
|
||||||
|
location.Confidence,
|
||||||
|
location.Left,
|
||||||
|
Stateless.Methods.Location.GetNormalizedPixelPercentage(location.Bottom, height, location.Left, locationDigits, locationFactor, location.Right, location.Top, width, zCount),
|
||||||
|
location.Right,
|
||||||
|
location.Top) =>
|
||||||
|
Stateless.Methods.Location.Check(Bottom, Left, NormalizedPixelPercentage, Right, Top, zCount);
|
||||||
|
|
||||||
public Location(double confidence, int factor, int height, Location location, int locationDigits, int locationFactor, int width, int zCount)
|
public Location(double confidence, int factor, int height, Location location, int locationDigits, int locationFactor, int width, int zCount)
|
||||||
{
|
{
|
||||||
@ -52,13 +64,15 @@ public class Location : Properties.ILocation, IEquatable<Location>
|
|||||||
int right = Math.Min(location.Right + x, width);
|
int right = Math.Min(location.Right + x, width);
|
||||||
int top = Math.Max(location.Top - y, 0);
|
int top = Math.Max(location.Top - y, 0);
|
||||||
int normalizedPixelPercentage = Stateless.Methods.Location.GetNormalizedPixelPercentage(location.Bottom, height, location.Left, locationDigits, locationFactor, location.Right, location.Top, width, zCount);
|
int normalizedPixelPercentage = Stateless.Methods.Location.GetNormalizedPixelPercentage(location.Bottom, height, location.Left, locationDigits, locationFactor, location.Right, location.Top, width, zCount);
|
||||||
Stateless.Methods.Location.Check(bottom, left, _NormalizedPixelPercentage, right, top, zCount);
|
if (location.NormalizedPixelPercentage is null || normalizedPixelPercentage != location.NormalizedPixelPercentage.Value)
|
||||||
_Confidence = confidence;
|
throw new Exception();
|
||||||
_Bottom = bottom;
|
Stateless.Methods.Location.Check(bottom, left, NormalizedPixelPercentage, right, top, zCount);
|
||||||
_Left = left;
|
Confidence = confidence;
|
||||||
_NormalizedPixelPercentage = normalizedPixelPercentage;
|
Bottom = bottom;
|
||||||
_Right = right;
|
Left = left;
|
||||||
_Top = top;
|
NormalizedPixelPercentage = normalizedPixelPercentage;
|
||||||
|
Right = right;
|
||||||
|
Top = top;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool Equals(object? obj) => Equals(obj as Location);
|
public override bool Equals(object? obj) => Equals(obj as Location);
|
||||||
@ -72,20 +86,20 @@ public class Location : Properties.ILocation, IEquatable<Location>
|
|||||||
public override int GetHashCode()
|
public override int GetHashCode()
|
||||||
{
|
{
|
||||||
int hashCode = -773114317;
|
int hashCode = -773114317;
|
||||||
hashCode = hashCode * -1521134295 + _Bottom.GetHashCode();
|
hashCode = hashCode * -1521134295 + Bottom.GetHashCode();
|
||||||
hashCode = hashCode * -1521134295 + _Left.GetHashCode();
|
hashCode = hashCode * -1521134295 + Left.GetHashCode();
|
||||||
hashCode = hashCode * -1521134295 + _Right.GetHashCode();
|
hashCode = hashCode * -1521134295 + Right.GetHashCode();
|
||||||
hashCode = hashCode * -1521134295 + _Top.GetHashCode();
|
hashCode = hashCode * -1521134295 + Top.GetHashCode();
|
||||||
return hashCode;
|
return hashCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool Equals(Location? location)
|
public bool Equals(Location? location)
|
||||||
{
|
{
|
||||||
return location is not null
|
return location is not null
|
||||||
&& _Bottom == location.Bottom
|
&& Bottom == location.Bottom
|
||||||
&& _Left == location.Left
|
&& Left == location.Left
|
||||||
&& _Right == location.Right
|
&& Right == location.Right
|
||||||
&& _Top == location.Top;
|
&& Top == location.Top;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator ==(Location location1, Location location2) => EqualityComparer<Location>.Default.Equals(location1, location2);
|
public static bool operator ==(Location location1, Location location2) => EqualityComparer<Location>.Default.Equals(location1, location2);
|
||||||
|
@ -3,11 +3,11 @@ namespace View_by_Distance.Shared.Models.Properties;
|
|||||||
public interface ILocation
|
public interface ILocation
|
||||||
{
|
{
|
||||||
|
|
||||||
public int Bottom { get; }
|
public int Bottom { init; get; }
|
||||||
public double Confidence { get; }
|
public double Confidence { init; get; }
|
||||||
public int Left { get; }
|
public int Left { init; get; }
|
||||||
public int? NormalizedPixelPercentage { get; }
|
public int? NormalizedPixelPercentage { init; get; }
|
||||||
public int Right { get; }
|
public int Right { init; get; }
|
||||||
public int Top { get; }
|
public int Top { init; get; }
|
||||||
|
|
||||||
}
|
}
|
@ -3,7 +3,7 @@
|
|||||||
public interface ILocation
|
public interface ILocation
|
||||||
{
|
{
|
||||||
|
|
||||||
const int Digits = 6;
|
const int Digits = 9;
|
||||||
const int Factor = 1000000;
|
const int Factor = 10000;
|
||||||
|
|
||||||
}
|
}
|
@ -28,21 +28,6 @@ internal abstract class Face
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<Models.Face> GetVerifiedFaces(int locationDigits, int locationFactor, List<Models.Face> faces)
|
|
||||||
{
|
|
||||||
List<Models.Face> results = new();
|
|
||||||
foreach (Models.Face face in faces)
|
|
||||||
{
|
|
||||||
if (face.Location?.NormalizedPixelPercentage is null)
|
|
||||||
results.Add(face);
|
|
||||||
else if (face.Location.NormalizedPixelPercentage.ToString() == ILocation.GetRightPadded(locationDigits, face.Location.NormalizedPixelPercentage.Value))
|
|
||||||
results.Add(face);
|
|
||||||
else
|
|
||||||
results.Add(new(face, face.Location, locationDigits, locationFactor, faces.Count));
|
|
||||||
}
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static JsonElement[] GetJsonElements(string jsonFileFullName)
|
private static JsonElement[] GetJsonElements(string jsonFileFullName)
|
||||||
{
|
{
|
||||||
string json = GetJson(jsonFileFullName);
|
string json = GetJson(jsonFileFullName);
|
||||||
|
@ -18,11 +18,6 @@ public interface IFace
|
|||||||
static Models.Face GetFace(string jsonFileFullName) =>
|
static Models.Face GetFace(string jsonFileFullName) =>
|
||||||
Face.GetFace(jsonFileFullName);
|
Face.GetFace(jsonFileFullName);
|
||||||
|
|
||||||
List<Models.Face> TestStatic_GetVerifiedFaces(int locationDigits, int locationFactor, List<Models.Face> faces) =>
|
|
||||||
GetVerifiedFaces(locationDigits, locationFactor, faces);
|
|
||||||
static List<Models.Face> GetVerifiedFaces(int locationDigits, int locationFactor, List<Models.Face> faces) =>
|
|
||||||
Face.GetVerifiedFaces(locationDigits, locationFactor, faces);
|
|
||||||
|
|
||||||
Models.Face[] TestStatic_GetFaces(string jsonFileFullName) =>
|
Models.Face[] TestStatic_GetFaces(string jsonFileFullName) =>
|
||||||
GetFaces(jsonFileFullName);
|
GetFaces(jsonFileFullName);
|
||||||
static Models.Face[] GetFaces(string jsonFileFullName) =>
|
static Models.Face[] GetFaces(string jsonFileFullName) =>
|
||||||
|
@ -3,15 +3,15 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
|||||||
public interface ILocation
|
public interface ILocation
|
||||||
{ // ...
|
{ // ...
|
||||||
|
|
||||||
string TestStatic_GetRightPadded(int locationDigits, string value) =>
|
string TestStatic_GetLeftPadded(int locationDigits, string value) =>
|
||||||
GetRightPadded(locationDigits, value);
|
GetLeftPadded(locationDigits, value);
|
||||||
static string GetRightPadded(int locationDigits, string value) =>
|
static string GetLeftPadded(int locationDigits, string value) =>
|
||||||
value.Length == locationDigits ? value : value.Length > locationDigits ? value[..locationDigits] : value.PadRight(locationDigits, '0');
|
value.Length == locationDigits ? value : value.Length > locationDigits ? value[..locationDigits] : value.PadLeft(locationDigits, '0');
|
||||||
|
|
||||||
string TestStatic_GetRightPadded(int locationDigits, int value) =>
|
string TestStatic_GetLeftPadded(int locationDigits, int value) =>
|
||||||
GetRightPadded(locationDigits, value);
|
GetLeftPadded(locationDigits, value);
|
||||||
static string GetRightPadded(int locationDigits, int value) =>
|
static string GetLeftPadded(int locationDigits, int value) =>
|
||||||
GetRightPadded(locationDigits, value.ToString());
|
GetLeftPadded(locationDigits, value.ToString());
|
||||||
|
|
||||||
Models.Location? TestStatic_GetLocation(Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
|
Models.Location? TestStatic_GetLocation(Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
|
||||||
GetLocation(location, locationDigits, locationFactor, height, width, zCount);
|
GetLocation(location, locationDigits, locationFactor, height, width, zCount);
|
||||||
@ -19,7 +19,7 @@ public interface ILocation
|
|||||||
location is null ? null : new(location.Confidence, height, location, locationDigits, locationFactor, width, zCount);
|
location is null ? null : new(location.Confidence, height, location, locationDigits, locationFactor, width, zCount);
|
||||||
|
|
||||||
Models.Location? TestStatic_GetLocation(int factor, Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
|
Models.Location? TestStatic_GetLocation(int factor, Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
|
||||||
GetLocation(location, locationDigits, locationFactor, height, width, zCount);
|
GetLocation(factor, location, locationDigits, locationFactor, height, width, zCount);
|
||||||
static Models.Location? GetLocation(int factor, Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
|
static Models.Location? GetLocation(int factor, Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
|
||||||
location is null ? null : new(location.Confidence, factor, height, location, locationDigits, locationFactor, width, zCount);
|
location is null ? null : new(location.Confidence, factor, height, location, locationDigits, locationFactor, width, zCount);
|
||||||
|
|
||||||
@ -28,10 +28,15 @@ public interface ILocation
|
|||||||
static int?[] GetInts(List<Models.Location> locations) =>
|
static int?[] GetInts(List<Models.Location> locations) =>
|
||||||
(from l in locations where l.NormalizedPixelPercentage is not null select l.NormalizedPixelPercentage).ToArray();
|
(from l in locations where l.NormalizedPixelPercentage is not null select l.NormalizedPixelPercentage).ToArray();
|
||||||
|
|
||||||
int TestStatic_GetNormalizedPixelPercentage(int bottom, int height, int left, int locationDigits, int locationFactor, int right, int top, int width, int zCount) =>
|
int TestStatic_GetNormalizedPixelPercentage(Models.Location location, int locationDigits, int locationFactor, OutputResolution outputResolution) =>
|
||||||
GetNormalizedPixelPercentage(bottom, height, left, locationDigits, locationFactor, right, top, width, zCount);
|
GetNormalizedPixelPercentage(location, locationDigits, locationFactor, outputResolution);
|
||||||
static int GetNormalizedPixelPercentage(int bottom, int height, int left, int locationDigits, int locationFactor, int right, int top, int width, int zCount) =>
|
static int GetNormalizedPixelPercentage(Models.Location location, int locationDigits, int locationFactor, OutputResolution outputResolution) =>
|
||||||
Location.GetNormalizedPixelPercentage(bottom, height, left, locationDigits, locationFactor, right, top, width, zCount);
|
Location.GetNormalizedPixelPercentage(location.Bottom, outputResolution.Height, location.Left, locationDigits, locationFactor, location.Right, location.Top, outputResolution.Width, zCount: 1);
|
||||||
|
|
||||||
|
int TestStatic_GetNormalizedPixelPercentage(int bottom, int height, int left, int locationDigits, int locationFactor, int right, int top, int width) =>
|
||||||
|
GetNormalizedPixelPercentage(bottom, height, left, locationDigits, locationFactor, right, top, width);
|
||||||
|
static int GetNormalizedPixelPercentage(int bottom, int height, int left, int locationDigits, int locationFactor, int right, int top, int width) =>
|
||||||
|
Location.GetNormalizedPixelPercentage(bottom, height, left, locationDigits, locationFactor, right, top, width, zCount: 1);
|
||||||
|
|
||||||
Models.Location TestStatic_GetTrimBound(double detectionConfidence, System.Drawing.Rectangle rectangle, int width, int height, int facesCount) =>
|
Models.Location TestStatic_GetTrimBound(double detectionConfidence, System.Drawing.Rectangle rectangle, int width, int height, int facesCount) =>
|
||||||
TrimBound(detectionConfidence, rectangle, width, height, facesCount);
|
TrimBound(detectionConfidence, rectangle, width, height, facesCount);
|
||||||
|
@ -3,8 +3,8 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
|||||||
public interface IMapping
|
public interface IMapping
|
||||||
{ // ...
|
{ // ...
|
||||||
|
|
||||||
static string GetDeterministicHashCodeKey(int id, int normalizedPixelPercentage)
|
static string GetDeterministicHashCodeKey(int id, int pixel)
|
||||||
=> $"{id}.{normalizedPixelPercentage}";
|
=> $"{id}.{pixel}";
|
||||||
|
|
||||||
(string?, string?, string?, bool?) TestStatic_GetSegments(int locationDigits, string facesFileNameExtension, string fileName)
|
(string?, string?, string?, bool?) TestStatic_GetSegments(int locationDigits, string facesFileNameExtension, string fileName)
|
||||||
=> GetSegments(locationDigits, facesFileNameExtension, fileName);
|
=> GetSegments(locationDigits, facesFileNameExtension, fileName);
|
||||||
@ -16,9 +16,9 @@ public interface IMapping
|
|||||||
static (int?, int?, List<Models.Face>?) GetReversedDeterministicHashCodeKey(int locationDigits, string facesFileNameExtension, string file) =>
|
static (int?, int?, List<Models.Face>?) GetReversedDeterministicHashCodeKey(int locationDigits, string facesFileNameExtension, string file) =>
|
||||||
Mapping.GetReversedDeterministicHashCodeKey(locationDigits, facesFileNameExtension, false, new(), file);
|
Mapping.GetReversedDeterministicHashCodeKey(locationDigits, facesFileNameExtension, false, new(), file);
|
||||||
|
|
||||||
(int?, int?, List<Models.Face>?) TestStatic_GetReversedDeterministicHashCodeKey(int locationDigits, string facesFileNameExtension, bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file) =>
|
(int?, int?, List<Models.Face>?) TestStatic_GetReversedDeterministicHashCodeKey(int locationDigits, string facesFileNameExtension, bool idToFacesAny, Dictionary<int, List<Models.Face>> idToFaces, string file) =>
|
||||||
GetReversedDeterministicHashCodeKey(locationDigits, facesFileNameExtension, keyValuePairsAny, keyValuePairs, file);
|
GetReversedDeterministicHashCodeKey(locationDigits, facesFileNameExtension, idToFacesAny, idToFaces, file);
|
||||||
static (int?, int?, List<Models.Face>?) GetReversedDeterministicHashCodeKey(int locationDigits, string facesFileNameExtension, bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file) =>
|
static (int?, int?, List<Models.Face>?) GetReversedDeterministicHashCodeKey(int locationDigits, string facesFileNameExtension, bool idToFacesAny, Dictionary<int, List<Models.Face>> idToFaces, string file) =>
|
||||||
Mapping.GetReversedDeterministicHashCodeKey(locationDigits, facesFileNameExtension, keyValuePairsAny, keyValuePairs, file);
|
Mapping.GetReversedDeterministicHashCodeKey(locationDigits, facesFileNameExtension, idToFacesAny, idToFaces, file);
|
||||||
|
|
||||||
}
|
}
|
@ -3,25 +3,6 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
|||||||
internal abstract class Location
|
internal abstract class Location
|
||||||
{
|
{
|
||||||
|
|
||||||
internal static int GetNormalizedPixelPercentage(int bottom, int height, int left, int locationDigits, int locationFactor, int right, int top, int width, int zCount)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
double value;
|
|
||||||
double total = width * height;
|
|
||||||
Check(bottom, left, right, top, zCount);
|
|
||||||
double xCenter = left + ((right - left) / 2);
|
|
||||||
double yCenter = top + ((bottom - top) / 2);
|
|
||||||
double at = ((yCenter - 1) * width) + xCenter;
|
|
||||||
value = at / total;
|
|
||||||
if (value < 0)
|
|
||||||
value = 3;
|
|
||||||
result = (int)(Math.Round(value, locationDigits) * locationFactor);
|
|
||||||
string rightPadded = ILocation.GetRightPadded(locationDigits, result);
|
|
||||||
if (result.ToString() != rightPadded)
|
|
||||||
result = int.Parse(rightPadded);
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static void Check(int bottom, int left, int right, int top, int zCount)
|
internal static void Check(int bottom, int left, int right, int top, int zCount)
|
||||||
{
|
{
|
||||||
if (left < 0)
|
if (left < 0)
|
||||||
@ -69,4 +50,41 @@ internal abstract class Location
|
|||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static int GetNormalizedPixelPercentage(int bottom, int height, int left, int locationDigits, int locationFactor, int right, int top, int width, int zCount)
|
||||||
|
{
|
||||||
|
int result;
|
||||||
|
int checksum;
|
||||||
|
decimal center = 2m;
|
||||||
|
string xCenterPadded;
|
||||||
|
string yCenterPadded;
|
||||||
|
decimal factor = locationFactor;
|
||||||
|
// int.MaxPercentage = 21 4748 3647;
|
||||||
|
int length = (locationDigits - 1) / 2;
|
||||||
|
Check(bottom, left, right, top, zCount);
|
||||||
|
Check(bottom, height, left, right, top, width, zCount);
|
||||||
|
decimal xCenterValue = left + ((right - left) / center);
|
||||||
|
decimal yCenterValue = top + ((bottom - top) / center);
|
||||||
|
if (xCenterValue > yCenterValue)
|
||||||
|
checksum = 1;
|
||||||
|
else
|
||||||
|
checksum = 2;
|
||||||
|
decimal xCenterPercentageFactored = xCenterValue / width * factor;
|
||||||
|
decimal yCenterPercentageFactored = yCenterValue / height * factor;
|
||||||
|
int xCenterRounded = (int)Math.Round(xCenterPercentageFactored, 0);
|
||||||
|
int yCenterRounded = (int)Math.Round(yCenterPercentageFactored, 0);
|
||||||
|
if (xCenterRounded != factor)
|
||||||
|
xCenterPadded = ILocation.GetLeftPadded(length, xCenterRounded);
|
||||||
|
else
|
||||||
|
xCenterPadded = ILocation.GetLeftPadded(length, xCenterRounded - 1);
|
||||||
|
if (yCenterRounded != factor)
|
||||||
|
yCenterPadded = ILocation.GetLeftPadded(length, yCenterRounded);
|
||||||
|
else
|
||||||
|
yCenterPadded = ILocation.GetLeftPadded(length, yCenterRounded - 1);
|
||||||
|
long check = long.Parse(string.Concat(xCenterPadded, yCenterPadded, checksum));
|
||||||
|
if (check > int.MaxValue)
|
||||||
|
throw new Exception();
|
||||||
|
result = (int)check;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -3,48 +3,6 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
|||||||
internal abstract class Mapping
|
internal abstract class Mapping
|
||||||
{
|
{
|
||||||
|
|
||||||
private static void IfNotAlreadyFileMove(string facesFileNameExtension, string file, int idValue, int normalizedPixelPercentageValue, string extensionLowered)
|
|
||||||
{
|
|
||||||
string? directoryName = Path.GetDirectoryName(file);
|
|
||||||
if (string.IsNullOrEmpty(directoryName))
|
|
||||||
throw new Exception();
|
|
||||||
string checkFile = Path.Combine(directoryName, $"{IMapping.GetDeterministicHashCodeKey(idValue, normalizedPixelPercentageValue)}{extensionLowered}{facesFileNameExtension}");
|
|
||||||
if (!File.Exists(checkFile))
|
|
||||||
File.Move(file, checkFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static (int?, int?, List<Models.Face>?) GetReversedDeterministicHashCodeKeysFromSegments(int locationDigits, string facesFileNameExtension, bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file, string fileName)
|
|
||||||
{
|
|
||||||
int? id;
|
|
||||||
List<Models.Face>? faces;
|
|
||||||
int? normalizedPixelPercentage;
|
|
||||||
(string? Id, string? NormalizedPixelPercentage, string? ExtensionLowered, bool? Check) segments = GetSegments(locationDigits, facesFileNameExtension, fileName);
|
|
||||||
if (string.IsNullOrEmpty(segments.Id) || string.IsNullOrEmpty(segments.NormalizedPixelPercentage) || string.IsNullOrEmpty(segments.ExtensionLowered) || segments.Check is null)
|
|
||||||
{
|
|
||||||
id = null;
|
|
||||||
faces = null;
|
|
||||||
normalizedPixelPercentage = null;
|
|
||||||
}
|
|
||||||
else if (!int.TryParse(segments.Id, out int idValue) || !int.TryParse(ILocation.GetRightPadded(locationDigits, segments.NormalizedPixelPercentage), out int normalizedPixelPercentageValue))
|
|
||||||
{
|
|
||||||
id = null;
|
|
||||||
faces = null;
|
|
||||||
normalizedPixelPercentage = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
id = idValue;
|
|
||||||
normalizedPixelPercentage = normalizedPixelPercentageValue;
|
|
||||||
if (segments.Check.Value || segments.NormalizedPixelPercentage.Length != locationDigits)
|
|
||||||
IfNotAlreadyFileMove(facesFileNameExtension, file, idValue, normalizedPixelPercentageValue, segments.ExtensionLowered);
|
|
||||||
if (!keyValuePairsAny || !keyValuePairs.ContainsKey(idValue))
|
|
||||||
faces = null;
|
|
||||||
else
|
|
||||||
faces = keyValuePairs[idValue];
|
|
||||||
}
|
|
||||||
return new(id, normalizedPixelPercentage, faces);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static (string?, string?, string?, bool?) GetSegments(int locationDigits, string facesFileNameExtension, string fileName)
|
internal static (string?, string?, string?, bool?) GetSegments(int locationDigits, string facesFileNameExtension, string fileName)
|
||||||
{
|
{
|
||||||
string[] segments = fileName.Split('.');
|
string[] segments = fileName.Split('.');
|
||||||
@ -52,7 +10,7 @@ internal abstract class Mapping
|
|||||||
string? extensionLowered;
|
string? extensionLowered;
|
||||||
bool? needsFacesFileNameExtension;
|
bool? needsFacesFileNameExtension;
|
||||||
string? normalizedPixelPercentage;
|
string? normalizedPixelPercentage;
|
||||||
if (segments.Length < 3 || (segments.Length == 4 && $".{segments[3]}" != facesFileNameExtension))
|
if (segments.Length < 4 || $".{segments[3]}" != facesFileNameExtension)
|
||||||
{
|
{
|
||||||
id = null;
|
id = null;
|
||||||
extensionLowered = null;
|
extensionLowered = null;
|
||||||
@ -64,12 +22,42 @@ internal abstract class Mapping
|
|||||||
id = segments[0];
|
id = segments[0];
|
||||||
extensionLowered = $".{segments[2]}";
|
extensionLowered = $".{segments[2]}";
|
||||||
needsFacesFileNameExtension = segments.Length == 3;
|
needsFacesFileNameExtension = segments.Length == 3;
|
||||||
normalizedPixelPercentage = ILocation.GetRightPadded(locationDigits, segments[1]);
|
normalizedPixelPercentage = segments[1].Length == locationDigits ? segments[1] : null;
|
||||||
}
|
}
|
||||||
return new(id, normalizedPixelPercentage, extensionLowered, needsFacesFileNameExtension);
|
return new(id, normalizedPixelPercentage, extensionLowered, needsFacesFileNameExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static (int?, int?, List<Models.Face>?) GetReversedDeterministicHashCodeKey(int locationDigits, string facesFileNameExtension, bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file)
|
private static (int?, int?, List<Models.Face>?) GetReversedDeterministicHashCodeKeysFromSegments(int locationDigits, string facesFileNameExtension, bool idToFacesAny, Dictionary<int, List<Models.Face>> idToFaces, string fileName)
|
||||||
|
{
|
||||||
|
int? id;
|
||||||
|
List<Models.Face>? faces;
|
||||||
|
int? normalizedPixelPercentage;
|
||||||
|
(string? Id, string? NormalizedPixelPercentage, string? ExtensionLowered, bool? Check) segments = GetSegments(locationDigits, facesFileNameExtension, fileName);
|
||||||
|
if (string.IsNullOrEmpty(segments.Id) || string.IsNullOrEmpty(segments.NormalizedPixelPercentage) || string.IsNullOrEmpty(segments.ExtensionLowered) || segments.Check is null)
|
||||||
|
{
|
||||||
|
id = null;
|
||||||
|
faces = null;
|
||||||
|
normalizedPixelPercentage = null;
|
||||||
|
}
|
||||||
|
else if (!int.TryParse(segments.Id, out int idValue) || !int.TryParse(segments.NormalizedPixelPercentage, out int normalizedPixelPercentageValue))
|
||||||
|
{
|
||||||
|
id = null;
|
||||||
|
faces = null;
|
||||||
|
normalizedPixelPercentage = null;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
id = idValue;
|
||||||
|
normalizedPixelPercentage = segments.NormalizedPixelPercentage.Length == locationDigits ? normalizedPixelPercentageValue : null;
|
||||||
|
if (!idToFacesAny || !idToFaces.ContainsKey(idValue))
|
||||||
|
faces = null;
|
||||||
|
else
|
||||||
|
faces = idToFaces[idValue];
|
||||||
|
}
|
||||||
|
return new(id, normalizedPixelPercentage, faces);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static (int?, int?, List<Models.Face>?) GetReversedDeterministicHashCodeKey(int locationDigits, string facesFileNameExtension, bool idToFacesAny, Dictionary<int, List<Models.Face>> idToFaces, string file)
|
||||||
{
|
{
|
||||||
int? id;
|
int? id;
|
||||||
List<Models.Face>? faces;
|
List<Models.Face>? faces;
|
||||||
@ -85,9 +73,8 @@ internal abstract class Mapping
|
|||||||
(id, normalizedPixelPercentage, faces) = GetReversedDeterministicHashCodeKeysFromSegments(
|
(id, normalizedPixelPercentage, faces) = GetReversedDeterministicHashCodeKeysFromSegments(
|
||||||
locationDigits,
|
locationDigits,
|
||||||
facesFileNameExtension,
|
facesFileNameExtension,
|
||||||
keyValuePairsAny,
|
idToFacesAny,
|
||||||
keyValuePairs,
|
idToFaces,
|
||||||
file,
|
|
||||||
fileName);
|
fileName);
|
||||||
return new(id, normalizedPixelPercentage, faces);
|
return new(id, normalizedPixelPercentage, faces);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ using Phares.Shared;
|
|||||||
using Serilog;
|
using Serilog;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
using View_by_Distance.Shared.Models;
|
||||||
using View_by_Distance.Shared.Models.Stateless.Methods;
|
using View_by_Distance.Shared.Models.Stateless.Methods;
|
||||||
using View_by_Distance.Tests.Models;
|
using View_by_Distance.Tests.Models;
|
||||||
|
|
||||||
@ -75,33 +76,12 @@ public class UnitTestCalculations
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodGetAge()
|
public void TestMethodGetAge()
|
||||||
{
|
{
|
||||||
Shared.Models.PersonBirthday personBirthday = new(new(1980, 1, 17));
|
PersonBirthday personBirthday = new(new(1980, 1, 17));
|
||||||
double? age = IPersonBirthday.GetAge(personBirthday);
|
double? age = IPersonBirthday.GetAge(personBirthday);
|
||||||
Assert.IsNotNull(age);
|
Assert.IsNotNull(age);
|
||||||
Assert.IsTrue(age.Value > 42.6092);
|
Assert.IsTrue(age.Value > 42.6092);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestMethodRound()
|
|
||||||
{
|
|
||||||
Assert.IsTrue(Shared.Models.Stateless.ILocation.Digits == 6);
|
|
||||||
Assert.IsTrue(Shared.Models.Stateless.ILocation.Factor == 1000000);
|
|
||||||
double valueA = 0.00001d;
|
|
||||||
int checkA = (int)(Math.Round(valueA, Shared.Models.Stateless.ILocation.Digits) * Shared.Models.Stateless.ILocation.Factor);
|
|
||||||
Assert.IsTrue(checkA == 10);
|
|
||||||
double valueB = 0.01d;
|
|
||||||
int checkB = (int)(Math.Round(valueB, Shared.Models.Stateless.ILocation.Digits) * Shared.Models.Stateless.ILocation.Factor);
|
|
||||||
Assert.IsTrue(checkB == 10000);
|
|
||||||
Assert.IsTrue(checkB > checkA);
|
|
||||||
double valueC = 0.06673685709635417;
|
|
||||||
int checkC = (int)(Math.Round(valueC, Shared.Models.Stateless.ILocation.Digits) * Shared.Models.Stateless.ILocation.Factor);
|
|
||||||
string rightPadded = ILocation.GetRightPadded(Shared.Models.Stateless.ILocation.Digits, checkC);
|
|
||||||
Assert.IsTrue(checkC == 66737);
|
|
||||||
Assert.IsTrue(checkC.ToString() != rightPadded);
|
|
||||||
checkC = int.Parse(rightPadded);
|
|
||||||
Assert.IsTrue(checkC == 667370);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodParse()
|
public void TestMethodParse()
|
||||||
{
|
{
|
||||||
@ -130,6 +110,43 @@ public class UnitTestCalculations
|
|||||||
Assert.IsTrue(successfull == "_ Manual Copy Successfull");
|
Assert.IsTrue(successfull == "_ Manual Copy Successfull");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestMethodDamn()
|
||||||
|
{
|
||||||
|
string name;
|
||||||
|
string[] directories;
|
||||||
|
string? directoryName;
|
||||||
|
string checkDirectory;
|
||||||
|
string sourceDirectory = @"F:\Tmp\Phares\Compare\Images 2022-09-15 - 7390c13 - III - Results\E) Distance\2022-09-15\7680 x 4320\7680x4320 - Hog - Large\()";
|
||||||
|
directories = Directory.GetDirectories(sourceDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
|
foreach (string directory in directories)
|
||||||
|
{
|
||||||
|
directoryName = Path.GetDirectoryName(directory);
|
||||||
|
if (directoryName is null)
|
||||||
|
continue;
|
||||||
|
name = Path.GetFileName(directory);
|
||||||
|
if (name.Length is 1 or 20)
|
||||||
|
continue;
|
||||||
|
checkDirectory = Path.Combine(directoryName, "b", name);
|
||||||
|
Directory.Move(directory, checkDirectory);
|
||||||
|
}
|
||||||
|
directories = Directory.GetDirectories(Path.Combine(sourceDirectory, "b"), "*", SearchOption.TopDirectoryOnly);
|
||||||
|
foreach (string directory in directories)
|
||||||
|
{
|
||||||
|
directoryName = Path.GetDirectoryName(directory);
|
||||||
|
if (directoryName is null)
|
||||||
|
continue;
|
||||||
|
name = Path.GetFileName(directory);
|
||||||
|
if (name.Length is 1 or 20)
|
||||||
|
continue;
|
||||||
|
checkDirectory = Path.Combine(directoryName, $"{name[..^4]})");
|
||||||
|
if (Directory.Exists(checkDirectory))
|
||||||
|
continue;
|
||||||
|
Directory.Move(directory, checkDirectory);
|
||||||
|
}
|
||||||
|
Assert.IsTrue(true);
|
||||||
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodDel()
|
public void TestMethodDel()
|
||||||
{
|
{
|
||||||
@ -170,4 +187,118 @@ public class UnitTestCalculations
|
|||||||
// "()"
|
// "()"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestGetLocation()
|
||||||
|
{
|
||||||
|
double confidence = 0.1D;
|
||||||
|
int left, top, right, bottom, width, height;
|
||||||
|
left = 20;
|
||||||
|
top = 40;
|
||||||
|
right = 60;
|
||||||
|
bottom = 80;
|
||||||
|
width = 100;
|
||||||
|
height = 100;
|
||||||
|
Location location = new(bottom, confidence, left, null, right, top);
|
||||||
|
_ = new Location(confidence, height, location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, 1);
|
||||||
|
_ = new Location(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestGetPixelPercentage()
|
||||||
|
{
|
||||||
|
int normalizedPixelPercentage;
|
||||||
|
int bottom, height, left, right, top, width;
|
||||||
|
left = 1;
|
||||||
|
top = 1;
|
||||||
|
right = 10;
|
||||||
|
bottom = 10;
|
||||||
|
width = 100;
|
||||||
|
height = 100;
|
||||||
|
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
|
||||||
|
Assert.IsTrue(normalizedPixelPercentage == 055005502);
|
||||||
|
left = 50;
|
||||||
|
top = 50;
|
||||||
|
right = 60;
|
||||||
|
bottom = 60;
|
||||||
|
width = 100;
|
||||||
|
height = 100;
|
||||||
|
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
|
||||||
|
Assert.IsTrue(normalizedPixelPercentage == 550055002);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestGetPixelPercentageB()
|
||||||
|
{
|
||||||
|
int normalizedPixelPercentage;
|
||||||
|
int bottom, height, left, right, top, width;
|
||||||
|
left = 240;
|
||||||
|
top = 240;
|
||||||
|
right = 260;
|
||||||
|
bottom = 260;
|
||||||
|
width = 500;
|
||||||
|
height = 500;
|
||||||
|
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
|
||||||
|
Assert.IsTrue(normalizedPixelPercentage == 500050002);
|
||||||
|
left = 490;
|
||||||
|
top = 490;
|
||||||
|
right = 510;
|
||||||
|
bottom = 510;
|
||||||
|
width = 1000;
|
||||||
|
height = 1000;
|
||||||
|
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
|
||||||
|
Assert.IsTrue(normalizedPixelPercentage == 500050002);
|
||||||
|
left++;
|
||||||
|
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
|
||||||
|
Assert.IsTrue(normalizedPixelPercentage == 500550001);
|
||||||
|
left++;
|
||||||
|
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
|
||||||
|
Assert.IsTrue(normalizedPixelPercentage == 501050001);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestGetPixelPercentageC()
|
||||||
|
{
|
||||||
|
int normalizedPixelPercentage;
|
||||||
|
int bottom, height, left, right, top, width;
|
||||||
|
left = 20;
|
||||||
|
top = 40;
|
||||||
|
right = 60;
|
||||||
|
bottom = 80;
|
||||||
|
width = 100;
|
||||||
|
height = 100;
|
||||||
|
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
|
||||||
|
Assert.IsTrue(normalizedPixelPercentage == 400060002);
|
||||||
|
left = 20;
|
||||||
|
top = 40;
|
||||||
|
right = 60;
|
||||||
|
bottom = 80;
|
||||||
|
width = 100;
|
||||||
|
height = 100;
|
||||||
|
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
|
||||||
|
Assert.IsTrue(normalizedPixelPercentage == 400060002);
|
||||||
|
}
|
||||||
|
|
||||||
|
[TestMethod]
|
||||||
|
public void TestGetPixelPercentageD()
|
||||||
|
{
|
||||||
|
int normalizedPixelPercentage;
|
||||||
|
int bottom, height, left, right, top, width;
|
||||||
|
left = 7678;
|
||||||
|
top = 4318;
|
||||||
|
right = 7680;
|
||||||
|
bottom = 4320;
|
||||||
|
width = 7680;
|
||||||
|
height = 4320;
|
||||||
|
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
|
||||||
|
Assert.IsTrue(normalizedPixelPercentage == 999999981);
|
||||||
|
left = 7680;
|
||||||
|
top = 4320;
|
||||||
|
right = 7680;
|
||||||
|
bottom = 4320;
|
||||||
|
width = 7680;
|
||||||
|
height = 4320;
|
||||||
|
normalizedPixelPercentage = ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width);
|
||||||
|
Assert.IsTrue(normalizedPixelPercentage == 999999991);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -73,91 +73,6 @@ public class UnitTestResize
|
|||||||
Assert.IsFalse(_PropertyConfiguration is null);
|
Assert.IsFalse(_PropertyConfiguration is null);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestGetLocation()
|
|
||||||
{
|
|
||||||
double confidence = 0.1D;
|
|
||||||
int left, top, right, bottom, width, height;
|
|
||||||
left = 20;
|
|
||||||
top = 40;
|
|
||||||
right = 60;
|
|
||||||
bottom = 80;
|
|
||||||
width = 100;
|
|
||||||
height = 100;
|
|
||||||
Location location = new(bottom, confidence, left, null, right, top);
|
|
||||||
_ = new Location(confidence, height, location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, 1);
|
|
||||||
_ = new Location(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestGetPixelPercentage()
|
|
||||||
{
|
|
||||||
int normalizedPixelPercentage;
|
|
||||||
int left, top, right, bottom, width, height;
|
|
||||||
left = 1;
|
|
||||||
top = 1;
|
|
||||||
right = 10;
|
|
||||||
bottom = 10;
|
|
||||||
width = 100;
|
|
||||||
height = 100;
|
|
||||||
normalizedPixelPercentage = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
|
||||||
Assert.IsTrue(normalizedPixelPercentage == 40500);
|
|
||||||
left = 50;
|
|
||||||
top = 50;
|
|
||||||
right = 60;
|
|
||||||
bottom = 60;
|
|
||||||
width = 100;
|
|
||||||
height = 100;
|
|
||||||
normalizedPixelPercentage = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
|
||||||
Assert.IsTrue(normalizedPixelPercentage == 545500);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestGetPixelPercentageB()
|
|
||||||
{
|
|
||||||
int normalizedPixelPercentage;
|
|
||||||
int left, top, right, bottom, width, height;
|
|
||||||
left = 240;
|
|
||||||
top = 240;
|
|
||||||
right = 260;
|
|
||||||
bottom = 260;
|
|
||||||
width = 500;
|
|
||||||
height = 500;
|
|
||||||
normalizedPixelPercentage = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
|
||||||
Assert.IsTrue(normalizedPixelPercentage == 499000);
|
|
||||||
left = 490;
|
|
||||||
top = 490;
|
|
||||||
right = 510;
|
|
||||||
bottom = 510;
|
|
||||||
width = 1000;
|
|
||||||
height = 1000;
|
|
||||||
normalizedPixelPercentage = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
|
||||||
Assert.IsTrue(normalizedPixelPercentage == 499500);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestGetPixelPercentageC()
|
|
||||||
{
|
|
||||||
int normalizedPixelPercentage;
|
|
||||||
int left, top, right, bottom, width, height;
|
|
||||||
left = 20;
|
|
||||||
top = 40;
|
|
||||||
right = 60;
|
|
||||||
bottom = 80;
|
|
||||||
width = 100;
|
|
||||||
height = 100;
|
|
||||||
normalizedPixelPercentage = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
|
||||||
Assert.IsTrue(normalizedPixelPercentage == 594000);
|
|
||||||
left = 20;
|
|
||||||
top = 40;
|
|
||||||
right = 60;
|
|
||||||
bottom = 80;
|
|
||||||
width = 100;
|
|
||||||
height = 100;
|
|
||||||
normalizedPixelPercentage = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 10);
|
|
||||||
Assert.IsTrue(normalizedPixelPercentage == 594000);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Property.Models.A_Property GetPropertyLogic(bool reverse, Model? model, PredictorModel? predictorModel)
|
private Property.Models.A_Property GetPropertyLogic(bool reverse, Model? model, PredictorModel? predictorModel)
|
||||||
{
|
{
|
||||||
Property.Models.A_Property result;
|
Property.Models.A_Property result;
|
||||||
|
@ -34,7 +34,6 @@ public class Configuration
|
|||||||
[Display(Name = "Mapped Max Index"), Required] public int? MappedMaxIndex { get; set; }
|
[Display(Name = "Mapped Max Index"), Required] public int? MappedMaxIndex { get; set; }
|
||||||
[Display(Name = "Mapping Default Name"), Required] public string MappingDefaultName { get; set; }
|
[Display(Name = "Mapping Default Name"), Required] public string MappingDefaultName { get; set; }
|
||||||
[Display(Name = "Mapping Move Unable to Match by 1 Tick"), Required] public bool? MappingMoveUnableToMatch { get; set; }
|
[Display(Name = "Mapping Move Unable to Match by 1 Tick"), Required] public bool? MappingMoveUnableToMatch { get; set; }
|
||||||
[Display(Name = "Mapping Save Face Encoding"), Required] public bool? MappingSaveFaceEncoding { get; set; }
|
|
||||||
[Display(Name = "Mapping Save Mapped"), Required] public bool? MappingSaveMapped { get; set; }
|
[Display(Name = "Mapping Save Mapped"), Required] public bool? MappingSaveMapped { get; set; }
|
||||||
[Display(Name = "Mapping Save Not Mapped"), Required] public bool? MappingSaveNotMapped { get; set; }
|
[Display(Name = "Mapping Save Not Mapped"), Required] public bool? MappingSaveNotMapped { get; set; }
|
||||||
[Display(Name = "Mapping Use Deterministic Hash Code Unknown Face Key Value Pairs for Add to Mapping"), Required] public bool? MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { get; set; }
|
[Display(Name = "Mapping Use Deterministic Hash Code Unknown Face Key Value Pairs for Add to Mapping"), Required] public bool? MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { get; set; }
|
||||||
@ -69,8 +68,6 @@ public class Configuration
|
|||||||
[Display(Name = "Save Shortcuts"), Required] public string[] SaveShortcutsForOutputResolutions { get; set; }
|
[Display(Name = "Save Shortcuts"), Required] public string[] SaveShortcutsForOutputResolutions { get; set; }
|
||||||
[Display(Name = "Skip Search"), Required] public bool? SkipSearch { get; set; }
|
[Display(Name = "Skip Search"), Required] public bool? SkipSearch { get; set; }
|
||||||
[Display(Name = "Sorting Days Delta Tolerance"), Required] public int? SortingDaysDeltaTolerance { get; set; }
|
[Display(Name = "Sorting Days Delta Tolerance"), Required] public int? SortingDaysDeltaTolerance { get; set; }
|
||||||
[Display(Name = "Sorting Faces To Skip After Sort Before Load"), Required] public int? SortingFacesToSkipAfterSortBeforeLoad { get; set; }
|
|
||||||
[Display(Name = "Sorting Faces To Take After Sort Before Load"), Required] public int? SortingFacesToTakeAfterSortBeforeLoad { get; set; }
|
|
||||||
[Display(Name = "SortingMaximumPerFaceShould be High"), Required] public int? SortingMaximumPerFaceShouldBeHigh { get; set; }
|
[Display(Name = "SortingMaximumPerFaceShould be High"), Required] public int? SortingMaximumPerFaceShouldBeHigh { get; set; }
|
||||||
[Display(Name = "Sorting Maximum Per Key"), Required] public int? SortingMaximumPerKey { get; set; }
|
[Display(Name = "Sorting Maximum Per Key"), Required] public int? SortingMaximumPerKey { get; set; }
|
||||||
[Display(Name = "Sorting Sigma"), Required] public int? SortingSigma { get; set; }
|
[Display(Name = "Sorting Sigma"), Required] public int? SortingSigma { get; set; }
|
||||||
@ -132,8 +129,6 @@ public class Configuration
|
|||||||
throw new NullReferenceException(nameof(configuration.MappingDefaultName));
|
throw new NullReferenceException(nameof(configuration.MappingDefaultName));
|
||||||
if (configuration.MappingMoveUnableToMatch is null)
|
if (configuration.MappingMoveUnableToMatch is null)
|
||||||
throw new NullReferenceException(nameof(configuration.MappingMoveUnableToMatch));
|
throw new NullReferenceException(nameof(configuration.MappingMoveUnableToMatch));
|
||||||
if (configuration.MappingSaveFaceEncoding is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.MappingSaveFaceEncoding));
|
|
||||||
if (configuration.MappingSaveNotMapped is null)
|
if (configuration.MappingSaveNotMapped is null)
|
||||||
throw new NullReferenceException(nameof(configuration.MappingSaveNotMapped));
|
throw new NullReferenceException(nameof(configuration.MappingSaveNotMapped));
|
||||||
if (configuration.MappingSaveMapped is null)
|
if (configuration.MappingSaveMapped is null)
|
||||||
@ -194,10 +189,6 @@ public class Configuration
|
|||||||
throw new NullReferenceException(nameof(configuration.SkipSearch));
|
throw new NullReferenceException(nameof(configuration.SkipSearch));
|
||||||
if (configuration.SortingDaysDeltaTolerance is null)
|
if (configuration.SortingDaysDeltaTolerance is null)
|
||||||
throw new NullReferenceException(nameof(configuration.SortingDaysDeltaTolerance));
|
throw new NullReferenceException(nameof(configuration.SortingDaysDeltaTolerance));
|
||||||
if (configuration.SortingFacesToSkipAfterSortBeforeLoad is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.SortingFacesToSkipAfterSortBeforeLoad));
|
|
||||||
if (configuration.SortingFacesToTakeAfterSortBeforeLoad is null)
|
|
||||||
throw new NullReferenceException(nameof(configuration.SortingFacesToTakeAfterSortBeforeLoad));
|
|
||||||
if (configuration.SortingMaximumPerFaceShouldBeHigh is null)
|
if (configuration.SortingMaximumPerFaceShouldBeHigh is null)
|
||||||
throw new NullReferenceException(nameof(configuration.SortingMaximumPerFaceShouldBeHigh));
|
throw new NullReferenceException(nameof(configuration.SortingMaximumPerFaceShouldBeHigh));
|
||||||
if (configuration.SortingMaximumPerKey is null)
|
if (configuration.SortingMaximumPerKey is null)
|
||||||
@ -241,7 +232,6 @@ public class Configuration
|
|||||||
configuration.MappedMaxIndex,
|
configuration.MappedMaxIndex,
|
||||||
configuration.MappingDefaultName,
|
configuration.MappingDefaultName,
|
||||||
configuration.MappingMoveUnableToMatch.Value,
|
configuration.MappingMoveUnableToMatch.Value,
|
||||||
configuration.MappingSaveFaceEncoding.Value,
|
|
||||||
configuration.MappingSaveNotMapped.Value,
|
configuration.MappingSaveNotMapped.Value,
|
||||||
configuration.MappingSaveMapped.Value,
|
configuration.MappingSaveMapped.Value,
|
||||||
configuration.MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping.Value,
|
configuration.MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping.Value,
|
||||||
@ -275,8 +265,6 @@ public class Configuration
|
|||||||
configuration.SaveShortcutsForOutputResolutions,
|
configuration.SaveShortcutsForOutputResolutions,
|
||||||
configuration.SkipSearch.Value,
|
configuration.SkipSearch.Value,
|
||||||
configuration.SortingDaysDeltaTolerance.Value,
|
configuration.SortingDaysDeltaTolerance.Value,
|
||||||
configuration.SortingFacesToSkipAfterSortBeforeLoad.Value,
|
|
||||||
configuration.SortingFacesToTakeAfterSortBeforeLoad.Value,
|
|
||||||
configuration.SortingMaximumPerFaceShouldBeHigh.Value,
|
configuration.SortingMaximumPerFaceShouldBeHigh.Value,
|
||||||
configuration.SortingMaximumPerKey.Value,
|
configuration.SortingMaximumPerKey.Value,
|
||||||
configuration.SortingSigma.Value,
|
configuration.SortingSigma.Value,
|
||||||
|
@ -33,7 +33,6 @@ public class Configuration
|
|||||||
public int? MappedMaxIndex { init; get; }
|
public int? MappedMaxIndex { init; get; }
|
||||||
public string MappingDefaultName { init; get; }
|
public string MappingDefaultName { init; get; }
|
||||||
public bool MappingMoveUnableToMatch { init; get; }
|
public bool MappingMoveUnableToMatch { init; get; }
|
||||||
public bool MappingSaveFaceEncoding { init; get; }
|
|
||||||
public bool MappingSaveNotMapped { init; get; }
|
public bool MappingSaveNotMapped { init; get; }
|
||||||
public bool MappingSaveMapped { init; get; }
|
public bool MappingSaveMapped { init; get; }
|
||||||
public bool MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { init; get; }
|
public bool MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { init; get; }
|
||||||
@ -67,8 +66,6 @@ public class Configuration
|
|||||||
public string[] SaveShortcutsForOutputResolutions { init; get; }
|
public string[] SaveShortcutsForOutputResolutions { init; get; }
|
||||||
public bool SkipSearch { init; get; }
|
public bool SkipSearch { init; get; }
|
||||||
public int SortingDaysDeltaTolerance { init; get; }
|
public int SortingDaysDeltaTolerance { init; get; }
|
||||||
public int SortingFacesToSkipAfterSortBeforeLoad { init; get; }
|
|
||||||
public int SortingFacesToTakeAfterSortBeforeLoad { init; get; }
|
|
||||||
public int SortingMaximumPerFaceShouldBeHigh { init; get; }
|
public int SortingMaximumPerFaceShouldBeHigh { init; get; }
|
||||||
public int SortingMaximumPerKey { init; get; }
|
public int SortingMaximumPerKey { init; get; }
|
||||||
public int SortingSigma { init; get; }
|
public int SortingSigma { init; get; }
|
||||||
@ -101,7 +98,6 @@ public class Configuration
|
|||||||
int? mappedMaxIndex,
|
int? mappedMaxIndex,
|
||||||
string mappingDefaultName,
|
string mappingDefaultName,
|
||||||
bool mappingMoveUnableToMatch,
|
bool mappingMoveUnableToMatch,
|
||||||
bool mappingSaveFaceEncoding,
|
|
||||||
bool mappingSaveNotMapped,
|
bool mappingSaveNotMapped,
|
||||||
bool mappingSaveMapped,
|
bool mappingSaveMapped,
|
||||||
bool mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping,
|
bool mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping,
|
||||||
@ -135,8 +131,6 @@ public class Configuration
|
|||||||
string[] saveShortcutsForOutputResolutions,
|
string[] saveShortcutsForOutputResolutions,
|
||||||
bool skipSearch,
|
bool skipSearch,
|
||||||
int sortingDaysDeltaTolerance,
|
int sortingDaysDeltaTolerance,
|
||||||
int sortingFacesToSkipAfterSortBeforeLoad,
|
|
||||||
int sortingFacesToTakeAfterSortBeforeLoad,
|
|
||||||
int sortingMaximumPerFaceShouldBeHigh,
|
int sortingMaximumPerFaceShouldBeHigh,
|
||||||
int sortingMaximumPerKey,
|
int sortingMaximumPerKey,
|
||||||
int sortingSigma,
|
int sortingSigma,
|
||||||
@ -168,7 +162,6 @@ public class Configuration
|
|||||||
MappedMaxIndex = mappedMaxIndex;
|
MappedMaxIndex = mappedMaxIndex;
|
||||||
MappingDefaultName = mappingDefaultName;
|
MappingDefaultName = mappingDefaultName;
|
||||||
MappingMoveUnableToMatch = mappingMoveUnableToMatch;
|
MappingMoveUnableToMatch = mappingMoveUnableToMatch;
|
||||||
MappingSaveFaceEncoding = mappingSaveFaceEncoding;
|
|
||||||
MappingSaveNotMapped = mappingSaveNotMapped;
|
MappingSaveNotMapped = mappingSaveNotMapped;
|
||||||
MappingSaveMapped = mappingSaveMapped;
|
MappingSaveMapped = mappingSaveMapped;
|
||||||
MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping = mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping;
|
MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping = mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping;
|
||||||
@ -202,8 +195,6 @@ public class Configuration
|
|||||||
SaveShortcutsForOutputResolutions = saveShortcutsForOutputResolutions;
|
SaveShortcutsForOutputResolutions = saveShortcutsForOutputResolutions;
|
||||||
SkipSearch = skipSearch;
|
SkipSearch = skipSearch;
|
||||||
SortingDaysDeltaTolerance = sortingDaysDeltaTolerance;
|
SortingDaysDeltaTolerance = sortingDaysDeltaTolerance;
|
||||||
SortingFacesToSkipAfterSortBeforeLoad = sortingFacesToSkipAfterSortBeforeLoad;
|
|
||||||
SortingFacesToTakeAfterSortBeforeLoad = sortingFacesToTakeAfterSortBeforeLoad;
|
|
||||||
SortingMaximumPerFaceShouldBeHigh = sortingMaximumPerFaceShouldBeHigh;
|
SortingMaximumPerFaceShouldBeHigh = sortingMaximumPerFaceShouldBeHigh;
|
||||||
SortingMaximumPerKey = sortingMaximumPerKey;
|
SortingMaximumPerKey = sortingMaximumPerKey;
|
||||||
SortingSigma = sortingSigma;
|
SortingSigma = sortingSigma;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user