Move const usage out of Shared
This commit is contained in:
parent
ad28ab2d38
commit
409c020426
30
.vscode/launch.json
vendored
30
.vscode/launch.json
vendored
@ -26,6 +26,34 @@
|
|||||||
"console": "externalTerminal",
|
"console": "externalTerminal",
|
||||||
"stopAtEntry": false,
|
"stopAtEntry": false,
|
||||||
"requireExactSource": false
|
"requireExactSource": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": ".NET Core Attach",
|
||||||
|
"type": "coreclr",
|
||||||
|
"request": "attach"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
// "AmazonUsername": "phares36@gmail.com",
|
||||||
|
// "AmazonPassword": "JlPhgtv@63",
|
||||||
|
// Keep creating the .json file the same way
|
||||||
|
// However load all .json files at the beginning
|
||||||
|
// When looping through all files and file not in collection path&name or date is different from collection value
|
||||||
|
// Get id in normal fashion
|
||||||
|
// If id is in collection update collection to new path/name
|
||||||
|
// If not save and add to collection
|
||||||
|
// Nicéphore Niépce in 1826 or 182
|
||||||
|
// Stateless.ILocation.Digits
|
||||||
|
// locationDigits
|
||||||
|
// Stateless.ILocation.Factor
|
||||||
|
// locationFactor
|
||||||
|
// Stateless.IFaceDistance.Tolerance
|
||||||
|
// faceDistanceTolerance
|
||||||
|
// Stateless.IFaceDistance.Permyriad
|
||||||
|
// faceDistancePermyriad
|
||||||
|
// Stateless.IPersonBirthday.FirstYear
|
||||||
|
// personBirthdayFirstYear
|
||||||
|
// Stateless.IPersonBirthday.Format
|
||||||
|
// personBirthdayFormat
|
||||||
|
// Stateless.IPerson.KeyFormat
|
||||||
|
// personKeyFormat
|
@ -82,6 +82,8 @@ public class FaceRecognition : DisposableObject
|
|||||||
detectionConfidence,
|
detectionConfidence,
|
||||||
height,
|
height,
|
||||||
Math.Max(rectangle.Left, 0),
|
Math.Max(rectangle.Left, 0),
|
||||||
|
ILocation.Digits,
|
||||||
|
ILocation.Factor,
|
||||||
Math.Min(rectangle.Right, width),
|
Math.Min(rectangle.Right, width),
|
||||||
Math.Max(rectangle.Top, 0),
|
Math.Max(rectangle.Top, 0),
|
||||||
width,
|
width,
|
||||||
|
@ -69,7 +69,7 @@ internal class A2_People
|
|||||||
if (rootResultsDirectory is null)
|
if (rootResultsDirectory is null)
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
Storage storage = new(rootDirectory, rootResultsDirectory, peopleRootDirectory);
|
Storage storage = new(rootDirectory, rootResultsDirectory, peopleRootDirectory);
|
||||||
results = Shared.Models.Stateless.Methods.IPerson.GetPeople(storage);
|
results = Shared.Models.Stateless.Methods.IPerson.GetPeople(storage, Shared.Models.Stateless.IPersonBirthday.FirstYear, Shared.Models.Stateless.IPersonBirthday.Format, Shared.Models.Stateless.IPerson.KeyFormat);
|
||||||
return results.ToArray();
|
return results.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -159,7 +159,7 @@ public class D_Face
|
|||||||
continue;
|
continue;
|
||||||
if (face.FaceEncoding is null || face?.Location is null)
|
if (face.FaceEncoding is null || face?.Location is null)
|
||||||
continue;
|
continue;
|
||||||
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(face.Location, source.Height, source.Width, collection.Count);
|
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(face.Location, ILocation.Digits, ILocation.Factor, 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;
|
||||||
@ -173,7 +173,7 @@ public class D_Face
|
|||||||
}
|
}
|
||||||
if (File.Exists(fileName))
|
if (File.Exists(fileName))
|
||||||
File.Delete(fileName);
|
File.Delete(fileName);
|
||||||
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(IFaceDistance.HiddenImageFactor, face.Location, source.Height, source.Width, collection.Count);
|
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(IFaceDistance.HiddenImageFactor, face.Location, ILocation.Digits, ILocation.Factor, 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;
|
||||||
@ -330,7 +330,7 @@ public class D_Face
|
|||||||
}
|
}
|
||||||
if (_Configuration.ForceFaceLastWriteTimeToCreationTime)
|
if (_Configuration.ForceFaceLastWriteTimeToCreationTime)
|
||||||
{
|
{
|
||||||
results = (from l in results select new Face(results.Count, l)).ToList();
|
results = (from l in results select new Face(ILocation.Digits, ILocation.Factor, results.Count, l)).ToList();
|
||||||
normalizedPixelPercentageCollection = Shared.Models.Stateless.Methods.IFace.GetInts(results);
|
normalizedPixelPercentageCollection = Shared.Models.Stateless.Methods.IFace.GetInts(results);
|
||||||
normalizedPixelPercentageDistinctCount = normalizedPixelPercentageCollection.Distinct().Count();
|
normalizedPixelPercentageDistinctCount = normalizedPixelPercentageCollection.Distinct().Count();
|
||||||
if (normalizedPixelPercentageDistinctCount != normalizedPixelPercentageCollection.Length)
|
if (normalizedPixelPercentageDistinctCount != normalizedPixelPercentageCollection.Length)
|
||||||
|
@ -35,9 +35,9 @@ internal class E_Distance
|
|||||||
Sorting[] collection = Shared.Models.Stateless.Methods.ISorting.Sort(sortingCollection);
|
Sorting[] collection = Shared.Models.Stateless.Methods.ISorting.Sort(sortingCollection);
|
||||||
foreach (Sorting sorting in collection)
|
foreach (Sorting sorting in collection)
|
||||||
{
|
{
|
||||||
if (faceDistanceEncoding.NormalizedPixelPercentage is null)
|
if (face.Mapping is null || faceDistanceEncoding.NormalizedPixelPercentage is null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
if (sorting.DistancePermyriad > IFaceDistance.Permyriad || sorting.DaysDelta > ISorting.DaysDeltaTolerance)
|
if (face.Mapping.MappingFromLocation.Confidence < IFaceDistance.MinimumConfidence || sorting.DistancePermyriad > IFaceDistance.Permyriad || sorting.DaysDelta > ISorting.DaysDeltaTolerance)
|
||||||
continue;
|
continue;
|
||||||
sortingContainer = new(face, sorting);
|
sortingContainer = new(face, sorting);
|
||||||
results.Add(sortingContainer);
|
results.Add(sortingContainer);
|
||||||
@ -135,8 +135,7 @@ internal class E_Distance
|
|||||||
SetFaceDistances(maxDegreeOfParallelism, ticks, outputResolution, selectedFilteredFaces);
|
SetFaceDistances(maxDegreeOfParallelism, ticks, outputResolution, selectedFilteredFaces);
|
||||||
FaceDistanceContainer[] faceDistanceContainers = GetFaceDistanceContainers(selectedFilteredFaces);
|
FaceDistanceContainer[] faceDistanceContainers = GetFaceDistanceContainers(selectedFilteredFaces);
|
||||||
results = GetSortingContainersThenSetFaceMappingSortingCollection(maxDegreeOfParallelism, ticks, mapLogic, outputResolution, faceDistanceContainers);
|
results = GetSortingContainersThenSetFaceMappingSortingCollection(maxDegreeOfParallelism, ticks, mapLogic, outputResolution, faceDistanceContainers);
|
||||||
if (results.Length < IFaceDistance.Permyriad)
|
SaveFaceDistances(eDistanceContentFileName, results);
|
||||||
SaveFaceDistances(eDistanceContentFileName, results);
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ public class G2_Identify : Shared.Models.Properties.IIdentify, IIdentify
|
|||||||
json = File.ReadAllText(named.FullName);
|
json = File.ReadAllText(named.FullName);
|
||||||
Person[] people = a2People.GetPeople(configuration);
|
Person[] people = a2People.GetPeople(configuration);
|
||||||
Dictionary<string, string[]> resultKeyValuePairs = new();
|
Dictionary<string, string[]> resultKeyValuePairs = new();
|
||||||
string[] peopleBirthDates = (from l in people select Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(l.Birthday)).ToArray();
|
string[] peopleBirthDates = (from l in people select Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, l.Birthday)).ToArray();
|
||||||
Dictionary<string, string[]> sourceKeyValuePairs = JsonSerializer.Deserialize<Dictionary<string, string[]>>(json);
|
Dictionary<string, string[]> sourceKeyValuePairs = JsonSerializer.Deserialize<Dictionary<string, string[]>>(json);
|
||||||
foreach (KeyValuePair<string, string[]> keyValuePair in sourceKeyValuePairs)
|
foreach (KeyValuePair<string, string[]> keyValuePair in sourceKeyValuePairs)
|
||||||
{
|
{
|
||||||
|
@ -206,7 +206,7 @@ public class MapLogic
|
|||||||
if (!keyValuePairs.ContainsKey(faceDistanceLength.NormalizedPixelPercentage.Value))
|
if (!keyValuePairs.ContainsKey(faceDistanceLength.NormalizedPixelPercentage.Value))
|
||||||
continue;
|
continue;
|
||||||
personKeysRangesCollection = GetPersonKeysRangesCollection(keyValuePairs[faceDistanceLength.NormalizedPixelPercentage.Value]);
|
personKeysRangesCollection = GetPersonKeysRangesCollection(keyValuePairs[faceDistanceLength.NormalizedPixelPercentage.Value]);
|
||||||
sorting = ISorting.Get(faceDistanceEncoding, faceDistanceLength, anyLowerThanTolerance, personKeysRangesCollection);
|
sorting = ISorting.Get(Shared.Models.Stateless.IFaceDistance.Permyriad, Shared.Models.Stateless.IFaceDistance.Tolerance, faceDistanceEncoding, faceDistanceLength, anyLowerThanTolerance, personKeysRangesCollection);
|
||||||
if (sorting.DistancePermyriad == 0)
|
if (sorting.DistancePermyriad == 0)
|
||||||
continue;
|
continue;
|
||||||
if (sorting.Id == faceDistanceEncoding.Id)
|
if (sorting.Id == faceDistanceEncoding.Id)
|
||||||
@ -254,7 +254,7 @@ public class MapLogic
|
|||||||
if (personKey is null)
|
if (personKey is null)
|
||||||
continue;
|
continue;
|
||||||
personBirthday = IPersonBirthday.GetPersonBirthday(personKey.Value);
|
personBirthday = IPersonBirthday.GetPersonBirthday(personKey.Value);
|
||||||
personKeyFormatted = IPersonBirthday.GetFormatted(personBirthday);
|
personKeyFormatted = IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, personBirthday);
|
||||||
if (juliePhares.Contains(personKeyFormatted) && !string.IsNullOrEmpty(copyDirectory))
|
if (juliePhares.Contains(personKeyFormatted) && !string.IsNullOrEmpty(copyDirectory))
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(copyDirectory))
|
if (!Directory.Exists(copyDirectory))
|
||||||
@ -346,7 +346,7 @@ public class MapLogic
|
|||||||
personBirthdays = new();
|
personBirthdays = new();
|
||||||
foreach (string personKey in keyValuePair.Value)
|
foreach (string personKey in keyValuePair.Value)
|
||||||
{
|
{
|
||||||
personBirthday = IPersonBirthday.GetPersonBirthday(personKey);
|
personBirthday = IPersonBirthday.GetPersonBirthday(Shared.Models.Stateless.IPersonBirthday.Format, personKey);
|
||||||
if (personBirthday is null)
|
if (personBirthday is null)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -398,7 +398,7 @@ public class MapLogic
|
|||||||
approximateYears = person.ApproximateYears;
|
approximateYears = person.ApproximateYears;
|
||||||
personBirthday = person.PersonBirthdays[zero];
|
personBirthday = person.PersonBirthdays[zero];
|
||||||
displayDirectoryName = person.DisplayDirectoryName;
|
displayDirectoryName = person.DisplayDirectoryName;
|
||||||
personKeyFormatted = IPersonBirthday.GetFormatted(personBirthday);
|
personKeyFormatted = IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, personBirthday);
|
||||||
mappingSegmentB = GetMappingSegmentB(_Ticks, personBirthday, approximateYears, face.Mapping.MappingFromItem);
|
mappingSegmentB = GetMappingSegmentB(_Ticks, personBirthday, approximateYears, face.Mapping.MappingFromItem);
|
||||||
face.Mapping.UpdateMappingFromPerson(approximateYears, by, displayDirectoryName, personBirthday, mappingSegmentB);
|
face.Mapping.UpdateMappingFromPerson(approximateYears, by, displayDirectoryName, personBirthday, mappingSegmentB);
|
||||||
}
|
}
|
||||||
@ -415,7 +415,7 @@ public class MapLogic
|
|||||||
approximateYears = person.ApproximateYears;
|
approximateYears = person.ApproximateYears;
|
||||||
personBirthday = person.PersonBirthdays[zero];
|
personBirthday = person.PersonBirthdays[zero];
|
||||||
displayDirectoryName = person.DisplayDirectoryName;
|
displayDirectoryName = person.DisplayDirectoryName;
|
||||||
personKeyFormatted = IPersonBirthday.GetFormatted(personBirthday);
|
personKeyFormatted = IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, personBirthday);
|
||||||
mappingSegmentB = GetMappingSegmentB(_Ticks, personBirthday, approximateYears, face.Mapping.MappingFromItem);
|
mappingSegmentB = GetMappingSegmentB(_Ticks, personBirthday, approximateYears, face.Mapping.MappingFromItem);
|
||||||
face.Mapping.UpdateMappingFromPerson(approximateYears, by, displayDirectoryName, personBirthday, mappingSegmentB);
|
face.Mapping.UpdateMappingFromPerson(approximateYears, by, displayDirectoryName, personBirthday, mappingSegmentB);
|
||||||
}
|
}
|
||||||
@ -490,7 +490,7 @@ public class MapLogic
|
|||||||
foreach (long personKey in _NotMappedPersonKeys)
|
foreach (long personKey in _NotMappedPersonKeys)
|
||||||
{
|
{
|
||||||
personBirthday = IPersonBirthday.GetPersonBirthday(personKey);
|
personBirthday = IPersonBirthday.GetPersonBirthday(personKey);
|
||||||
personKeyFormatted = IPersonBirthday.GetFormatted(personBirthday);
|
personKeyFormatted = IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, personBirthday);
|
||||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"{facePopulatedKey}NotMapped", personKeyFormatted, Property.Models.Stateless.IResult.AllInOne);
|
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"{facePopulatedKey}NotMapped", personKeyFormatted, Property.Models.Stateless.IResult.AllInOne);
|
||||||
saveContainer = new(directory);
|
saveContainer = new(directory);
|
||||||
saveContainers.Add(saveContainer);
|
saveContainers.Add(saveContainer);
|
||||||
@ -583,7 +583,7 @@ public class MapLogic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
face = faceCollection[zero];
|
face = faceCollection[zero];
|
||||||
personKeyFormatted = IPersonBirthday.GetFormatted(personBirthday);
|
personKeyFormatted = IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, personBirthday);
|
||||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, "Shortcuts", personKeyFormatted, subDirectoryName);
|
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, "Shortcuts", personKeyFormatted, subDirectoryName);
|
||||||
if (face.FaceEncoding is not null && face.Location?.NormalizedPixelPercentage is not null)
|
if (face.FaceEncoding is not null && face.Location?.NormalizedPixelPercentage is not null)
|
||||||
copyDirectory = Path.Combine(_ZPropertyHolderContentTicksDirectory, "Images", personKeyFormatted, subDirectoryName);
|
copyDirectory = Path.Combine(_ZPropertyHolderContentTicksDirectory, "Images", personKeyFormatted, subDirectoryName);
|
||||||
@ -691,7 +691,7 @@ public class MapLogic
|
|||||||
if (!keyValuePairs.ContainsKey(sortingContainer.Sorting.NormalizedPixelPercentage))
|
if (!keyValuePairs.ContainsKey(sortingContainer.Sorting.NormalizedPixelPercentage))
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
personBirthdays = keyValuePairs[sortingContainer.Sorting.NormalizedPixelPercentage];
|
personBirthdays = keyValuePairs[sortingContainer.Sorting.NormalizedPixelPercentage];
|
||||||
if (sortingContainer.Sorting.DistancePermyriad > Shared.Models.Stateless.IFaceDistance.Permyriad || sortingContainer.Sorting.DaysDelta > Shared.Models.Stateless.ISorting.DaysDeltaTolerance)
|
if (sortingContainer.Face.Mapping.MappingFromLocation.Confidence < Shared.Models.Stateless.IFaceDistance.MinimumConfidence || sortingContainer.Sorting.DistancePermyriad > Shared.Models.Stateless.IFaceDistance.Permyriad || sortingContainer.Sorting.DaysDelta > Shared.Models.Stateless.ISorting.DaysDeltaTolerance)
|
||||||
continue;
|
continue;
|
||||||
for (int i = 0; i < personBirthdays.Length; i++)
|
for (int i = 0; i < personBirthdays.Length; i++)
|
||||||
{
|
{
|
||||||
@ -700,7 +700,7 @@ public class MapLogic
|
|||||||
continue;
|
continue;
|
||||||
person = _PeopleKeyValuePairs[personKey];
|
person = _PeopleKeyValuePairs[personKey];
|
||||||
personBirthday = person.PersonBirthdays[zero];
|
personBirthday = person.PersonBirthdays[zero];
|
||||||
personKeyFormatted = IPersonBirthday.GetFormatted(personBirthday);
|
personKeyFormatted = IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, personBirthday);
|
||||||
mappingSegmentB = GetMappingSegmentB(_Ticks, personBirthday, person.ApproximateYears, sortingContainer.Face.Mapping.MappingFromItem);
|
mappingSegmentB = GetMappingSegmentB(_Ticks, personBirthday, person.ApproximateYears, sortingContainer.Face.Mapping.MappingFromItem);
|
||||||
key = string.Concat(personKeyFormatted, '\t', mappingSegmentB);
|
key = string.Concat(personKeyFormatted, '\t', mappingSegmentB);
|
||||||
if (!checkKeyValuePairs.ContainsKey(key))
|
if (!checkKeyValuePairs.ContainsKey(key))
|
||||||
@ -770,7 +770,7 @@ public class MapLogic
|
|||||||
continue;
|
continue;
|
||||||
if (string.IsNullOrEmpty(face.Mapping.MappingFromPerson.SegmentB))
|
if (string.IsNullOrEmpty(face.Mapping.MappingFromPerson.SegmentB))
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
personKeyFormatted = IPersonBirthday.GetFormatted(face.Mapping.MappingFromPerson.PersonBirthday);
|
personKeyFormatted = IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, face.Mapping.MappingFromPerson.PersonBirthday);
|
||||||
if (face.Mapping.MappingFromPerson.By is null)
|
if (face.Mapping.MappingFromPerson.By is null)
|
||||||
by = $"{nameof(Mapping)}Null";
|
by = $"{nameof(Mapping)}Null";
|
||||||
else
|
else
|
||||||
|
@ -32,7 +32,7 @@ public class ByDeterministicHashCode
|
|||||||
Dictionary<string, Person> personKeyValuePairs = new();
|
Dictionary<string, Person> personKeyValuePairs = new();
|
||||||
foreach (Person person in people)
|
foreach (Person person in people)
|
||||||
{
|
{
|
||||||
personKeyFormatted = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(person.Birthday);
|
personKeyFormatted = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, person.Birthday);
|
||||||
if (personKeyValuePairs.ContainsKey(personKeyFormatted))
|
if (personKeyValuePairs.ContainsKey(personKeyFormatted))
|
||||||
break;
|
break;
|
||||||
personKeyValuePairs.Add(personKeyFormatted, person);
|
personKeyValuePairs.Add(personKeyFormatted, person);
|
||||||
@ -71,11 +71,11 @@ public class ByDeterministicHashCode
|
|||||||
{
|
{
|
||||||
personKeyFormatted = Path.GetFileName(personKeyDirectory);
|
personKeyFormatted = Path.GetFileName(personKeyDirectory);
|
||||||
if (!DateTime.TryParseExact(personKeyFormatted, "MM.dd.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime birthday))
|
if (!DateTime.TryParseExact(personKeyFormatted, "MM.dd.yyyy", CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime birthday))
|
||||||
personBirthday = Shared.Models.Stateless.Methods.IPersonBirthday.GetPersonBirthday(personKeyFormatted);
|
personBirthday = Shared.Models.Stateless.Methods.IPersonBirthday.GetPersonBirthday(Shared.Models.Stateless.IPersonBirthday.Format, personKeyFormatted);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
personBirthday = new PersonBirthday(birthday);
|
personBirthday = new PersonBirthday(birthday);
|
||||||
personKeyFormatted = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(personBirthday);
|
personKeyFormatted = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, personBirthday);
|
||||||
convertedPersonKeyDirectory = Path.Combine(personDisplayDirectory, personKeyFormatted);
|
convertedPersonKeyDirectory = Path.Combine(personDisplayDirectory, personKeyFormatted);
|
||||||
if (!Directory.Exists(convertedPersonKeyDirectory))
|
if (!Directory.Exists(convertedPersonKeyDirectory))
|
||||||
Directory.Move(personKeyDirectory, convertedPersonKeyDirectory);
|
Directory.Move(personKeyDirectory, convertedPersonKeyDirectory);
|
||||||
@ -89,7 +89,7 @@ public class ByDeterministicHashCode
|
|||||||
foreach (string personKeyDirectory in personKeyDirectories)
|
foreach (string personKeyDirectory in personKeyDirectories)
|
||||||
{
|
{
|
||||||
personKeyFormatted = Path.GetFileName(personKeyDirectory);
|
personKeyFormatted = Path.GetFileName(personKeyDirectory);
|
||||||
personBirthday = Shared.Models.Stateless.Methods.IPersonBirthday.GetPersonBirthday(personKeyFormatted);
|
personBirthday = Shared.Models.Stateless.Methods.IPersonBirthday.GetPersonBirthday(Shared.Models.Stateless.IPersonBirthday.Format, personKeyFormatted);
|
||||||
if (personBirthday is null)
|
if (personBirthday is null)
|
||||||
continue;
|
continue;
|
||||||
if (personKeyValuePairs.ContainsKey(personKeyFormatted))
|
if (personKeyValuePairs.ContainsKey(personKeyFormatted))
|
||||||
@ -130,7 +130,7 @@ public class ByDeterministicHashCode
|
|||||||
personKey = incrementDate.Ticks;
|
personKey = incrementDate.Ticks;
|
||||||
personBirthday = new(incrementDate);
|
personBirthday = new(incrementDate);
|
||||||
incrementDate = incrementDate.AddDays(1);
|
incrementDate = incrementDate.AddDays(1);
|
||||||
personKeyFormatted = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(personBirthday);
|
personKeyFormatted = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, personBirthday);
|
||||||
if (personKeys.Contains(personKey))
|
if (personKeys.Contains(personKey))
|
||||||
continue;
|
continue;
|
||||||
personKeys.Add(personKey);
|
personKeys.Add(personKey);
|
||||||
@ -174,7 +174,7 @@ public class ByDeterministicHashCode
|
|||||||
personBirthday = null;
|
personBirthday = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
personBirthday = Shared.Models.Stateless.Methods.IPersonBirthday.GetPersonBirthday(personKeyFormatted);
|
personBirthday = Shared.Models.Stateless.Methods.IPersonBirthday.GetPersonBirthday(Shared.Models.Stateless.IPersonBirthday.Format, personKeyFormatted);
|
||||||
if (personBirthday is null)
|
if (personBirthday is null)
|
||||||
continue;
|
continue;
|
||||||
personKey = personBirthday.Value.Ticks;
|
personKey = personBirthday.Value.Ticks;
|
||||||
@ -208,7 +208,7 @@ public class ByDeterministicHashCode
|
|||||||
{
|
{
|
||||||
if (file.EndsWith(".lnk") || file.EndsWith(".json"))
|
if (file.EndsWith(".lnk") || file.EndsWith(".json"))
|
||||||
continue;
|
continue;
|
||||||
(id, normalizedPixelPercentage) = Shared.Models.Stateless.Methods.IMapping.GetReversedDeterministicHashCodeKey(keyValuePairsAny, keyValuePairs, file);
|
(id, normalizedPixelPercentage) = Shared.Models.Stateless.Methods.IMapping.GetReversedDeterministicHashCodeKey(Shared.Models.Stateless.ILocation.Digits, keyValuePairsAny, keyValuePairs, file);
|
||||||
if (id is null || normalizedPixelPercentage is null)
|
if (id is null || normalizedPixelPercentage is null)
|
||||||
continue;
|
continue;
|
||||||
idThenNormalizedPixelPercentageCollection.Add(new(personBirthday, id.Value, normalizedPixelPercentage.Value));
|
idThenNormalizedPixelPercentageCollection.Add(new(personBirthday, id.Value, normalizedPixelPercentage.Value));
|
||||||
|
@ -5,10 +5,10 @@ namespace View_by_Distance.Property.Models.Stateless;
|
|||||||
public interface IResult
|
public interface IResult
|
||||||
{
|
{
|
||||||
|
|
||||||
public const string Content = "()";
|
const string Content = "()";
|
||||||
public const string Singleton = "{}";
|
const string Singleton = "{}";
|
||||||
public const string Collection = "[]";
|
const string Collection = "[]";
|
||||||
public const string AllInOne = "_ _ _";
|
const string AllInOne = "_ _ _";
|
||||||
|
|
||||||
string TestStatic_GetRelativePath(Configuration configuration, string path);
|
string TestStatic_GetRelativePath(Configuration configuration, string path);
|
||||||
static string GetRelativePath(Configuration configuration, string path)
|
static string GetRelativePath(Configuration configuration, string path)
|
||||||
|
1
Shared/.vscode/settings.json
vendored
1
Shared/.vscode/settings.json
vendored
@ -1,5 +1,6 @@
|
|||||||
{
|
{
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
|
"Permyriad",
|
||||||
"Phares"
|
"Phares"
|
||||||
]
|
]
|
||||||
}
|
}
|
@ -39,11 +39,11 @@ public class Face : Properties.IFace
|
|||||||
_RelativePath = relativePath;
|
_RelativePath = relativePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Face(int facesCount, Face face) :
|
public Face(int locationDigits, int locationFactor, int facesCount, Face face) :
|
||||||
this(face.DateTime, null, face.FaceEncoding, face.FaceParts, face.Location, face.LocationIndex, null, face.OutputResolution, face.RelativePath)
|
this(face.DateTime, null, face.FaceEncoding, face.FaceParts, face.Location, face.LocationIndex, null, face.OutputResolution, face.RelativePath)
|
||||||
{
|
{
|
||||||
if (face.Location?.Confidence is not null && face.OutputResolution is not null)
|
if (face.Location?.Confidence is not null && face.OutputResolution is not null)
|
||||||
_Location = new(face.Location.Confidence, face.OutputResolution.Height, face.Location, face.OutputResolution.Width, facesCount);
|
_Location = new(face.Location.Confidence, face.OutputResolution.Height, face.Location, locationDigits, locationFactor, face.OutputResolution.Width, facesCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Face(Property property, int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation, string relativePath, int? i, Location? location) :
|
public Face(Property property, int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation, string relativePath, int? i, Location? location) :
|
||||||
|
@ -31,15 +31,15 @@ public class Location : Properties.ILocation, IEquatable<Location>
|
|||||||
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 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, location.Right, location.Top, width, zCount), location.Right, location.Top) =>
|
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) =>
|
||||||
Stateless.Methods.Location.Check(_Bottom, _Left, _NormalizedPixelPercentage, _Right, _Top, zCount);
|
Stateless.Methods.Location.Check(_Bottom, _Left, _NormalizedPixelPercentage, _Right, _Top, zCount);
|
||||||
|
|
||||||
public Location(int bottom, double confidence, int height, int left, 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, right, top, width, zCount), right, top) =>
|
this(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);
|
Stateless.Methods.Location.Check(_Bottom, height, _Left, _NormalizedPixelPercentage, _Right, _Top, width, zCount);
|
||||||
|
|
||||||
public Location(double confidence, int factor, int height, Location location, int width, int zCount)
|
public Location(double confidence, int factor, int height, Location location, int locationDigits, int locationFactor, int width, int zCount)
|
||||||
{
|
{
|
||||||
int x = (location.Right - location.Left) / factor;
|
int x = (location.Right - location.Left) / factor;
|
||||||
int y = (location.Bottom - location.Top) / factor;
|
int y = (location.Bottom - location.Top) / factor;
|
||||||
@ -47,7 +47,7 @@ public class Location : Properties.ILocation, IEquatable<Location>
|
|||||||
int left = Math.Max(location.Left - x, 0);
|
int left = Math.Max(location.Left - x, 0);
|
||||||
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, 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);
|
Stateless.Methods.Location.Check(bottom, left, _NormalizedPixelPercentage, right, top, zCount);
|
||||||
_Confidence = confidence;
|
_Confidence = confidence;
|
||||||
_Bottom = bottom;
|
_Bottom = bottom;
|
||||||
|
@ -10,5 +10,5 @@ public interface IFaceDistance
|
|||||||
public double? Length { init; get; }
|
public double? Length { init; get; }
|
||||||
public DateTime? MinimumDateTime { init; get; }
|
public DateTime? MinimumDateTime { init; get; }
|
||||||
public int? NormalizedPixelPercentage { init; get; }
|
public int? NormalizedPixelPercentage { init; get; }
|
||||||
|
|
||||||
}
|
}
|
@ -2,11 +2,13 @@
|
|||||||
|
|
||||||
public interface IFaceDistance
|
public interface IFaceDistance
|
||||||
{
|
{
|
||||||
// 637972153144596958
|
|
||||||
// const int MaximumPer = 999;
|
|
||||||
|
|
||||||
const int HiddenImageFactor = 2;
|
const int HiddenImageFactor = 2;
|
||||||
const int Permyriad = 10000;
|
const int Permyriad = 10000;
|
||||||
const double Tolerance = 0.2d;
|
const double MinimumConfidence = 0.95d;
|
||||||
|
const double Tolerance = 0.21d;
|
||||||
|
|
||||||
|
// (637987888254767613) Tolerance = 0.31d; MinimumConfidence = 0.80d; => 1003 in 20 minutes with 9 failures
|
||||||
|
// (637987913910140924) Tolerance = 0.21d; MinimumConfidence = 0.95d;
|
||||||
|
|
||||||
}
|
}
|
@ -3,7 +3,6 @@
|
|||||||
public interface ILocation
|
public interface ILocation
|
||||||
{
|
{
|
||||||
|
|
||||||
const double MinimumConfidence = 0.8d;
|
|
||||||
const int Digits = 6;
|
const int Digits = 6;
|
||||||
const int Factor = 1000000;
|
const int Factor = 1000000;
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ public interface ISorting
|
|||||||
{
|
{
|
||||||
|
|
||||||
const int FacesToSkipAfterSortBeforeLoad = 0;
|
const int FacesToSkipAfterSortBeforeLoad = 0;
|
||||||
const int FacesToTakeAfterSortBeforeLoad = 21000;
|
const int FacesToTakeAfterSortBeforeLoad = 123000;
|
||||||
const int MaximumPerFaceShouldBeHigh = 1000;
|
const int MaximumPerFaceShouldBeHigh = 1000;
|
||||||
const int DaysDeltaTolerance = 700;
|
const int DaysDeltaTolerance = 700;
|
||||||
const int MaximumPerKey = 27;
|
const int MaximumPerKey = 27;
|
||||||
|
@ -3,24 +3,24 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
|||||||
public interface ILocation
|
public interface ILocation
|
||||||
{ // ...
|
{ // ...
|
||||||
|
|
||||||
Models.Location? TestStatic_GetLocation(Models.Location? location, 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, height, width, zCount);
|
GetLocation(location, locationDigits, locationFactor, height, width, zCount);
|
||||||
static Models.Location? GetLocation(Models.Location? location, int height, int width, int zCount) =>
|
static Models.Location? GetLocation(Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
|
||||||
location is null ? null : new(location.Confidence, height, location, 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 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, height, width, zCount);
|
GetLocation(location, locationDigits, locationFactor, height, width, zCount);
|
||||||
static Models.Location? GetLocation(int factor, Models.Location? location, 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, width, zCount);
|
location is null ? null : new(location.Confidence, factor, height, location, locationDigits, locationFactor, width, zCount);
|
||||||
|
|
||||||
int?[] TestStatic_GetInts(List<Models.Location> locations) =>
|
int?[] TestStatic_GetInts(List<Models.Location> locations) =>
|
||||||
GetInts(locations);
|
GetInts(locations);
|
||||||
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 right, int top, int width, int zCount) =>
|
int TestStatic_GetNormalizedPixelPercentage(int bottom, int height, int left, int locationDigits, int locationFactor, int right, int top, int width, int zCount) =>
|
||||||
GetNormalizedPixelPercentage(bottom, height, left, right, top, width, zCount);
|
GetNormalizedPixelPercentage(bottom, height, left, locationDigits, locationFactor, right, top, width, zCount);
|
||||||
static int GetNormalizedPixelPercentage(int bottom, int height, int left, int right, int top, int width, int zCount) =>
|
static int GetNormalizedPixelPercentage(int bottom, int height, int left, int locationDigits, int locationFactor, int right, int top, int width, int zCount) =>
|
||||||
Location.GetNormalizedPixelPercentage(bottom, height, left, right, top, width, zCount);
|
Location.GetNormalizedPixelPercentage(bottom, height, left, locationDigits, locationFactor, right, top, width, zCount);
|
||||||
|
|
||||||
}
|
}
|
@ -6,12 +6,12 @@ public interface IMapping
|
|||||||
static string GetDeterministicHashCodeKeyDisplay(int id, int normalizedPixelPercentage)
|
static string GetDeterministicHashCodeKeyDisplay(int id, int normalizedPixelPercentage)
|
||||||
=> $"{id}.{normalizedPixelPercentage}";
|
=> $"{id}.{normalizedPixelPercentage}";
|
||||||
|
|
||||||
static double GetDeterministicHashCodeKeyValue(int id, int normalizedPixelPercentage)
|
static double GetDeterministicHashCodeKeyValue(int locationDigits, int id, int normalizedPixelPercentage)
|
||||||
=> Math.Round(double.Parse($"{id}.{normalizedPixelPercentage}"), Stateless.ILocation.Digits);
|
=> Math.Round(double.Parse($"{id}.{normalizedPixelPercentage}"), locationDigits);
|
||||||
|
|
||||||
(int?, int?) TestStatic_GetReversedDeterministicHashCodeKey(bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file) =>
|
(int?, int?) TestStatic_GetReversedDeterministicHashCodeKey(int locationDigits, bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file) =>
|
||||||
GetReversedDeterministicHashCodeKey(keyValuePairsAny, keyValuePairs, file);
|
GetReversedDeterministicHashCodeKey(locationDigits, keyValuePairsAny, keyValuePairs, file);
|
||||||
static (int?, int?) GetReversedDeterministicHashCodeKey(bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file) =>
|
static (int?, int?) GetReversedDeterministicHashCodeKey(int locationDigits, bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file) =>
|
||||||
Mapping.GetReversedDeterministicHashCodeKey(keyValuePairsAny, keyValuePairs, file);
|
Mapping.GetReversedDeterministicHashCodeKey(locationDigits, keyValuePairsAny, keyValuePairs, file);
|
||||||
|
|
||||||
}
|
}
|
@ -5,19 +5,29 @@ public interface IPerson
|
|||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
Dictionary<DateTime, string[]> TestStatic_Split(string knownPeopleFile);
|
Dictionary<DateTime, string[]> TestStatic_Split(int personBirthdayFirstYear, string personKeyFormat, string knownPeopleFile) =>
|
||||||
static Dictionary<DateTime, string[]> Split(string knownPeopleFile) => Person.Split(knownPeopleFile);
|
Split(personBirthdayFirstYear, personKeyFormat, knownPeopleFile);
|
||||||
|
static Dictionary<DateTime, string[]> Split(int personBirthdayFirstYear, string personKeyFormat, string knownPeopleFile) =>
|
||||||
|
Person.Split(personBirthdayFirstYear, personKeyFormat, knownPeopleFile);
|
||||||
|
|
||||||
Models.Person[] TestStatic_GetPeople(Properties.IStorage storage);
|
Models.Person[] TestStatic_GetPeople(Properties.IStorage storage, int personBirthdayFirstYear, string personBirthdayFormat, string personKeyFormat) =>
|
||||||
static Models.Person[] GetPeople(Properties.IStorage storage) => Person.GetPeople(storage);
|
GetPeople(storage, personBirthdayFirstYear, personBirthdayFormat, personKeyFormat);
|
||||||
|
static Models.Person[] GetPeople(Properties.IStorage storage, int personBirthdayFirstYear, string personBirthdayFormat, string personKeyFormat) =>
|
||||||
|
Person.GetPeople(storage, personBirthdayFirstYear, personBirthdayFormat, personKeyFormat);
|
||||||
|
|
||||||
void TestStatic_SavePerson(Properties.IStorage storage, Models.Person person);
|
void TestStatic_SavePerson(Properties.IStorage storage, string personBirthdayFormat, Models.Person person) =>
|
||||||
static void SavePerson(Properties.IStorage storage, Models.Person person) => Person.SavePerson(storage, person);
|
SavePerson(storage, personBirthdayFormat, person);
|
||||||
|
static void SavePerson(Properties.IStorage storage, string personBirthdayFormat, Models.Person person) =>
|
||||||
|
Person.SavePerson(storage, personBirthdayFormat, person);
|
||||||
|
|
||||||
string TestStatic_GetFileFullName(Properties.IStorage storage, Models.Person person);
|
string TestStatic_GetFileFullName(Properties.IStorage storage, string personBirthdayFormat, Models.Person person) =>
|
||||||
static string GetFileFullName(Properties.IStorage storage, Models.Person person) => PersonBirthday.GetFileFullName(storage, person.Birthday);
|
GetFileFullName(storage, personBirthdayFormat, person);
|
||||||
|
static string GetFileFullName(Properties.IStorage storage, string personBirthdayFormat, Models.Person person) =>
|
||||||
|
PersonBirthday.GetFileFullName(storage, personBirthdayFormat, person.Birthday);
|
||||||
|
|
||||||
Models.Person TestStatic_CreatePerson(Properties.IStorage storage, Models.PersonBirthday birthday, Models.PersonName name, List<Models.PersonComment> comments, List<Models.PersonURL> urls, List<Models.PersonNumber> numbers, List<Models.PersonEmail> emails, List<Models.PersonAddress> addresses);
|
Models.Person TestStatic_CreatePerson(Properties.IStorage storage, string personBirthdayFormat, Models.PersonBirthday birthday, Models.PersonName name, List<Models.PersonComment> comments, List<Models.PersonURL> urls, List<Models.PersonNumber> numbers, List<Models.PersonEmail> emails, List<Models.PersonAddress> addresses) =>
|
||||||
static Models.Person CreatePerson(Properties.IStorage storage, Models.PersonBirthday birthday, Models.PersonName name, List<Models.PersonComment> comments, List<Models.PersonURL> urls, List<Models.PersonNumber> numbers, List<Models.PersonEmail> emails, List<Models.PersonAddress> addresses) => Person.CreatePerson(storage, birthday, name, comments, urls, numbers, emails, addresses);
|
CreatePerson(storage, personBirthdayFormat, birthday, name, comments, urls, numbers, emails, addresses);
|
||||||
|
static Models.Person CreatePerson(Properties.IStorage storage, string personBirthdayFormat, Models.PersonBirthday birthday, Models.PersonName name, List<Models.PersonComment> comments, List<Models.PersonURL> urls, List<Models.PersonNumber> numbers, List<Models.PersonEmail> emails, List<Models.PersonAddress> addresses) =>
|
||||||
|
Person.CreatePerson(storage, personBirthdayFormat, birthday, name, comments, urls, numbers, emails, addresses);
|
||||||
|
|
||||||
}
|
}
|
@ -16,20 +16,20 @@ public interface IPersonBirthday
|
|||||||
static double? GetAge(Models.PersonBirthday birthday) =>
|
static double? GetAge(Models.PersonBirthday birthday) =>
|
||||||
PersonBirthday.GetAge(birthday);
|
PersonBirthday.GetAge(birthday);
|
||||||
|
|
||||||
DateTime? TestStatic_GetDateTime(string personKey) =>
|
DateTime? TestStatic_GetDateTime(string personBirthdayFormat, string personKey) =>
|
||||||
PersonBirthday.GetDateTime(personKey);
|
PersonBirthday.GetDateTime(personBirthdayFormat, personKey);
|
||||||
static DateTime? GetDateTime(string personKey) =>
|
static DateTime? GetDateTime(string personBirthdayFormat, string personKey) =>
|
||||||
PersonBirthday.GetDateTime(personKey);
|
PersonBirthday.GetDateTime(personBirthdayFormat, personKey);
|
||||||
|
|
||||||
Models.PersonBirthday TestStatic_GetPersonBirthday(long ticks) =>
|
Models.PersonBirthday TestStatic_GetPersonBirthday(long ticks) =>
|
||||||
new(new(ticks));
|
new(new(ticks));
|
||||||
static Models.PersonBirthday GetPersonBirthday(long ticks) =>
|
static Models.PersonBirthday GetPersonBirthday(long ticks) =>
|
||||||
new(new(ticks));
|
new(new(ticks));
|
||||||
|
|
||||||
string TestStatic_GetFileName(Models.PersonBirthday personBirthday) =>
|
string TestStatic_GetFileName(string personBirthdayFormat, Models.PersonBirthday personBirthday) =>
|
||||||
PersonBirthday.GetFileName(personBirthday);
|
PersonBirthday.GetFileName(personBirthdayFormat, personBirthday);
|
||||||
static string GetFileName(Models.PersonBirthday personBirthday) =>
|
static string GetFileName(string personBirthdayFormat, Models.PersonBirthday personBirthday) =>
|
||||||
PersonBirthday.GetFileName(personBirthday);
|
PersonBirthday.GetFileName(personBirthdayFormat, personBirthday);
|
||||||
|
|
||||||
(int, TimeSpan) TestStatic_GetAge(DateTime dateTime, Models.PersonBirthday birthday) =>
|
(int, TimeSpan) TestStatic_GetAge(DateTime dateTime, Models.PersonBirthday birthday) =>
|
||||||
GetAge(dateTime, birthday);
|
GetAge(dateTime, birthday);
|
||||||
@ -41,15 +41,15 @@ public interface IPersonBirthday
|
|||||||
static (int, TimeSpan) GetAge(long dateTimeTicks, Models.PersonBirthday birthday) =>
|
static (int, TimeSpan) GetAge(long dateTimeTicks, Models.PersonBirthday birthday) =>
|
||||||
PersonBirthday.GetAge(dateTimeTicks, birthday);
|
PersonBirthday.GetAge(dateTimeTicks, birthday);
|
||||||
|
|
||||||
string TestStatic_GetFormatted(Models.PersonBirthday personBirthday) =>
|
string TestStatic_GetFormatted(string personBirthdayFormat, Models.PersonBirthday personBirthday) =>
|
||||||
PersonBirthday.GetFormatted(personBirthday);
|
PersonBirthday.GetFormatted(personBirthdayFormat, personBirthday);
|
||||||
static string GetFormatted(Models.PersonBirthday personBirthday) =>
|
static string GetFormatted(string personBirthdayFormat, Models.PersonBirthday personBirthday) =>
|
||||||
PersonBirthday.GetFormatted(personBirthday);
|
PersonBirthday.GetFormatted(personBirthdayFormat, personBirthday);
|
||||||
|
|
||||||
Models.PersonBirthday? TestStatic_GetPersonBirthday(string personKey) =>
|
Models.PersonBirthday? TestStatic_GetPersonBirthday(string personBirthdayFormat, string personKey) =>
|
||||||
PersonBirthday.GetPersonBirthday(personKey);
|
PersonBirthday.GetPersonBirthday(personBirthdayFormat, personKey);
|
||||||
static Models.PersonBirthday? GetPersonBirthday(string personKey) =>
|
static Models.PersonBirthday? GetPersonBirthday(string personBirthdayFormat, string personKey) =>
|
||||||
PersonBirthday.GetPersonBirthday(personKey);
|
PersonBirthday.GetPersonBirthday(personBirthdayFormat, personKey);
|
||||||
|
|
||||||
bool TestStatic_IsCounterPersonBirthday(Models.PersonBirthday personBirthday);
|
bool TestStatic_IsCounterPersonBirthday(Models.PersonBirthday personBirthday);
|
||||||
static bool IsCounterPersonBirthday(Models.PersonBirthday personBirthday) =>
|
static bool IsCounterPersonBirthday(Models.PersonBirthday personBirthday) =>
|
||||||
@ -70,10 +70,10 @@ public interface IPersonBirthday
|
|||||||
static TimeSpan? GetTimeSpan(long minimumDateTimeTicks, bool? isWrongYear, Models.PersonBirthday personBirthday) =>
|
static TimeSpan? GetTimeSpan(long minimumDateTimeTicks, bool? isWrongYear, Models.PersonBirthday personBirthday) =>
|
||||||
PersonBirthday.GetTimeSpan(minimumDateTimeTicks, isWrongYear, personBirthday);
|
PersonBirthday.GetTimeSpan(minimumDateTimeTicks, isWrongYear, personBirthday);
|
||||||
|
|
||||||
string TestStatic_GetFileFullName(Properties.IStorage storage, Models.PersonBirthday personBirthday) =>
|
string TestStatic_GetFileFullName(Properties.IStorage storage, string personBirthdayFormat, Models.PersonBirthday personBirthday) =>
|
||||||
PersonBirthday.GetFileFullName(storage, personBirthday);
|
PersonBirthday.GetFileFullName(storage, personBirthdayFormat, personBirthday);
|
||||||
static string GetFileFullName(Properties.IStorage storage, Models.PersonBirthday personBirthday) =>
|
static string GetFileFullName(Properties.IStorage storage, string personBirthdayFormat, Models.PersonBirthday personBirthday) =>
|
||||||
PersonBirthday.GetFileFullName(storage, personBirthday);
|
PersonBirthday.GetFileFullName(storage, personBirthdayFormat, personBirthday);
|
||||||
|
|
||||||
bool TestStatic_DoesBirthDateExits(Properties.IStorage storage, Models.PersonBirthday personBirthday) =>
|
bool TestStatic_DoesBirthDateExits(Properties.IStorage storage, Models.PersonBirthday personBirthday) =>
|
||||||
DoesBirthDateExits(storage, personBirthday);
|
DoesBirthDateExits(storage, personBirthday);
|
||||||
|
@ -8,9 +8,9 @@ public interface ISorting
|
|||||||
static Models.Sorting[] Sort(List<Models.Sorting> collection) =>
|
static Models.Sorting[] Sort(List<Models.Sorting> collection) =>
|
||||||
(from l in collection orderby l.WithinRange, l.DistancePermyriad, l.DaysDelta select l).ToArray();
|
(from l in collection orderby l.WithinRange, l.DistancePermyriad, l.DaysDelta select l).ToArray();
|
||||||
|
|
||||||
Models.Sorting TestStatic_Get(Models.FaceDistance faceDistanceEncoding, Models.FaceDistance faceDistanceLength, bool anyLowerThanTolerance, List<(long lcl, long minimum, long maximum, long ucl)> personKeysRangesCollection) =>
|
Models.Sorting TestStatic_Get(int faceDistancePermyriad, double faceDistanceTolerance, Models.FaceDistance faceDistanceEncoding, Models.FaceDistance faceDistanceLength, bool anyLowerThanTolerance, List<(long lcl, long minimum, long maximum, long ucl)> personKeysRangesCollection) =>
|
||||||
Get(faceDistanceEncoding, faceDistanceLength, anyLowerThanTolerance, personKeysRangesCollection);
|
Get(faceDistancePermyriad, faceDistanceTolerance, faceDistanceEncoding, faceDistanceLength, anyLowerThanTolerance, personKeysRangesCollection);
|
||||||
static Models.Sorting Get(Models.FaceDistance faceDistanceEncoding, Models.FaceDistance faceDistanceLength, bool anyLowerThanTolerance, List<(long lcl, long minimum, long maximum, long ucl)> personKeysRangesCollection) =>
|
static Models.Sorting Get(int faceDistancePermyriad, double faceDistanceTolerance, Models.FaceDistance faceDistanceEncoding, Models.FaceDistance faceDistanceLength, bool anyLowerThanTolerance, List<(long lcl, long minimum, long maximum, long ucl)> personKeysRangesCollection) =>
|
||||||
Sorting.Get(faceDistanceEncoding, faceDistanceLength, anyLowerThanTolerance, personKeysRangesCollection);
|
Sorting.Get(faceDistancePermyriad, faceDistanceTolerance, faceDistanceEncoding, faceDistanceLength, anyLowerThanTolerance, personKeysRangesCollection);
|
||||||
|
|
||||||
}
|
}
|
@ -3,7 +3,7 @@ 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 right, int top, int width, int zCount)
|
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 result;
|
||||||
double value;
|
double value;
|
||||||
@ -15,7 +15,7 @@ internal abstract class Location
|
|||||||
value = at / total;
|
value = at / total;
|
||||||
if (value < 0)
|
if (value < 0)
|
||||||
value = 3;
|
value = 3;
|
||||||
result = (int)(Math.Round(value, Stateless.ILocation.Digits) * Stateless.ILocation.Factor);
|
result = (int)(Math.Round(value, locationDigits) * locationFactor);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,15 +5,15 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
|||||||
internal abstract class Mapping
|
internal abstract class Mapping
|
||||||
{
|
{
|
||||||
|
|
||||||
internal static double GetDeterministicHashCodeKey(Models.Item item, Models.Face face)
|
internal static double GetDeterministicHashCodeKey(int locationDigits, Models.Item item, Models.Face face)
|
||||||
{
|
{
|
||||||
if (item.Property?.Id is null || item.ImageFileHolder is null || face.Location?.NormalizedPixelPercentage is null)
|
if (item.Property?.Id is null || item.ImageFileHolder is null || face.Location?.NormalizedPixelPercentage is null)
|
||||||
throw new NullReferenceException();
|
throw new NullReferenceException();
|
||||||
double result = IMapping.GetDeterministicHashCodeKeyValue(item.Property.Id.Value, face.Location.NormalizedPixelPercentage.Value);
|
double result = IMapping.GetDeterministicHashCodeKeyValue(locationDigits, item.Property.Id.Value, face.Location.NormalizedPixelPercentage.Value);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void UseKeyValuePairsSaveFaceEncoding(Dictionary<int, List<Models.Face>> keyValuePairs, string file, int id, int normalizedPixelPercentageValue, double deterministicHashCodeKey, string extensionLowered)
|
private static void UseKeyValuePairsSaveFaceEncoding(int locationDigits, Dictionary<int, List<Models.Face>> keyValuePairs, string file, int id, int normalizedPixelPercentageValue, double deterministicHashCodeKey, string extensionLowered)
|
||||||
{
|
{
|
||||||
string json;
|
string json;
|
||||||
string checkFile;
|
string checkFile;
|
||||||
@ -24,7 +24,7 @@ internal abstract class Mapping
|
|||||||
{
|
{
|
||||||
if (face.FaceEncoding is null || face.Location?.NormalizedPixelPercentage is null)
|
if (face.FaceEncoding is null || face.Location?.NormalizedPixelPercentage is null)
|
||||||
continue;
|
continue;
|
||||||
if (normalizedPixelPercentageValue != face.Location.NormalizedPixelPercentage.Value && deterministicHashCodeKey != IMapping.GetDeterministicHashCodeKeyValue(id, face.Location.NormalizedPixelPercentage.Value))
|
if (normalizedPixelPercentageValue != face.Location.NormalizedPixelPercentage.Value && deterministicHashCodeKey != IMapping.GetDeterministicHashCodeKeyValue(locationDigits, id, face.Location.NormalizedPixelPercentage.Value))
|
||||||
continue;
|
continue;
|
||||||
collection.Add(face);
|
collection.Add(face);
|
||||||
}
|
}
|
||||||
@ -43,7 +43,7 @@ internal abstract class Mapping
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static (int?, int?, double?) GetReversedDeterministicHashCodeKeysFromSegments(bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file, string[] segments)
|
private static (int?, int?, double?) GetReversedDeterministicHashCodeKeysFromSegments(int locationDigits, bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file, string[] segments)
|
||||||
{
|
{
|
||||||
double? result;
|
double? result;
|
||||||
if (segments.Length != 3)
|
if (segments.Length != 3)
|
||||||
@ -55,14 +55,14 @@ internal abstract class Mapping
|
|||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
result = IMapping.GetDeterministicHashCodeKeyValue(idValue, normalizedPixelPercentageValue);
|
result = IMapping.GetDeterministicHashCodeKeyValue(locationDigits, idValue, normalizedPixelPercentageValue);
|
||||||
if (keyValuePairsAny && keyValuePairs.ContainsKey(idValue))
|
if (keyValuePairsAny && keyValuePairs.ContainsKey(idValue))
|
||||||
UseKeyValuePairsSaveFaceEncoding(keyValuePairs, file, idValue, normalizedPixelPercentageValue, result.Value, $".{segments[2]}");
|
UseKeyValuePairsSaveFaceEncoding(locationDigits, keyValuePairs, file, idValue, normalizedPixelPercentageValue, result.Value, $".{segments[2]}");
|
||||||
}
|
}
|
||||||
return new(idValue, normalizedPixelPercentageValue, result);
|
return new(idValue, normalizedPixelPercentageValue, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static (int?, int?) GetReversedDeterministicHashCodeKey(bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file)
|
internal static (int?, int?) GetReversedDeterministicHashCodeKey(int locationDigits, bool keyValuePairsAny, Dictionary<int, List<Models.Face>> keyValuePairs, string file)
|
||||||
{
|
{
|
||||||
int? id;
|
int? id;
|
||||||
int? normalizedPixelPercentage;
|
int? normalizedPixelPercentage;
|
||||||
@ -75,7 +75,7 @@ internal abstract class Mapping
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
string[] segments = fileName.Split('.');
|
string[] segments = fileName.Split('.');
|
||||||
(id, normalizedPixelPercentage, double? result) = GetReversedDeterministicHashCodeKeysFromSegments(keyValuePairsAny, keyValuePairs, file, segments);
|
(id, normalizedPixelPercentage, double? result) = GetReversedDeterministicHashCodeKeysFromSegments(locationDigits, keyValuePairsAny, keyValuePairs, file, segments);
|
||||||
if (result is null)
|
if (result is null)
|
||||||
{
|
{
|
||||||
id = null;
|
id = null;
|
||||||
|
@ -8,7 +8,7 @@ internal abstract class Person
|
|||||||
|
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
private static List<string> ValidatePerson(Properties.IStorage storage, Models.PersonId id, Models.PersonBirthday birthday, Models.PersonName name)
|
private static List<string> ValidatePerson(Properties.IStorage storage, string personBirthdayFormat, Models.PersonId id, Models.PersonBirthday birthday, Models.PersonName name)
|
||||||
{
|
{
|
||||||
List<string> results = new();
|
List<string> results = new();
|
||||||
if (birthday is null)
|
if (birthday is null)
|
||||||
@ -21,18 +21,18 @@ internal abstract class Person
|
|||||||
results.Add("Id must be Birthday ticks!");
|
results.Add("Id must be Birthday ticks!");
|
||||||
if (name.First is null || string.IsNullOrEmpty(name.First.Value))
|
if (name.First is null || string.IsNullOrEmpty(name.First.Value))
|
||||||
results.Add("Fist Name must be supplied!");
|
results.Add("Fist Name must be supplied!");
|
||||||
if (PersonBirthday.DoesBirthDateExits(storage, birthday))
|
if (PersonBirthday.DoesBirthDateExits(storage, personBirthdayFormat, birthday))
|
||||||
results.Add("BirthDate already exits!");
|
results.Add("BirthDate already exits!");
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Models.Person CreatePerson(Properties.IStorage storage, Models.PersonBirthday birthday, Models.PersonName name, List<Models.PersonComment> comments, List<Models.PersonURL> urls, List<Models.PersonNumber> numbers, List<Models.PersonEmail> emails, List<Models.PersonAddress> addresses)
|
internal static Models.Person CreatePerson(Properties.IStorage storage, string personBirthdayFormat, Models.PersonBirthday birthday, Models.PersonName name, List<Models.PersonComment> comments, List<Models.PersonURL> urls, List<Models.PersonNumber> numbers, List<Models.PersonEmail> emails, List<Models.PersonAddress> addresses)
|
||||||
{
|
{
|
||||||
Models.Person result;
|
Models.Person result;
|
||||||
Models.PersonId id = new(birthday.Value.Ticks);
|
Models.PersonId id = new(birthday.Value.Ticks);
|
||||||
if (birthday.Value == DateTime.MinValue)
|
if (birthday.Value == DateTime.MinValue)
|
||||||
birthday = PersonBirthday.GetNextBirthDate(storage);
|
birthday = PersonBirthday.GetNextBirthDate(storage);
|
||||||
List<string> results = ValidatePerson(storage, id, birthday, name);
|
List<string> results = ValidatePerson(storage, personBirthdayFormat, id, birthday, name);
|
||||||
if (results.Any())
|
if (results.Any())
|
||||||
throw new Exception(string.Join(Environment.NewLine, results));
|
throw new Exception(string.Join(Environment.NewLine, results));
|
||||||
if (comments is null)
|
if (comments is null)
|
||||||
@ -61,12 +61,12 @@ internal abstract class Person
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Dictionary<DateTime, string[]> Split(string knownPeopleFile)
|
internal static Dictionary<DateTime, string[]> Split(int personBirthdayFirstYear, string personKeyFormat, string knownPeopleFile)
|
||||||
{
|
{
|
||||||
Dictionary<DateTime, string[]> results = new();
|
Dictionary<DateTime, string[]> results = new();
|
||||||
string[] segments;
|
string[] segments;
|
||||||
DateTime personKey;
|
DateTime personKey;
|
||||||
DateTime incrementDate = new(Stateless.IPersonBirthday.FirstYear, 1, 1);
|
DateTime incrementDate = new(personBirthdayFirstYear, 1, 1);
|
||||||
string[] lines = File.ReadAllLines(knownPeopleFile);
|
string[] lines = File.ReadAllLines(knownPeopleFile);
|
||||||
_ = incrementDate.AddDays(lines.Length);
|
_ = incrementDate.AddDays(lines.Length);
|
||||||
System.Globalization.CultureInfo cultureInfo = System.Globalization.CultureInfo.InvariantCulture;
|
System.Globalization.CultureInfo cultureInfo = System.Globalization.CultureInfo.InvariantCulture;
|
||||||
@ -77,8 +77,8 @@ internal abstract class Person
|
|||||||
segments = line.Replace(" //", "\t//").Split('\t');
|
segments = line.Replace(" //", "\t//").Split('\t');
|
||||||
if (segments.Length < 1)
|
if (segments.Length < 1)
|
||||||
continue;
|
continue;
|
||||||
SetSegments(ref segments, Stateless.IPerson.KeyFormat, ref incrementDate);
|
SetSegments(ref segments, personKeyFormat, ref incrementDate);
|
||||||
personKey = DateTime.ParseExact(segments[0], Stateless.IPerson.KeyFormat, cultureInfo);
|
personKey = DateTime.ParseExact(segments[0], personKeyFormat, cultureInfo);
|
||||||
if (results.ContainsKey(personKey))
|
if (results.ContainsKey(personKey))
|
||||||
continue;
|
continue;
|
||||||
results.Add(personKey, segments);
|
results.Add(personKey, segments);
|
||||||
@ -90,7 +90,7 @@ internal abstract class Person
|
|||||||
for (int i = 1; i < (1000 - countBefore); i++)
|
for (int i = 1; i < (1000 - countBefore); i++)
|
||||||
{
|
{
|
||||||
personKey = minimumDateTime.AddDays(i * -1);
|
personKey = minimumDateTime.AddDays(i * -1);
|
||||||
results.Add(personKey, new string[] { personKey.ToString(Stateless.IPerson.KeyFormat) });
|
results.Add(personKey, new string[] { personKey.ToString(personKeyFormat) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return results.OrderBy(l => l.Key).ToDictionary(l => l.Key, l => l.Value);
|
return results.OrderBy(l => l.Key).ToDictionary(l => l.Key, l => l.Value);
|
||||||
@ -118,7 +118,7 @@ internal abstract class Person
|
|||||||
SetValues(ref name, ref comment, ref mergeName, splitLine);
|
SetValues(ref name, ref comment, ref mergeName, splitLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dictionary<DateTime, PersonImport> GetPersonCollection(string knownPeopleFile)
|
private static Dictionary<DateTime, PersonImport> GetPersonCollection(int personBirthdayFirstYear, string personKeyFormat, string knownPeopleFile)
|
||||||
{
|
{
|
||||||
Dictionary<DateTime, PersonImport> results = new();
|
Dictionary<DateTime, PersonImport> results = new();
|
||||||
string name;
|
string name;
|
||||||
@ -127,7 +127,7 @@ internal abstract class Person
|
|||||||
string oldName;
|
string oldName;
|
||||||
string mergeName;
|
string mergeName;
|
||||||
PersonImport person;
|
PersonImport person;
|
||||||
Dictionary<DateTime, string[]> splitLines = Split(knownPeopleFile);
|
Dictionary<DateTime, string[]> splitLines = Split(personBirthdayFirstYear, personKeyFormat, knownPeopleFile);
|
||||||
foreach (KeyValuePair<DateTime, string[]> splitLine in splitLines)
|
foreach (KeyValuePair<DateTime, string[]> splitLine in splitLines)
|
||||||
{
|
{
|
||||||
name = string.Empty;
|
name = string.Empty;
|
||||||
@ -142,9 +142,9 @@ internal abstract class Person
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void SavePerson(Properties.IStorage storage, Models.Person person)
|
internal static void SavePerson(Properties.IStorage storage, string personBirthdayFormat, Models.Person person)
|
||||||
{
|
{
|
||||||
string fileName = IPerson.GetFileFullName(storage, person);
|
string fileName = IPerson.GetFileFullName(storage, personBirthdayFormat, person);
|
||||||
string json = JsonSerializer.Serialize(person, new JsonSerializerOptions { WriteIndented = true });
|
string json = JsonSerializer.Serialize(person, new JsonSerializerOptions { WriteIndented = true });
|
||||||
_ = IStorage.WriteAllText(fileName, json, updateDateWhenMatches: true, compareBeforeWrite: true);
|
_ = IStorage.WriteAllText(fileName, json, updateDateWhenMatches: true, compareBeforeWrite: true);
|
||||||
}
|
}
|
||||||
@ -162,7 +162,7 @@ internal abstract class Person
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Models.Person> GetPeopleFromText(Properties.IStorage storage, string localKnownPeopleFile)
|
private static List<Models.Person> GetPeopleFromText(Properties.IStorage storage, int personBirthdayFirstYear, string personBirthdayFormat, string personKeyFormat, string localKnownPeopleFile)
|
||||||
{
|
{
|
||||||
List<Models.Person> results = new();
|
List<Models.Person> results = new();
|
||||||
string comment;
|
string comment;
|
||||||
@ -174,7 +174,7 @@ internal abstract class Person
|
|||||||
List<Models.PersonEmail> emails = new();
|
List<Models.PersonEmail> emails = new();
|
||||||
List<Models.PersonNumber> numbers = new();
|
List<Models.PersonNumber> numbers = new();
|
||||||
List<Models.PersonAddress> addresses = new();
|
List<Models.PersonAddress> addresses = new();
|
||||||
Dictionary<DateTime, PersonImport> keyValuePairs = GetPersonCollection(localKnownPeopleFile);
|
Dictionary<DateTime, PersonImport> keyValuePairs = GetPersonCollection(personBirthdayFirstYear, personKeyFormat, localKnownPeopleFile);
|
||||||
foreach (KeyValuePair<DateTime, PersonImport> keyValuePair in keyValuePairs)
|
foreach (KeyValuePair<DateTime, PersonImport> keyValuePair in keyValuePairs)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(keyValuePair.Value.Name))
|
if (string.IsNullOrEmpty(keyValuePair.Value.Name))
|
||||||
@ -189,14 +189,14 @@ internal abstract class Person
|
|||||||
comment = GetComment(urls, comments, keyValuePair);
|
comment = GetComment(urls, comments, keyValuePair);
|
||||||
if (!string.IsNullOrEmpty(keyValuePair.Value.OldName))
|
if (!string.IsNullOrEmpty(keyValuePair.Value.OldName))
|
||||||
comments.Add(new(new(keyValuePair.Value.OldName)));
|
comments.Add(new(new(keyValuePair.Value.OldName)));
|
||||||
person = IPerson.CreatePerson(storage, birthday, name, comments, urls, numbers, emails, addresses);
|
person = IPerson.CreatePerson(storage, personBirthdayFormat, birthday, name, comments, urls, numbers, emails, addresses);
|
||||||
SavePerson(storage, person);
|
SavePerson(storage, personBirthdayFormat, person);
|
||||||
results.Add(person);
|
results.Add(person);
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Models.Person[] GetPeople(Properties.IStorage storage)
|
internal static Models.Person[] GetPeople(Properties.IStorage storage, int personBirthdayFirstYear, string personBirthdayFormat, string personKeyFormat)
|
||||||
{
|
{
|
||||||
List<Models.Person> results = new();
|
List<Models.Person> results = new();
|
||||||
string json;
|
string json;
|
||||||
@ -234,7 +234,7 @@ internal abstract class Person
|
|||||||
results.Add(person);
|
results.Add(person);
|
||||||
}
|
}
|
||||||
if (!results.Any())
|
if (!results.Any())
|
||||||
results = GetPeopleFromText(storage, localKnownPeopleFile);
|
results = GetPeopleFromText(storage, personBirthdayFirstYear, personBirthdayFormat, personKeyFormat, localKnownPeopleFile);
|
||||||
else if (!string.IsNullOrEmpty(localKnownPeopleFile))
|
else if (!string.IsNullOrEmpty(localKnownPeopleFile))
|
||||||
{
|
{
|
||||||
fileInfo = new FileInfo(localKnownPeopleFile);
|
fileInfo = new FileInfo(localKnownPeopleFile);
|
||||||
@ -242,14 +242,14 @@ internal abstract class Person
|
|||||||
{
|
{
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
File.Delete(file);
|
File.Delete(file);
|
||||||
results = GetPeopleFromText(storage, localKnownPeopleFile);
|
results = GetPeopleFromText(storage, personBirthdayFirstYear, personBirthdayFormat, personKeyFormat, localKnownPeopleFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SaveToDirectory(storage, results);
|
SaveToDirectory(storage, personBirthdayFormat, results);
|
||||||
return results.ToArray();
|
return results.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void SaveToDirectory(Properties.IStorage storage, List<Models.Person> people)
|
private static void SaveToDirectory(Properties.IStorage storage, string personBirthdayFormat, List<Models.Person> people)
|
||||||
{
|
{
|
||||||
int years;
|
int years;
|
||||||
TimeSpan? timeSpan;
|
TimeSpan? timeSpan;
|
||||||
@ -265,7 +265,7 @@ internal abstract class Person
|
|||||||
const string pattern = @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]";
|
const string pattern = @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]";
|
||||||
foreach (Models.Person person in people)
|
foreach (Models.Person person in people)
|
||||||
{
|
{
|
||||||
personJsonFileName = IPerson.GetFileFullName(storage, person);
|
personJsonFileName = IPerson.GetFileFullName(storage, personBirthdayFormat, person);
|
||||||
if (string.IsNullOrEmpty(peopleDirectory))
|
if (string.IsNullOrEmpty(peopleDirectory))
|
||||||
peopleDirectory = Path.GetDirectoryName(personJsonFileName);
|
peopleDirectory = Path.GetDirectoryName(personJsonFileName);
|
||||||
if (string.IsNullOrEmpty(peopleDirectory))
|
if (string.IsNullOrEmpty(peopleDirectory))
|
||||||
|
@ -8,17 +8,17 @@ internal abstract class PersonBirthday
|
|||||||
internal static DateTime GetDefaultValue() => DateTime.MinValue; // {{1}}SingletonValue
|
internal static DateTime GetDefaultValue() => DateTime.MinValue; // {{1}}SingletonValue
|
||||||
|
|
||||||
// ...
|
// ...
|
||||||
internal static string GetFormatted(Models.PersonBirthday personBirthday) => personBirthday.Value.ToString(Stateless.IPersonBirthday.Format);
|
internal static string GetFormatted(string personBirthdayFormat, Models.PersonBirthday personBirthday) => personBirthday.Value.ToString(personBirthdayFormat);
|
||||||
internal static string GetFileName(Models.PersonBirthday personBirthday) => $"{personBirthday.Value.ToString(Stateless.IPersonBirthday.Format)}.json";
|
internal static string GetFileName(string personBirthdayFormat, Models.PersonBirthday personBirthday) => $"{personBirthday.Value.ToString(personBirthdayFormat)}.json";
|
||||||
internal static bool DoesBirthDateExits(Properties.IStorage storage, Models.PersonBirthday personBirthday) => File.Exists(GetFileFullName(storage, personBirthday));
|
internal static bool DoesBirthDateExits(Properties.IStorage storage, string personBirthdayFormat, Models.PersonBirthday personBirthday) => File.Exists(GetFileFullName(storage, personBirthdayFormat, personBirthday));
|
||||||
internal static Models.PersonBirthday GetNextBirthDate(Properties.IStorage storage) => throw new Exception(storage.ToString()); // Person.GetNextBirthDate(storage);
|
internal static Models.PersonBirthday GetNextBirthDate(Properties.IStorage storage) => throw new Exception(storage.ToString()); // Person.GetNextBirthDate(storage);
|
||||||
internal static string GetFileFullName(Properties.IStorage storage, Models.PersonBirthday personBirthday) => Path.Combine(storage.PeopleRootDirectory, "{}", GetFileName(personBirthday));
|
internal static string GetFileFullName(Properties.IStorage storage, string personBirthdayFormat, Models.PersonBirthday personBirthday) => Path.Combine(storage.PeopleRootDirectory, "{}", GetFileName(personBirthdayFormat, personBirthday));
|
||||||
internal static DateTime? GetDateTime(string personKey) => DateTime.TryParseExact(personKey, Stateless.IPersonBirthday.Format, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTime) ? dateTime : null;
|
internal static DateTime? GetDateTime(string personBirthdayFormat, string personKey) => DateTime.TryParseExact(personKey, personBirthdayFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTime) ? dateTime : null;
|
||||||
|
|
||||||
internal static Models.PersonBirthday? GetPersonBirthday(string personKey)
|
internal static Models.PersonBirthday? GetPersonBirthday(string personBirthdayFormat, string personKey)
|
||||||
{
|
{
|
||||||
Models.PersonBirthday? result;
|
Models.PersonBirthday? result;
|
||||||
DateTime? dateTime = GetDateTime(personKey);
|
DateTime? dateTime = GetDateTime(personBirthdayFormat, personKey);
|
||||||
if (dateTime is null)
|
if (dateTime is null)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
|
@ -3,7 +3,7 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
|||||||
internal abstract class Sorting
|
internal abstract class Sorting
|
||||||
{
|
{
|
||||||
|
|
||||||
internal static Models.Sorting Get(Models.FaceDistance faceDistanceEncoding, Models.FaceDistance faceDistanceLength, bool anyLowerThanTolerance, List<(long lcl, long minimum, long maximum, long ucl)> personKeysRangesCollection)
|
internal static Models.Sorting Get(int faceDistancePermyriad, double faceDistanceTolerance, Models.FaceDistance faceDistanceEncoding, Models.FaceDistance faceDistanceLength, bool anyLowerThanTolerance, List<(long lcl, long minimum, long maximum, long ucl)> personKeysRangesCollection)
|
||||||
{
|
{
|
||||||
Models.Sorting result;
|
Models.Sorting result;
|
||||||
if (faceDistanceLength.Length is null)
|
if (faceDistanceLength.Length is null)
|
||||||
@ -14,7 +14,7 @@ internal abstract class Sorting
|
|||||||
int daysDelta;
|
int daysDelta;
|
||||||
int withinRange;
|
int withinRange;
|
||||||
int distancePermyriad;
|
int distancePermyriad;
|
||||||
if (faceDistanceLength.Length.Value == 0 || (anyLowerThanTolerance && faceDistanceLength.Length.Value >= Stateless.IFaceDistance.Tolerance))
|
if (faceDistanceLength.Length.Value == 0 || (anyLowerThanTolerance && faceDistanceLength.Length.Value >= faceDistanceTolerance))
|
||||||
{
|
{
|
||||||
older = false;
|
older = false;
|
||||||
daysDelta = 0;
|
daysDelta = 0;
|
||||||
@ -30,7 +30,7 @@ internal abstract class Sorting
|
|||||||
TimeSpan timeSpan = new(faceDistanceLength.MinimumDateTime.Value.Ticks - ticks);
|
TimeSpan timeSpan = new(faceDistanceLength.MinimumDateTime.Value.Ticks - ticks);
|
||||||
older = timeSpan.TotalMilliseconds < 0;
|
older = timeSpan.TotalMilliseconds < 0;
|
||||||
daysDelta = (int)Math.Round(Math.Abs(timeSpan.TotalDays), 0);
|
daysDelta = (int)Math.Round(Math.Abs(timeSpan.TotalDays), 0);
|
||||||
distancePermyriad = (int)(faceDistanceLength.Length.Value / Stateless.IFaceDistance.Tolerance * Stateless.IFaceDistance.Permyriad);
|
distancePermyriad = (int)(faceDistanceLength.Length.Value / faceDistanceTolerance * faceDistancePermyriad);
|
||||||
foreach ((long lcl, long minimum, long maximum, long ucl) in personKeysRangesCollection)
|
foreach ((long lcl, long minimum, long maximum, long ucl) in personKeysRangesCollection)
|
||||||
{
|
{
|
||||||
if (ticks > minimum && ticks < maximum)
|
if (ticks > minimum && ticks < maximum)
|
||||||
|
@ -85,8 +85,8 @@ public class UnitTestResize
|
|||||||
width = 100;
|
width = 100;
|
||||||
height = 100;
|
height = 100;
|
||||||
Location location = new(bottom, confidence, left, null, right, top);
|
Location location = new(bottom, confidence, left, null, right, top);
|
||||||
_ = new Location(confidence, height, location, width, 1);
|
_ = new Location(confidence, height, location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, 1);
|
||||||
_ = new Location(bottom, confidence, height, left, right, top, width, 1);
|
_ = new Location(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -100,7 +100,7 @@ public class UnitTestResize
|
|||||||
bottom = 10;
|
bottom = 10;
|
||||||
width = 100;
|
width = 100;
|
||||||
height = 100;
|
height = 100;
|
||||||
normalizedPixelPercentage = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(bottom, height, left, right, top, width, 1);
|
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);
|
Assert.IsTrue(normalizedPixelPercentage == 40500);
|
||||||
left = 50;
|
left = 50;
|
||||||
top = 50;
|
top = 50;
|
||||||
@ -108,7 +108,7 @@ public class UnitTestResize
|
|||||||
bottom = 60;
|
bottom = 60;
|
||||||
width = 100;
|
width = 100;
|
||||||
height = 100;
|
height = 100;
|
||||||
normalizedPixelPercentage = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(bottom, height, left, right, top, width, 1);
|
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);
|
Assert.IsTrue(normalizedPixelPercentage == 545500);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ public class UnitTestResize
|
|||||||
bottom = 260;
|
bottom = 260;
|
||||||
width = 500;
|
width = 500;
|
||||||
height = 500;
|
height = 500;
|
||||||
normalizedPixelPercentage = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(bottom, height, left, right, top, width, 1);
|
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);
|
Assert.IsTrue(normalizedPixelPercentage == 499000);
|
||||||
left = 490;
|
left = 490;
|
||||||
top = 490;
|
top = 490;
|
||||||
@ -131,7 +131,7 @@ public class UnitTestResize
|
|||||||
bottom = 510;
|
bottom = 510;
|
||||||
width = 1000;
|
width = 1000;
|
||||||
height = 1000;
|
height = 1000;
|
||||||
normalizedPixelPercentage = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(bottom, height, left, right, top, width, 1);
|
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);
|
Assert.IsTrue(normalizedPixelPercentage == 499500);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -146,7 +146,7 @@ public class UnitTestResize
|
|||||||
bottom = 80;
|
bottom = 80;
|
||||||
width = 100;
|
width = 100;
|
||||||
height = 100;
|
height = 100;
|
||||||
normalizedPixelPercentage = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(bottom, height, left, right, top, width, 1);
|
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);
|
Assert.IsTrue(normalizedPixelPercentage == 594000);
|
||||||
left = 20;
|
left = 20;
|
||||||
top = 40;
|
top = 40;
|
||||||
@ -154,7 +154,7 @@ public class UnitTestResize
|
|||||||
bottom = 80;
|
bottom = 80;
|
||||||
width = 100;
|
width = 100;
|
||||||
height = 100;
|
height = 100;
|
||||||
normalizedPixelPercentage = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(bottom, height, left, right, top, width, 10);
|
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);
|
Assert.IsTrue(normalizedPixelPercentage == 594000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
11
package.json
11
package.json
@ -20,16 +20,5 @@
|
|||||||
"Z-Compare-Publish-": "dotnet publish \"Compare\\Compare.csproj\" --configuration Release --runtime win-x64 --verbosity normal --self-contained true -o \"D:\\net6.0\\View-by-Distance\\Compare\\\"",
|
"Z-Compare-Publish-": "dotnet publish \"Compare\\Compare.csproj\" --configuration Release --runtime win-x64 --verbosity normal --self-contained true -o \"D:\\net6.0\\View-by-Distance\\Compare\\\"",
|
||||||
"Z-Instance-Publish-": "dotnet publish \"Instance\\Instance.csproj\" --configuration Release --runtime win-x64 --verbosity normal --self-contained true -o \"D:\\net6.0\\View-by-Distance\\Instance\\\"",
|
"Z-Instance-Publish-": "dotnet publish \"Instance\\Instance.csproj\" --configuration Release --runtime win-x64 --verbosity normal --self-contained true -o \"D:\\net6.0\\View-by-Distance\\Instance\\\"",
|
||||||
"Z-Instance-CUDA-Publish-": "dotnet publish \"Instance\\Instance.csproj\" --configuration Release --runtime win-x64 --verbosity normal --self-contained true -o \"D:\\net6.0\\View-by-Distance\\Instance-CUDA\\\""
|
"Z-Instance-CUDA-Publish-": "dotnet publish \"Instance\\Instance.csproj\" --configuration Release --runtime win-x64 --verbosity normal --self-contained true -o \"D:\\net6.0\\View-by-Distance\\Instance-CUDA\\\""
|
||||||
},
|
|
||||||
"Notes": {
|
|
||||||
"AmazonUsername": "phares36@gmail.com",
|
|
||||||
"AmazonPassword": "JlPhgtv@63",
|
|
||||||
"a": "Keep creating the .json file the same way",
|
|
||||||
"b": "However load all .json files at the beginning",
|
|
||||||
"c": "When looping through all files and file not in collection path&name or date is different from collection value",
|
|
||||||
"d": "Get id in normal fashion",
|
|
||||||
"e": "If id is in collection update collection to new path/name",
|
|
||||||
"f": "If not save and add to collection",
|
|
||||||
"g": "Nicéphore Niépce in 1826 or 1827"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user