Strip old way
This commit is contained in:
parent
409c020426
commit
7390c13751
@ -714,15 +714,6 @@ public partial class DlibDotNet
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OldMapLogic(long ticks, string dResultsFullGroupDirectory, string d2ResultsFullGroupDirectory, MapLogic mapLogic, string outputResolution, Item[] filteredItems)
|
|
||||||
{
|
|
||||||
string dFacesContentDirectory = Path.Combine(dResultsFullGroupDirectory, "()");
|
|
||||||
if (_Configuration.SaveShortcutsForOutputResolutions.Contains(outputResolution))
|
|
||||||
mapLogic.SaveShortcuts(_Configuration.JuliePhares, filteredItems);
|
|
||||||
mapLogic.SavePropertyHolders(filteredItems);
|
|
||||||
_ = LogDeltaInSeconds(ticks, nameof(mapLogic.SavePropertyHolders));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Search(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string argZero, string propertyRoot, Person[] people)
|
private void Search(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string argZero, string propertyRoot, Person[] people)
|
||||||
{
|
{
|
||||||
Container[] containers;
|
Container[] containers;
|
||||||
@ -765,8 +756,8 @@ public partial class DlibDotNet
|
|||||||
List<Face> distinctFilteredFaces = SetMappingThenGetDistinctFilteredFacesWithMapping(argZero, containers);
|
List<Face> distinctFilteredFaces = SetMappingThenGetDistinctFilteredFacesWithMapping(argZero, containers);
|
||||||
SortingContainer[] sortingContainers = E_Distance.SetPersonTicksAndSetFaceDistancesAndSetFaceMappingSortingCollectionThenGetSortingContainers(_AppSettings.MaxDegreeOfParallelism, ticks, mapLogic, outputResolution, eDistanceContentFileName, distinctFilteredFaces);
|
SortingContainer[] sortingContainers = E_Distance.SetPersonTicksAndSetFaceDistancesAndSetFaceMappingSortingCollectionThenGetSortingContainers(_AppSettings.MaxDegreeOfParallelism, ticks, mapLogic, outputResolution, eDistanceContentFileName, distinctFilteredFaces);
|
||||||
mapLogic.CommonWork(_AppSettings.MaxDegreeOfParallelism, dFacesContentDirectory, d2ResultsFullGroupDirectory, distinctFilteredFaces, sortingContainers);
|
mapLogic.CommonWork(_AppSettings.MaxDegreeOfParallelism, dFacesContentDirectory, d2ResultsFullGroupDirectory, distinctFilteredFaces, sortingContainers);
|
||||||
Item[] filteredItems = GetIdSortedFilteredItems(argZero, containers);
|
if (_Configuration.SaveShortcutsForOutputResolutions.Contains(outputResolution))
|
||||||
OldMapLogic(ticks, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory, mapLogic, outputResolution, filteredItems);
|
mapLogic.SaveShortcuts(_Configuration.JuliePhares, distinctFilteredFaces);
|
||||||
if (!_Configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions.Any())
|
if (!_Configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions.Any())
|
||||||
break;
|
break;
|
||||||
if (_FileKeyValuePairs.Any())
|
if (_FileKeyValuePairs.Any())
|
||||||
|
@ -14,11 +14,9 @@ public class MapLogic
|
|||||||
protected readonly List<long> _NotMappedPersonKeys;
|
protected readonly List<long> _NotMappedPersonKeys;
|
||||||
protected readonly Dictionary<int, int[]> _KeyValuePairs;
|
protected readonly Dictionary<int, int[]> _KeyValuePairs;
|
||||||
protected readonly Dictionary<int, int[]> _IndicesFromNew;
|
protected readonly Dictionary<int, int[]> _IndicesFromNew;
|
||||||
protected readonly Dictionary<int, string[]> _SixCharacterNamedFaceInfo;
|
|
||||||
protected readonly Dictionary<int, PersonBirthday[]> _DeterministicHashCodeUnknownFaceKeyValuePairs;
|
|
||||||
protected readonly Dictionary<double, PersonBirthday[]> _IncorrectDeterministicHashCodeKeyValuePairs;
|
|
||||||
protected readonly Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> _PersonKeysRanges;
|
protected readonly Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> _PersonKeysRanges;
|
||||||
protected readonly Dictionary<int, Dictionary<int, PersonBirthday[]>> _IdThenNormalizedPixelPercentageKeyValuePairs;
|
protected readonly Dictionary<int, Dictionary<int, PersonBirthday[]>> _IdThenNormalizedPixelPercentageKeyValuePairs;
|
||||||
|
protected readonly Dictionary<int, Dictionary<int, PersonBirthday[]>> _IncorrectIdThenNormalizedPixelPercentageKeyValuePairs;
|
||||||
protected readonly Dictionary<long, (string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] PersonBirthdays, long PersonKey)> _PeopleKeyValuePairs;
|
protected readonly Dictionary<long, (string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] PersonBirthdays, long PersonKey)> _PeopleKeyValuePairs;
|
||||||
|
|
||||||
public Dictionary<int, int[]> KeyValuePairs => _KeyValuePairs;
|
public Dictionary<int, int[]> KeyValuePairs => _KeyValuePairs;
|
||||||
@ -56,16 +54,14 @@ public class MapLogic
|
|||||||
Dictionary<int, int[]>? keyValuePairs;
|
Dictionary<int, int[]>? keyValuePairs;
|
||||||
List<KeyValuePair<int, int[]>>? collection;
|
List<KeyValuePair<int, int[]>>? collection;
|
||||||
Dictionary<int, int[]> indicesFromNew = new();
|
Dictionary<int, int[]> indicesFromNew = new();
|
||||||
Dictionary<int, string[]>? sixCharacterNamedFaceInfo;
|
|
||||||
string? rootDirectoryParent = Path.GetDirectoryName(configuration.RootDirectory);
|
string? rootDirectoryParent = Path.GetDirectoryName(configuration.RootDirectory);
|
||||||
Dictionary<int, PersonBirthday[]>? deterministicHashCodeUnknownFaceKeyValuePairs;
|
|
||||||
Dictionary<long, (string, int?, PersonBirthday[], long)> peopleKeyValuePairs = new();
|
Dictionary<long, (string, int?, PersonBirthday[], long)> peopleKeyValuePairs = new();
|
||||||
string zPropertyHolderContentDirectory = Path.Combine(zResultsFullGroupDirectory, "()");
|
string zPropertyHolderContentDirectory = Path.Combine(zResultsFullGroupDirectory, "()");
|
||||||
Dictionary<double, PersonBirthday[]> incorrectDeterministicHashCodeKeyValuePairs = new();
|
|
||||||
string zPropertyHolderSingletonDirectory = Path.Combine(zResultsFullGroupDirectory, "{}");
|
string zPropertyHolderSingletonDirectory = Path.Combine(zResultsFullGroupDirectory, "{}");
|
||||||
Dictionary<int, Dictionary<int, PersonBirthday[]>> idThenNormalizedPixelPercentageKeyValuePairs = new();
|
Dictionary<int, Dictionary<int, PersonBirthday[]>> idThenNormalizedPixelPercentageKeyValuePairs = new();
|
||||||
string zPropertyHolderContentTicksDirectory = Path.Combine(zPropertyHolderContentDirectory, $"({ticks})");
|
string zPropertyHolderContentTicksDirectory = Path.Combine(zPropertyHolderContentDirectory, $"({ticks})");
|
||||||
string zPropertyHolderPeopleContentDirectory = Path.Combine(peopleDateGroupDirectory, "()", "(KnownPeople)");
|
string zPropertyHolderPeopleContentDirectory = Path.Combine(peopleDateGroupDirectory, "()", "(KnownPeople)");
|
||||||
|
Dictionary<int, Dictionary<int, PersonBirthday[]>> incorrectIdThenNormalizedPixelPercentageKeyValuePairs = new();
|
||||||
string zPropertyHolderSingletonTicksDirectory = Path.Combine(zPropertyHolderSingletonDirectory, string.Concat('{', _Ticks, '}'));
|
string zPropertyHolderSingletonTicksDirectory = Path.Combine(zPropertyHolderSingletonDirectory, string.Concat('{', _Ticks, '}'));
|
||||||
if (string.IsNullOrEmpty(rootDirectoryParent))
|
if (string.IsNullOrEmpty(rootDirectoryParent))
|
||||||
throw new NullReferenceException(nameof(rootDirectoryParent));
|
throw new NullReferenceException(nameof(rootDirectoryParent));
|
||||||
@ -73,32 +69,9 @@ public class MapLogic
|
|||||||
_ = Directory.CreateDirectory(zPropertyHolderContentDirectory);
|
_ = Directory.CreateDirectory(zPropertyHolderContentDirectory);
|
||||||
if (!Directory.Exists(zPropertyHolderPeopleContentDirectory))
|
if (!Directory.Exists(zPropertyHolderPeopleContentDirectory))
|
||||||
_ = Directory.CreateDirectory(zPropertyHolderPeopleContentDirectory);
|
_ = Directory.CreateDirectory(zPropertyHolderPeopleContentDirectory);
|
||||||
files = Directory.GetFiles(rootDirectoryParent, "DeterministicHashCode*.json", SearchOption.TopDirectoryOnly);
|
Stateless.ByDeterministicHashCode.SetByRef(maxDegreeOfParallelism, ticks, _ResizeFilenameExtension, people, skipCollection, peopleKeyValuePairs, notMappedTicks, idThenNormalizedPixelPercentageKeyValuePairs, incorrectIdThenNormalizedPixelPercentageKeyValuePairs, zPropertyHolderContentDirectory, zPropertyHolderPeopleContentDirectory);
|
||||||
if (files.Length != 1)
|
|
||||||
deterministicHashCodeUnknownFaceKeyValuePairs = new();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
json = File.ReadAllText(files[zero]);
|
|
||||||
deterministicHashCodeUnknownFaceKeyValuePairs = GetKeyValuePairs(json);
|
|
||||||
}
|
|
||||||
Stateless.ByDeterministicHashCode.SetByRef(maxDegreeOfParallelism, ticks, _ResizeFilenameExtension, people, skipCollection, peopleKeyValuePairs, notMappedTicks, deterministicHashCodeUnknownFaceKeyValuePairs, idThenNormalizedPixelPercentageKeyValuePairs, incorrectDeterministicHashCodeKeyValuePairs, zPropertyHolderContentDirectory, zPropertyHolderPeopleContentDirectory);
|
|
||||||
if (!Directory.Exists(zPropertyHolderContentTicksDirectory))
|
if (!Directory.Exists(zPropertyHolderContentTicksDirectory))
|
||||||
_ = Directory.CreateDirectory(zPropertyHolderContentTicksDirectory);
|
_ = Directory.CreateDirectory(zPropertyHolderContentTicksDirectory);
|
||||||
if (!deterministicHashCodeUnknownFaceKeyValuePairs.Any())
|
|
||||||
sixCharacterNamedFaceInfo = new();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
files = Directory.GetFiles(rootDirectoryParent, "*SixCharacter*.json", SearchOption.TopDirectoryOnly);
|
|
||||||
if (files.Length != 1)
|
|
||||||
sixCharacterNamedFaceInfo = new();
|
|
||||||
else
|
|
||||||
{
|
|
||||||
json = File.ReadAllText(files[zero]);
|
|
||||||
sixCharacterNamedFaceInfo = JsonSerializer.Deserialize<Dictionary<int, string[]>>(json);
|
|
||||||
if (sixCharacterNamedFaceInfo is null)
|
|
||||||
throw new NullReferenceException(nameof(sixCharacterNamedFaceInfo));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
files = Directory.GetFiles(rootDirectoryParent, "*keyValuePairs-6*.json", SearchOption.TopDirectoryOnly);
|
files = Directory.GetFiles(rootDirectoryParent, "*keyValuePairs-6*.json", SearchOption.TopDirectoryOnly);
|
||||||
if (files.Length != 1)
|
if (files.Length != 1)
|
||||||
keyValuePairs = new();
|
keyValuePairs = new();
|
||||||
@ -132,13 +105,11 @@ public class MapLogic
|
|||||||
_SkipCollection = skipCollection;
|
_SkipCollection = skipCollection;
|
||||||
_NotMappedPersonKeys = notMappedTicks;
|
_NotMappedPersonKeys = notMappedTicks;
|
||||||
_PeopleKeyValuePairs = peopleKeyValuePairs;
|
_PeopleKeyValuePairs = peopleKeyValuePairs;
|
||||||
_SixCharacterNamedFaceInfo = sixCharacterNamedFaceInfo;
|
|
||||||
_ZPropertyHolderContentDirectory = zPropertyHolderContentDirectory;
|
_ZPropertyHolderContentDirectory = zPropertyHolderContentDirectory;
|
||||||
_ZPropertyHolderContentTicksDirectory = zPropertyHolderContentTicksDirectory;
|
_ZPropertyHolderContentTicksDirectory = zPropertyHolderContentTicksDirectory;
|
||||||
_ZPropertyHolderSingletonTicksDirectory = zPropertyHolderSingletonTicksDirectory;
|
_ZPropertyHolderSingletonTicksDirectory = zPropertyHolderSingletonTicksDirectory;
|
||||||
_IncorrectDeterministicHashCodeKeyValuePairs = incorrectDeterministicHashCodeKeyValuePairs;
|
|
||||||
_IdThenNormalizedPixelPercentageKeyValuePairs = idThenNormalizedPixelPercentageKeyValuePairs;
|
_IdThenNormalizedPixelPercentageKeyValuePairs = idThenNormalizedPixelPercentageKeyValuePairs;
|
||||||
_DeterministicHashCodeUnknownFaceKeyValuePairs = deterministicHashCodeUnknownFaceKeyValuePairs;
|
_IncorrectIdThenNormalizedPixelPercentageKeyValuePairs = incorrectIdThenNormalizedPixelPercentageKeyValuePairs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MapLogic(int maxDegreeOfParallelism, Configuration configuration, string outputExtension, long ticks, Person[] people, string peopleDateGroupDirectory, string zResultsFullGroupDirectory) :
|
public MapLogic(int maxDegreeOfParallelism, Configuration configuration, string outputExtension, long ticks, Person[] people, string peopleDateGroupDirectory, string zResultsFullGroupDirectory) :
|
||||||
@ -220,27 +191,31 @@ public class MapLogic
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SaveShortcuts(string[] juliePhares, Item[] filteredItems)
|
public void SaveShortcuts(string[] juliePhares, List<Face> distinctFilteredFaces)
|
||||||
{
|
{
|
||||||
string fileName;
|
string fileName;
|
||||||
string fullName;
|
string fullName;
|
||||||
DateTime minimumDateTime;
|
|
||||||
string personKeyFormatted;
|
string personKeyFormatted;
|
||||||
PersonBirthday personBirthday;
|
PersonBirthday personBirthday;
|
||||||
WindowsShortcut windowsShortcut;
|
WindowsShortcut windowsShortcut;
|
||||||
(string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] PersonBirthdays, long PersonKey) person;
|
(string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] PersonBirthdays, long PersonKey) person;
|
||||||
List<(Item, (long?, Face?, (string, string, string, string))[])> collections = GetCollection(filteredItems);
|
List<(Face, long?, (string, string, string, string))> collection = GetCollection(distinctFilteredFaces);
|
||||||
foreach ((Item item, (long? personKey, Face? _, (string, string, string, string))[] collection) in collections)
|
foreach ((Face face, long? personKey, (string directory, string copyDirectory, string copyFileName, string shortcutFileName)) in collection)
|
||||||
{
|
|
||||||
if (collection.Length != 1)
|
|
||||||
continue;
|
|
||||||
foreach ((long? personKey, Face? _, (string directory, string copyDirectory, string copyFileName, string shortcutFileName)) in collection)
|
|
||||||
{
|
{
|
||||||
if (personKey is null)
|
if (personKey is null)
|
||||||
continue;
|
continue;
|
||||||
if (item.Property?.Id is null || item.ImageFileHolder is null || item.ResizedFileHolder is null)
|
if (face.Mapping is null)
|
||||||
continue;
|
throw new NotSupportedException();
|
||||||
minimumDateTime = IProperty.GetMinimumDateTime(item.Property);
|
personBirthday = IPersonBirthday.GetPersonBirthday(personKey.Value);
|
||||||
|
personKeyFormatted = IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, personBirthday);
|
||||||
|
if (juliePhares.Contains(personKeyFormatted) && !string.IsNullOrEmpty(copyDirectory))
|
||||||
|
{
|
||||||
|
if (!Directory.Exists(copyDirectory))
|
||||||
|
_ = Directory.CreateDirectory(copyDirectory);
|
||||||
|
fileName = Path.Combine(copyDirectory, $"{face.Mapping.MappingFromItem.Id}{face.Mapping.MappingFromItem.ResizedFileHolder.ExtensionLowered}");
|
||||||
|
if (!File.Exists(fileName))
|
||||||
|
File.Copy(face.Mapping.MappingFromItem.ResizedFileHolder.FullName, fileName);
|
||||||
|
}
|
||||||
if (!Directory.Exists(directory))
|
if (!Directory.Exists(directory))
|
||||||
{
|
{
|
||||||
_ = Directory.CreateDirectory(directory);
|
_ = Directory.CreateDirectory(directory);
|
||||||
@ -251,28 +226,15 @@ public class MapLogic
|
|||||||
File.WriteAllText(Path.Combine(directory, fullName), string.Empty);
|
File.WriteAllText(Path.Combine(directory, fullName), string.Empty);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (personKey is null)
|
fileName = Path.Combine(directory, $"{face.Mapping.MappingFromItem.Id}.lnk");
|
||||||
continue;
|
|
||||||
personBirthday = IPersonBirthday.GetPersonBirthday(personKey.Value);
|
|
||||||
personKeyFormatted = IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, personBirthday);
|
|
||||||
if (juliePhares.Contains(personKeyFormatted) && !string.IsNullOrEmpty(copyDirectory))
|
|
||||||
{
|
|
||||||
if (!Directory.Exists(copyDirectory))
|
|
||||||
_ = Directory.CreateDirectory(copyDirectory);
|
|
||||||
fileName = Path.Combine(copyDirectory, $"{item.Property.Id.Value}{item.ResizedFileHolder.ExtensionLowered}");
|
|
||||||
if (!File.Exists(fileName))
|
|
||||||
File.Copy(item.ResizedFileHolder.FullName, fileName);
|
|
||||||
}
|
|
||||||
fileName = Path.Combine(directory, $"{item.Property.Id.Value}.lnk");
|
|
||||||
if (File.Exists(fileName))
|
if (File.Exists(fileName))
|
||||||
continue;
|
continue;
|
||||||
windowsShortcut = new() { Path = item.ResizedFileHolder.FullName };
|
windowsShortcut = new() { Path = face.Mapping.MappingFromItem.ResizedFileHolder.FullName };
|
||||||
windowsShortcut.Save(fileName);
|
windowsShortcut.Save(fileName);
|
||||||
windowsShortcut.Dispose();
|
windowsShortcut.Dispose();
|
||||||
if (!File.Exists(fileName))
|
if (!File.Exists(fileName))
|
||||||
continue;
|
continue;
|
||||||
File.SetLastWriteTime(fileName, minimumDateTime);
|
File.SetLastWriteTime(fileName, face.Mapping.MappingFromItem.MinimumDateTime);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -281,7 +243,7 @@ public class MapLogic
|
|||||||
Dictionary<long, long> personKeyAliases = new();
|
Dictionary<long, long> personKeyAliases = new();
|
||||||
Dictionary<int, List<Face>> keyValuePairs = new();
|
Dictionary<int, List<Face>> keyValuePairs = new();
|
||||||
List<(PersonBirthday, int, int)> idThenNormalizedPixelPercentageCollection = new();
|
List<(PersonBirthday, int, int)> idThenNormalizedPixelPercentageCollection = new();
|
||||||
List<(PersonBirthday PersonBirthday, double IdAndNormalizedPixelPercentage)> incorrectDeterministicHashCodeCollection = new();
|
List<(PersonBirthday, int, int)> incorrectIdThenNormalizedPixelPercentageCollection = new();
|
||||||
foreach (SortingContainer sortingContainer in sortingContainers)
|
foreach (SortingContainer sortingContainer in sortingContainers)
|
||||||
{
|
{
|
||||||
if (sortingContainer.Face.FaceEncoding is null || sortingContainer.Face.Location?.NormalizedPixelPercentage is null)
|
if (sortingContainer.Face.FaceEncoding is null || sortingContainer.Face.Location?.NormalizedPixelPercentage is null)
|
||||||
@ -292,7 +254,7 @@ public class MapLogic
|
|||||||
keyValuePairs.Add(sortingContainer.Face.Mapping.MappingFromItem.Id, new());
|
keyValuePairs.Add(sortingContainer.Face.Mapping.MappingFromItem.Id, new());
|
||||||
keyValuePairs[sortingContainer.Face.Mapping.MappingFromItem.Id].Add(sortingContainer.Face);
|
keyValuePairs[sortingContainer.Face.Mapping.MappingFromItem.Id].Add(sortingContainer.Face);
|
||||||
}
|
}
|
||||||
Stateless.ByDeterministicHashCode.SetCollections(maxDegreeOfParallelism, _Ticks, _ZPropertyHolderContentDirectory, personKeyAliases, idThenNormalizedPixelPercentageCollection, incorrectDeterministicHashCodeCollection, keyValuePairs);
|
Stateless.ByDeterministicHashCode.SetCollections(maxDegreeOfParallelism, _Ticks, _ZPropertyHolderContentDirectory, personKeyAliases, idThenNormalizedPixelPercentageCollection, incorrectIdThenNormalizedPixelPercentageCollection, keyValuePairs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetMappingSegmentB(long ticks, PersonBirthday personBirthday, int? approximateYears, long minimumDateTimeTicks, bool? isWrongYear)
|
private static string GetMappingSegmentB(long ticks, PersonBirthday personBirthday, int? approximateYears, long minimumDateTimeTicks, bool? isWrongYear)
|
||||||
@ -359,7 +321,6 @@ public class MapLogic
|
|||||||
|
|
||||||
private int AddToMapping(List<Face> distinctFilteredFaces)
|
private int AddToMapping(List<Face> distinctFilteredFaces)
|
||||||
{
|
{
|
||||||
int by;
|
|
||||||
int result = 0;
|
int result = 0;
|
||||||
long personKey;
|
long personKey;
|
||||||
const int zero = 0;
|
const int zero = 0;
|
||||||
@ -370,13 +331,11 @@ public class MapLogic
|
|||||||
PersonBirthday personBirthday;
|
PersonBirthday personBirthday;
|
||||||
List<PersonBirthday> personBirthdays = new();
|
List<PersonBirthday> personBirthdays = new();
|
||||||
Dictionary<int, PersonBirthday[]> keyValuePairs;
|
Dictionary<int, PersonBirthday[]> keyValuePairs;
|
||||||
|
int by = Shared.Models.Stateless.ISorting.Mapping;
|
||||||
(string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] PersonBirthdays, long PersonKey) person;
|
(string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] PersonBirthdays, long PersonKey) person;
|
||||||
foreach (Face face in distinctFilteredFaces)
|
foreach (Face face in distinctFilteredFaces)
|
||||||
{
|
{
|
||||||
by = 2;
|
|
||||||
personBirthdays.Clear();
|
personBirthdays.Clear();
|
||||||
if (face.Mapping is null)
|
|
||||||
throw new NotSupportedException();
|
|
||||||
if (face.Mapping is null)
|
if (face.Mapping is null)
|
||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
if (!_IdThenNormalizedPixelPercentageKeyValuePairs.ContainsKey(face.Mapping.MappingFromItem.Id))
|
if (!_IdThenNormalizedPixelPercentageKeyValuePairs.ContainsKey(face.Mapping.MappingFromItem.Id))
|
||||||
@ -402,23 +361,6 @@ public class MapLogic
|
|||||||
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);
|
||||||
}
|
}
|
||||||
if (!Shared.Models.Stateless.IMapping.UseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping || !_DeterministicHashCodeUnknownFaceKeyValuePairs.ContainsKey(face.Mapping.MappingFromItem.Id))
|
|
||||||
continue;
|
|
||||||
by = 1;
|
|
||||||
personBirthdays.AddRange(_DeterministicHashCodeUnknownFaceKeyValuePairs[face.Mapping.MappingFromItem.Id]);
|
|
||||||
for (int i = 0; i < personBirthdays.Count; i++)
|
|
||||||
{
|
|
||||||
personKey = personBirthdays[i].Value.Ticks;
|
|
||||||
if (!_PeopleKeyValuePairs.ContainsKey(personKey))
|
|
||||||
continue;
|
|
||||||
person = _PeopleKeyValuePairs[personKey];
|
|
||||||
approximateYears = person.ApproximateYears;
|
|
||||||
personBirthday = person.PersonBirthdays[zero];
|
|
||||||
displayDirectoryName = person.DisplayDirectoryName;
|
|
||||||
personKeyFormatted = IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, personBirthday);
|
|
||||||
mappingSegmentB = GetMappingSegmentB(_Ticks, personBirthday, approximateYears, face.Mapping.MappingFromItem);
|
|
||||||
face.Mapping.UpdateMappingFromPerson(approximateYears, by, displayDirectoryName, personBirthday, mappingSegmentB);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -498,15 +440,12 @@ public class MapLogic
|
|||||||
SaveContainers(saveContainers);
|
SaveContainers(saveContainers);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<(Item, (long?, Face?, (string, string, string, string))[])> GetCollection(Item[] filteredItems)
|
public List<(Face, long?, (string, string, string, string))> GetCollection(List<Face> distinctFilteredFaces)
|
||||||
{
|
{
|
||||||
List<(Item, (long?, Face?, (string, string, string, string))[])> results = new();
|
List<(Face, long?, (string, string, string, string))> results = new();
|
||||||
int years;
|
int years;
|
||||||
Face face;
|
|
||||||
Item item;
|
|
||||||
long? personKey;
|
long? personKey;
|
||||||
string directory;
|
string directory;
|
||||||
bool? isWrongYear;
|
|
||||||
const int zero = 0;
|
const int zero = 0;
|
||||||
TimeSpan? timeSpan;
|
TimeSpan? timeSpan;
|
||||||
string copyFileName;
|
string copyFileName;
|
||||||
@ -515,63 +454,43 @@ public class MapLogic
|
|||||||
string isWrongYearFlag;
|
string isWrongYearFlag;
|
||||||
string shortcutFileName;
|
string shortcutFileName;
|
||||||
string subDirectoryName;
|
string subDirectoryName;
|
||||||
DateTime minimumDateTime;
|
|
||||||
List<int> indices = new();
|
|
||||||
List<Face> faceCollection;
|
|
||||||
string personKeyFormatted;
|
string personKeyFormatted;
|
||||||
PersonBirthday personBirthday;
|
PersonBirthday personBirthday;
|
||||||
PersonBirthday[] personBirthdays;
|
PersonBirthday[] personBirthdays;
|
||||||
DateTime dateTime = DateTime.Now;
|
DateTime dateTime = DateTime.Now;
|
||||||
List<(long?, Face?, (string, string, string, string))> collection;
|
Dictionary<int, PersonBirthday[]> keyValuePairs;
|
||||||
for (int i = 0; i < filteredItems.Length; i++)
|
foreach (Face face in distinctFilteredFaces)
|
||||||
{
|
{
|
||||||
indices.Clear();
|
if (face.Mapping is null)
|
||||||
|
throw new NotSupportedException();
|
||||||
copyFileName = string.Empty;
|
copyFileName = string.Empty;
|
||||||
copyDirectory = string.Empty;
|
copyDirectory = string.Empty;
|
||||||
item = filteredItems[i];
|
relativePath = Path.GetDirectoryName($"C:{face.RelativePath}");
|
||||||
if (item.ImageFileHolder is null)
|
|
||||||
continue;
|
|
||||||
relativePath = Path.GetDirectoryName($"C:{item.RelativePath}");
|
|
||||||
if (string.IsNullOrEmpty(relativePath) || relativePath.Length < 3)
|
if (string.IsNullOrEmpty(relativePath) || relativePath.Length < 3)
|
||||||
continue;
|
continue;
|
||||||
if (item.Property?.Id is null || item.ImageFileHolder is null || item.ResizedFileHolder is null)
|
if (!_IdThenNormalizedPixelPercentageKeyValuePairs.ContainsKey(face.Mapping.MappingFromItem.Id))
|
||||||
continue;
|
|
||||||
collection = new();
|
|
||||||
if (!_DeterministicHashCodeUnknownFaceKeyValuePairs.ContainsKey(item.Property.Id.Value))
|
|
||||||
{
|
{
|
||||||
faceCollection = new();
|
|
||||||
personKey = null;
|
personKey = null;
|
||||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"Unnamed{relativePath[2..]}");
|
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"Unnamed{relativePath[2..]}");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
faceCollection = item.Faces;
|
keyValuePairs = _IdThenNormalizedPixelPercentageKeyValuePairs[face.Mapping.MappingFromItem.Id];
|
||||||
personBirthdays = _DeterministicHashCodeUnknownFaceKeyValuePairs[item.Property.Id.Value];
|
if (!keyValuePairs.ContainsKey(face.Mapping.MappingFromLocation.NormalizedPixelPercentage))
|
||||||
minimumDateTime = IProperty.GetMinimumDateTime(item.Property);
|
throw new NotSupportedException();
|
||||||
(isWrongYear, _) = item.Property.IsWrongYear(item.ImageFileHolder.FullName, minimumDateTime);
|
personBirthdays = keyValuePairs[face.Mapping.MappingFromLocation.NormalizedPixelPercentage];
|
||||||
isWrongYearFlag = IItem.GetWrongYearFlag(isWrongYear);
|
isWrongYearFlag = IItem.GetWrongYearFlag(face.Mapping.MappingFromItem.IsWrongYear);
|
||||||
subDirectoryName = $"{isWrongYearFlag}{minimumDateTime:yyyy}";
|
subDirectoryName = $"{isWrongYearFlag}{face.Mapping.MappingFromItem.MinimumDateTime:yyyy}";
|
||||||
if (!faceCollection.Any())
|
if (personBirthdays.Length != 1)
|
||||||
{
|
|
||||||
personKey = null;
|
|
||||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"None{relativePath[2..]}", subDirectoryName);
|
|
||||||
}
|
|
||||||
else if (personBirthdays.Length != 1)
|
|
||||||
{
|
{
|
||||||
personKey = null;
|
personKey = null;
|
||||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"Not Supported{relativePath[2..]}", subDirectoryName);
|
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"Not Supported{relativePath[2..]}", subDirectoryName);
|
||||||
}
|
}
|
||||||
else if (faceCollection.Count != 1)
|
|
||||||
{
|
|
||||||
personKey = null;
|
|
||||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, $"Many{relativePath[2..]}", subDirectoryName);
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
indices.Add(zero);
|
|
||||||
personBirthday = personBirthdays[zero];
|
personBirthday = personBirthdays[zero];
|
||||||
personKey = personBirthday.Value.Ticks;
|
personKey = personBirthday.Value.Ticks;
|
||||||
timeSpan = IPersonBirthday.GetTimeSpan(minimumDateTime, isWrongYear, personBirthday);
|
timeSpan = IPersonBirthday.GetTimeSpan(face.Mapping.MappingFromItem.MinimumDateTime, face.Mapping.MappingFromItem.IsWrongYear, personBirthday);
|
||||||
if (timeSpan.HasValue)
|
if (timeSpan.HasValue)
|
||||||
{
|
{
|
||||||
if (timeSpan.Value.Ticks < 0)
|
if (timeSpan.Value.Ticks < 0)
|
||||||
@ -582,51 +501,24 @@ public class MapLogic
|
|||||||
subDirectoryName = $"^{years:000}";
|
subDirectoryName = $"^{years:000}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
face = faceCollection[zero];
|
|
||||||
personKeyFormatted = IPersonBirthday.GetFormatted(Shared.Models.Stateless.IPersonBirthday.Format, 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);
|
||||||
else
|
else
|
||||||
copyDirectory = Path.Combine(_ZPropertyHolderContentTicksDirectory, "ImagesBut", personKeyFormatted, subDirectoryName);
|
copyDirectory = Path.Combine(_ZPropertyHolderContentTicksDirectory, "ImagesBut", personKeyFormatted, subDirectoryName);
|
||||||
copyFileName = Path.Combine(copyDirectory, $"{item.Property.Id.Value}{item.ResizedFileHolder.ExtensionLowered}");
|
copyFileName = Path.Combine(copyDirectory, $"{face.Mapping.MappingFromItem.Id}{face.Mapping.MappingFromItem.ResizedFileHolder.ExtensionLowered}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
shortcutFileName = Path.Combine(directory, $"{item.Property.Id.Value}.lnk");
|
shortcutFileName = Path.Combine(directory, $"{face.Mapping.MappingFromItem.Id}.lnk");
|
||||||
if (personKey is null || !indices.Any())
|
if (personKey is null)
|
||||||
collection.Add(new(personKey, null, (directory, copyDirectory, copyFileName, shortcutFileName)));
|
results.Add(new(face, null, (directory, copyDirectory, copyFileName, shortcutFileName)));
|
||||||
else
|
else
|
||||||
{
|
results.Add(new(face, personKey, (directory, copyDirectory, copyFileName, shortcutFileName)));
|
||||||
foreach (int index in indices)
|
|
||||||
collection.Add(new(personKey, faceCollection[index], (directory, copyDirectory, copyFileName, shortcutFileName)));
|
|
||||||
}
|
|
||||||
results.Add(new(item, collection.ToArray()));
|
|
||||||
}
|
}
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SavePropertyHolders(Item[] items)
|
|
||||||
{
|
|
||||||
string json;
|
|
||||||
FileInfo fileInfo;
|
|
||||||
bool updateDateWhenMatches = false;
|
|
||||||
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
|
|
||||||
foreach (Item item in items)
|
|
||||||
{
|
|
||||||
if (item.Property?.Id is null || item.ImageFileHolder is null || item.ResizedFileHolder is null)
|
|
||||||
continue;
|
|
||||||
if (!item.Faces.Any())
|
|
||||||
continue;
|
|
||||||
json = JsonSerializer.Serialize(item, jsonSerializerOptions);
|
|
||||||
fileInfo = new(Path.GetFullPath(string.Concat(_ZPropertyHolderSingletonTicksDirectory, item.RelativePath, ".json")));
|
|
||||||
if (fileInfo.Directory is null)
|
|
||||||
continue;
|
|
||||||
if (!fileInfo.Directory.Exists)
|
|
||||||
continue;
|
|
||||||
_ = IPath.WriteAllText(fileInfo.FullName, json, updateDateWhenMatches, compareBeforeWrite: true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Dictionary<int, Dictionary<int, Face>> Convert(List<(int Id, Face Face)> collection)
|
private static Dictionary<int, Dictionary<int, Face>> Convert(List<(int Id, Face Face)> collection)
|
||||||
{
|
{
|
||||||
Dictionary<int, Dictionary<int, Face>> results = new();
|
Dictionary<int, Dictionary<int, Face>> results = new();
|
||||||
@ -659,7 +551,6 @@ public class MapLogic
|
|||||||
Dictionary<int, HashSet<int>> results = new();
|
Dictionary<int, HashSet<int>> results = new();
|
||||||
string key;
|
string key;
|
||||||
long personKey;
|
long personKey;
|
||||||
const int by = 3;
|
|
||||||
const int zero = 0;
|
const int zero = 0;
|
||||||
HashSet<int> hashSet;
|
HashSet<int> hashSet;
|
||||||
string mappingSegmentB;
|
string mappingSegmentB;
|
||||||
@ -668,6 +559,7 @@ public class MapLogic
|
|||||||
PersonBirthday personBirthday;
|
PersonBirthday personBirthday;
|
||||||
PersonBirthday[] personBirthdays;
|
PersonBirthday[] personBirthdays;
|
||||||
Dictionary<int, PersonBirthday[]> keyValuePairs;
|
Dictionary<int, PersonBirthday[]> keyValuePairs;
|
||||||
|
const int by = Shared.Models.Stateless.ISorting.Sorting;
|
||||||
Dictionary<string, List<Mapping>> checkKeyValuePairs = new();
|
Dictionary<string, List<Mapping>> checkKeyValuePairs = 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 DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] PersonBirthdays, long PersonKey) person;
|
(string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] PersonBirthdays, long PersonKey) person;
|
||||||
@ -720,12 +612,12 @@ public class MapLogic
|
|||||||
|
|
||||||
internal void ForceSingleImage(IEnumerable<Face> distinctFilteredFaces)
|
internal void ForceSingleImage(IEnumerable<Face> distinctFilteredFaces)
|
||||||
{
|
{
|
||||||
int by = 4;
|
|
||||||
long? personKey;
|
long? personKey;
|
||||||
const int zero = 0;
|
const int zero = 0;
|
||||||
string mappingSegmentB;
|
string mappingSegmentB;
|
||||||
int? approximateYears = null;
|
int? approximateYears = null;
|
||||||
PersonBirthday personBirthday;
|
PersonBirthday personBirthday;
|
||||||
|
int by = Shared.Models.Stateless.ISorting.ForceSingleImage;
|
||||||
Face[] orderedDistinctFilteredFaces = (from l in distinctFilteredFaces orderby l.Mapping is not null, l.Mapping?.MappingFromLocation.Confidence descending select l).ToArray();
|
Face[] orderedDistinctFilteredFaces = (from l in distinctFilteredFaces orderby l.Mapping is not null, l.Mapping?.MappingFromLocation.Confidence descending select l).ToArray();
|
||||||
const string displayDirectoryName = Property.Models.Stateless.IResult.AllInOne;
|
const string displayDirectoryName = Property.Models.Stateless.IResult.AllInOne;
|
||||||
foreach (Face face in orderedDistinctFilteredFaces)
|
foreach (Face face in orderedDistinctFilteredFaces)
|
||||||
@ -774,26 +666,25 @@ public class MapLogic
|
|||||||
if (face.Mapping.MappingFromPerson.By is null)
|
if (face.Mapping.MappingFromPerson.By is null)
|
||||||
by = $"{nameof(Mapping)}Null";
|
by = $"{nameof(Mapping)}Null";
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (face.Mapping.MappingFromPerson.By == Shared.Models.Stateless.ISorting.Mapping && !Shared.Models.Stateless.IMapping.SaveMapped)
|
||||||
|
continue;
|
||||||
by = face.Mapping.MappingFromPerson.By.Value switch
|
by = face.Mapping.MappingFromPerson.By.Value switch
|
||||||
{
|
{
|
||||||
1 => "ByUnknownFaceKey",
|
Shared.Models.Stateless.ISorting.Mapping => nameof(Mapping),
|
||||||
2 => nameof(Mapping),
|
Shared.Models.Stateless.ISorting.Sorting => nameof(Sorting),
|
||||||
3 => nameof(Sorting),
|
Shared.Models.Stateless.ISorting.ForceSingleImage => nameof(MapLogic.ForceSingleImage),
|
||||||
4 => nameof(MapLogic.ForceSingleImage),
|
|
||||||
_ => throw new NotImplementedException()
|
_ => throw new NotImplementedException()
|
||||||
};
|
};
|
||||||
if (face.Mapping.MappingFromPerson.By is not null and not 2)
|
}
|
||||||
{
|
|
||||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, by, personKeyFormatted, face.Mapping.MappingFromPerson.SegmentB);
|
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, by, personKeyFormatted, face.Mapping.MappingFromPerson.SegmentB);
|
||||||
|
saveContainer = new(Path.Combine(directory, "!"));
|
||||||
|
if (face.Mapping.MappingFromPerson.By.HasValue && face.Mapping.MappingFromPerson.By == Shared.Models.Stateless.ISorting.Sorting)
|
||||||
|
results.Add(saveContainer);
|
||||||
|
if (face.Mapping.MappingFromPerson.By is not null)
|
||||||
personDirectory = Path.Combine(directory, face.Mapping.MappingFromPerson.DisplayDirectoryName, "lnk");
|
personDirectory = Path.Combine(directory, face.Mapping.MappingFromPerson.DisplayDirectoryName, "lnk");
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
directory = Path.Combine(_ZPropertyHolderContentTicksDirectory, by, personKeyFormatted, face.Mapping.MappingFromPerson.SegmentB);
|
|
||||||
personDirectory = Path.Combine(directory, face.Mapping.MappingFromPerson.DisplayDirectoryName[..1], "lnk");
|
personDirectory = Path.Combine(directory, face.Mapping.MappingFromPerson.DisplayDirectoryName[..1], "lnk");
|
||||||
if (face.Mapping.MappingFromPerson.By == 2 && !Shared.Models.Stateless.IMapping.SaveMapped)
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
saveContainer = new(personDirectory);
|
saveContainer = new(personDirectory);
|
||||||
results.Add(saveContainer);
|
results.Add(saveContainer);
|
||||||
facesDirectory = string.Concat(dFacesContentDirectory, Path.Combine(directoryName, face.Mapping.MappingFromItem.ImageFileHolder.NameWithoutExtension));
|
facesDirectory = string.Concat(dFacesContentDirectory, Path.Combine(directoryName, face.Mapping.MappingFromItem.ImageFileHolder.NameWithoutExtension));
|
||||||
@ -823,7 +714,7 @@ public class MapLogic
|
|||||||
public void CommonWork(int maxDegreeOfParallelism, string dFacesContentDirectory, string d2ResultsFullGroupDirectory, List<Face> distinctFilteredFaces, SortingContainer[] sortingContainers)
|
public void CommonWork(int maxDegreeOfParallelism, string dFacesContentDirectory, string d2ResultsFullGroupDirectory, List<Face> distinctFilteredFaces, SortingContainer[] sortingContainers)
|
||||||
{
|
{
|
||||||
List<SaveContainer> saveContainers;
|
List<SaveContainer> saveContainers;
|
||||||
if (_DeterministicHashCodeUnknownFaceKeyValuePairs.Any())
|
if (!_IdThenNormalizedPixelPercentageKeyValuePairs.Any())
|
||||||
UseKeyValuePairsSaveFaceEncoding(maxDegreeOfParallelism, sortingContainers);
|
UseKeyValuePairsSaveFaceEncoding(maxDegreeOfParallelism, sortingContainers);
|
||||||
int totalNotMapped = AddToMapping(distinctFilteredFaces);
|
int totalNotMapped = AddToMapping(distinctFilteredFaces);
|
||||||
if (totalNotMapped == 0)
|
if (totalNotMapped == 0)
|
||||||
|
@ -137,7 +137,7 @@ public class ByDeterministicHashCode
|
|||||||
peopleCollection.Add(new(displayDirectoryName, approximateYears, new PersonBirthday[] { personBirthday }, personKey));
|
peopleCollection.Add(new(displayDirectoryName, approximateYears, new PersonBirthday[] { personBirthday }, personKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
internal static void SetCollections(int maxDegreeOfParallelism, long ticks, string zPropertyHolderContentDirectory, Dictionary<long, long> personKeyAliases, List<(PersonBirthday, int, int)> idThenNormalizedPixelPercentageCollection, List<(PersonBirthday, double)> incorrectDeterministicHashCodeCollection, Dictionary<int, List<Face>> keyValuePairs)
|
internal static void SetCollections(int maxDegreeOfParallelism, long ticks, string zPropertyHolderContentDirectory, Dictionary<long, long> personKeyAliases, List<(PersonBirthday, int, int)> idThenNormalizedPixelPercentageCollection, List<(PersonBirthday, int, int)> incorrectIdThenNormalizedPixelPercentageCollection, Dictionary<int, List<Face>> keyValuePairs)
|
||||||
{
|
{
|
||||||
int? id;
|
int? id;
|
||||||
string[] files;
|
string[] files;
|
||||||
@ -211,7 +211,10 @@ public class ByDeterministicHashCode
|
|||||||
(id, normalizedPixelPercentage) = Shared.Models.Stateless.Methods.IMapping.GetReversedDeterministicHashCodeKey(Shared.Models.Stateless.ILocation.Digits, 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;
|
||||||
|
if (personFirstInitial != "!")
|
||||||
idThenNormalizedPixelPercentageCollection.Add(new(personBirthday, id.Value, normalizedPixelPercentage.Value));
|
idThenNormalizedPixelPercentageCollection.Add(new(personBirthday, id.Value, normalizedPixelPercentage.Value));
|
||||||
|
else
|
||||||
|
incorrectIdThenNormalizedPixelPercentageCollection.Add(new(personBirthday, id.Value, normalizedPixelPercentage.Value));
|
||||||
}
|
}
|
||||||
personNameLinkDirectories = Directory.GetDirectories(personNameDirectory, "*", SearchOption.TopDirectoryOnly);
|
personNameLinkDirectories = Directory.GetDirectories(personNameDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
foreach (string personNameLinkDirectory in personNameLinkDirectories)
|
foreach (string personNameLinkDirectory in personNameLinkDirectories)
|
||||||
@ -239,36 +242,11 @@ public class ByDeterministicHashCode
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<long> GetPersonKeys(Dictionary<int, PersonBirthday[]> deterministicHashCodeUnknownFaceKeyValuePairs)
|
private static void SetKeyValuePairs(List<(PersonBirthday, int, int)> idThenNormalizedPixelPercentageCollection, List<(PersonBirthday, int, int)> incorrectIdThenNormalizedPixelPercentageCollection, Dictionary<int, Dictionary<int, PersonBirthday[]>> idThenNormalizedPixelPercentageKeyValuePairs, Dictionary<int, Dictionary<int, PersonBirthday[]>> incorrectIdThenNormalizedPixelPercentageKeyValuePairs)
|
||||||
{
|
{
|
||||||
List<long> results = new();
|
|
||||||
long personKey;
|
|
||||||
foreach (KeyValuePair<int, PersonBirthday[]> keyValuePair in deterministicHashCodeUnknownFaceKeyValuePairs)
|
|
||||||
{
|
|
||||||
foreach (PersonBirthday personBirthday in keyValuePair.Value)
|
|
||||||
{
|
|
||||||
personKey = personBirthday.Value.Ticks;
|
|
||||||
results.Add(personKey);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
results = results.Distinct().ToList();
|
|
||||||
return results;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void SetKeyValuePairs(List<(PersonBirthday, int, int)> idThenNormalizedPixelPercentageCollection, List<(PersonBirthday PersonBirthday, double IdAndNormalizedPixelPercentage)> incorrectDeterministicHashCodeCollection, Dictionary<double, PersonBirthday[]> incorrectDeterministicHashCodeKeyValuePairs, Dictionary<int, Dictionary<int, PersonBirthday[]>> idThenNormalizedPixelPercentageKeyValuePairs)
|
|
||||||
{
|
|
||||||
Dictionary<double, List<PersonBirthday>> incorrectDeterministicHashCodeScope = new();
|
|
||||||
Dictionary<int, Dictionary<int, List<PersonBirthday>>> idThenNormalizedPixelPercentageScope = new();
|
|
||||||
foreach ((PersonBirthday personBirthday, double idAndNormalizedPixelPercentage) in incorrectDeterministicHashCodeCollection)
|
|
||||||
{
|
|
||||||
if (!incorrectDeterministicHashCodeScope.ContainsKey(idAndNormalizedPixelPercentage))
|
|
||||||
incorrectDeterministicHashCodeScope.Add(idAndNormalizedPixelPercentage, new());
|
|
||||||
incorrectDeterministicHashCodeScope[idAndNormalizedPixelPercentage].Add(personBirthday);
|
|
||||||
}
|
|
||||||
foreach (KeyValuePair<double, List<PersonBirthday>> keyValuePair in incorrectDeterministicHashCodeScope)
|
|
||||||
incorrectDeterministicHashCodeKeyValuePairs.Add(keyValuePair.Key, keyValuePair.Value.Distinct().ToArray());
|
|
||||||
string check;
|
string check;
|
||||||
int normalizedPixelPercentageInDecimalForm;
|
int normalizedPixelPercentageInDecimalForm;
|
||||||
|
Dictionary<int, Dictionary<int, List<PersonBirthday>>> idThenNormalizedPixelPercentageScope = new();
|
||||||
foreach ((PersonBirthday personBirthday, int id, int normalizedPixelPercentage) in idThenNormalizedPixelPercentageCollection)
|
foreach ((PersonBirthday personBirthday, int id, int normalizedPixelPercentage) in idThenNormalizedPixelPercentageCollection)
|
||||||
{
|
{
|
||||||
if (!idThenNormalizedPixelPercentageScope.ContainsKey(id))
|
if (!idThenNormalizedPixelPercentageScope.ContainsKey(id))
|
||||||
@ -294,30 +272,51 @@ public class ByDeterministicHashCode
|
|||||||
foreach (KeyValuePair<int, List<PersonBirthday>> innerKeyValuePair in keyValuePair.Value)
|
foreach (KeyValuePair<int, List<PersonBirthday>> innerKeyValuePair in keyValuePair.Value)
|
||||||
idThenNormalizedPixelPercentageKeyValuePairs[keyValuePair.Key].Add(innerKeyValuePair.Key, innerKeyValuePair.Value.Distinct().ToArray());
|
idThenNormalizedPixelPercentageKeyValuePairs[keyValuePair.Key].Add(innerKeyValuePair.Key, innerKeyValuePair.Value.Distinct().ToArray());
|
||||||
}
|
}
|
||||||
|
Dictionary<int, Dictionary<int, List<PersonBirthday>>> incorrectIdThenNormalizedPixelPercentageScope = new();
|
||||||
|
foreach ((PersonBirthday personBirthday, int id, int normalizedPixelPercentage) in incorrectIdThenNormalizedPixelPercentageCollection)
|
||||||
|
{
|
||||||
|
if (!incorrectIdThenNormalizedPixelPercentageScope.ContainsKey(id))
|
||||||
|
incorrectIdThenNormalizedPixelPercentageScope.Add(id, new());
|
||||||
|
check = normalizedPixelPercentage.ToString();
|
||||||
|
if (check.Length == Shared.Models.Stateless.ILocation.Digits)
|
||||||
|
{
|
||||||
|
if (!incorrectIdThenNormalizedPixelPercentageScope[id].ContainsKey(normalizedPixelPercentage))
|
||||||
|
incorrectIdThenNormalizedPixelPercentageScope[id].Add(normalizedPixelPercentage, new());
|
||||||
|
incorrectIdThenNormalizedPixelPercentageScope[id][normalizedPixelPercentage].Add(personBirthday);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
normalizedPixelPercentageInDecimalForm = int.Parse(check.PadRight(Shared.Models.Stateless.ILocation.Digits, '0'));
|
||||||
|
if (!incorrectIdThenNormalizedPixelPercentageScope[id].ContainsKey(normalizedPixelPercentageInDecimalForm))
|
||||||
|
incorrectIdThenNormalizedPixelPercentageScope[id].Add(normalizedPixelPercentageInDecimalForm, new());
|
||||||
|
incorrectIdThenNormalizedPixelPercentageScope[id][normalizedPixelPercentageInDecimalForm].Add(personBirthday);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
foreach (KeyValuePair<int, Dictionary<int, List<PersonBirthday>>> keyValuePair in incorrectIdThenNormalizedPixelPercentageScope)
|
||||||
|
{
|
||||||
|
incorrectIdThenNormalizedPixelPercentageKeyValuePairs.Add(keyValuePair.Key, new());
|
||||||
|
foreach (KeyValuePair<int, List<PersonBirthday>> innerKeyValuePair in keyValuePair.Value)
|
||||||
|
incorrectIdThenNormalizedPixelPercentageKeyValuePairs[keyValuePair.Key].Add(innerKeyValuePair.Key, innerKeyValuePair.Value.Distinct().ToArray());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void SetByRef(int maxDegreeOfParallelism, long ticks, string resizeFilenameExtension, Person[] people, List<double> skipCollection, Dictionary<long, (string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] PersonBirthdays, long PersonKey)> peopleKeyValuePairs, List<long> notMappedPersonKeys, Dictionary<int, PersonBirthday[]> deterministicHashCodeUnknownFaceKeyValuePairs, Dictionary<int, Dictionary<int, PersonBirthday[]>> idThenNormalizedPixelPercentageKeyValuePairs, Dictionary<double, PersonBirthday[]> incorrectDeterministicHashCodeKeyValuePairs, string zPropertyHolderContentDirectory, string zPropertyHolderPeopleContentDirectory)
|
internal static void SetByRef(int maxDegreeOfParallelism, long ticks, string resizeFilenameExtension, Person[] people, List<double> skipCollection, Dictionary<long, (string DisplayDirectoryName, int? ApproximateYears, PersonBirthday[] PersonBirthdays, long PersonKey)> peopleKeyValuePairs, List<long> notMappedPersonKeys, Dictionary<int, Dictionary<int, PersonBirthday[]>> idThenNormalizedPixelPercentageKeyValuePairs, Dictionary<int, Dictionary<int, PersonBirthday[]>> incorrectIdThenNormalizedPixelPercentageKeyValuePairs, string zPropertyHolderContentDirectory, string zPropertyHolderPeopleContentDirectory)
|
||||||
{
|
{
|
||||||
Dictionary<long, long> personKeyAliases = new();
|
Dictionary<long, long> personKeyAliases = new();
|
||||||
Dictionary<int, List<Face>> keyValuePairs = new();
|
Dictionary<int, List<Face>> keyValuePairs = new();
|
||||||
List<long> idThenNormalizedPixelPercentagePersonKeys = new();
|
List<long> idThenNormalizedPixelPercentagePersonKeys = new();
|
||||||
List<(string, int?, PersonBirthday[], long)> peopleCollection = new();
|
List<(string, int?, PersonBirthday[], long)> peopleCollection = new();
|
||||||
List<(PersonBirthday, int, int)> idThenNormalizedPixelPercentageCollection = new();
|
List<(PersonBirthday, int, int)> idThenNormalizedPixelPercentageCollection = new();
|
||||||
List<long> deterministicHashCodeUnknownFacePersonKeys = GetPersonKeys(deterministicHashCodeUnknownFaceKeyValuePairs);
|
List<(PersonBirthday, int, int)> incorrectIdThenNormalizedPixelPercentageCollection = new();
|
||||||
List<(PersonBirthday PersonBirthday, double IdAndNormalizedPixelPercentage)> incorrectDeterministicHashCodeCollection = new();
|
|
||||||
SetOther(resizeFilenameExtension, people, zPropertyHolderPeopleContentDirectory, skipCollection, personKeyAliases, peopleCollection);
|
SetOther(resizeFilenameExtension, people, zPropertyHolderPeopleContentDirectory, skipCollection, personKeyAliases, peopleCollection);
|
||||||
SetCollections(maxDegreeOfParallelism, ticks, zPropertyHolderContentDirectory, personKeyAliases, idThenNormalizedPixelPercentageCollection, incorrectDeterministicHashCodeCollection, keyValuePairs);
|
SetCollections(maxDegreeOfParallelism, ticks, zPropertyHolderContentDirectory, personKeyAliases, idThenNormalizedPixelPercentageCollection, incorrectIdThenNormalizedPixelPercentageCollection, keyValuePairs);
|
||||||
SetKeyValuePairs(idThenNormalizedPixelPercentageCollection, incorrectDeterministicHashCodeCollection, incorrectDeterministicHashCodeKeyValuePairs, idThenNormalizedPixelPercentageKeyValuePairs);
|
SetKeyValuePairs(idThenNormalizedPixelPercentageCollection, incorrectIdThenNormalizedPixelPercentageCollection, idThenNormalizedPixelPercentageKeyValuePairs, incorrectIdThenNormalizedPixelPercentageKeyValuePairs);
|
||||||
incorrectDeterministicHashCodeCollection = (from l in incorrectDeterministicHashCodeCollection orderby l.IdAndNormalizedPixelPercentage select l).ToList();
|
|
||||||
foreach (KeyValuePair<int, Dictionary<int, PersonBirthday[]>> keyValuePair in idThenNormalizedPixelPercentageKeyValuePairs)
|
foreach (KeyValuePair<int, Dictionary<int, PersonBirthday[]>> keyValuePair in idThenNormalizedPixelPercentageKeyValuePairs)
|
||||||
{
|
{
|
||||||
foreach (KeyValuePair<int, PersonBirthday[]> keyValue in keyValuePair.Value)
|
foreach (KeyValuePair<int, PersonBirthday[]> keyValue in keyValuePair.Value)
|
||||||
idThenNormalizedPixelPercentagePersonKeys.AddRange(from l in keyValue.Value select l.Value.Ticks);
|
idThenNormalizedPixelPercentagePersonKeys.AddRange(from l in keyValue.Value select l.Value.Ticks);
|
||||||
}
|
}
|
||||||
idThenNormalizedPixelPercentagePersonKeys = idThenNormalizedPixelPercentagePersonKeys.Distinct().ToList();
|
idThenNormalizedPixelPercentagePersonKeys = idThenNormalizedPixelPercentagePersonKeys.Distinct().ToList();
|
||||||
foreach (KeyValuePair<int, PersonBirthday[]> keyValuePair in deterministicHashCodeUnknownFaceKeyValuePairs)
|
|
||||||
deterministicHashCodeUnknownFacePersonKeys.AddRange(from l in keyValuePair.Value select l.Value.Ticks);
|
|
||||||
deterministicHashCodeUnknownFacePersonKeys = deterministicHashCodeUnknownFacePersonKeys.Distinct().ToList();
|
|
||||||
if (peopleCollection.Any())
|
if (peopleCollection.Any())
|
||||||
{
|
{
|
||||||
foreach ((string displayDirectoryName, int? approximateYears, PersonBirthday[] personBirthdays, long personKey) in peopleCollection)
|
foreach ((string displayDirectoryName, int? approximateYears, PersonBirthday[] personBirthdays, long personKey) in peopleCollection)
|
||||||
@ -328,25 +327,17 @@ public class ByDeterministicHashCode
|
|||||||
continue;
|
continue;
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
if (!deterministicHashCodeUnknownFacePersonKeys.Contains(personKey) && !idThenNormalizedPixelPercentagePersonKeys.Contains(personKey))
|
if (!idThenNormalizedPixelPercentagePersonKeys.Contains(personKey))
|
||||||
notMappedPersonKeys.Add(personKey);
|
notMappedPersonKeys.Add(personKey);
|
||||||
else
|
else
|
||||||
peopleKeyValuePairs.Add(personKey, new(displayDirectoryName, approximateYears, personBirthdays, personKey));
|
peopleKeyValuePairs.Add(personKey, new(displayDirectoryName, approximateYears, personBirthdays, personKey));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (deterministicHashCodeUnknownFacePersonKeys.Any() || idThenNormalizedPixelPercentagePersonKeys.Any())
|
if (idThenNormalizedPixelPercentagePersonKeys.Any())
|
||||||
{
|
{
|
||||||
int? approximateYears = null;
|
int? approximateYears = null;
|
||||||
PersonBirthday? personBirthday;
|
PersonBirthday? personBirthday;
|
||||||
const string displayDirectoryName = Property.Models.Stateless.IResult.AllInOne;
|
const string displayDirectoryName = Property.Models.Stateless.IResult.AllInOne;
|
||||||
foreach (long personKey in deterministicHashCodeUnknownFacePersonKeys)
|
|
||||||
{
|
|
||||||
if (!peopleKeyValuePairs.ContainsKey(personKey))
|
|
||||||
{
|
|
||||||
personBirthday = Shared.Models.Stateless.Methods.IPersonBirthday.GetPersonBirthday(personKey);
|
|
||||||
peopleKeyValuePairs.Add(personKey, new(displayDirectoryName, approximateYears, new PersonBirthday[] { personBirthday }, personKey));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
foreach (long personKey in idThenNormalizedPixelPercentagePersonKeys)
|
foreach (long personKey in idThenNormalizedPixelPercentagePersonKeys)
|
||||||
{
|
{
|
||||||
if (!peopleKeyValuePairs.ContainsKey(personKey))
|
if (!peopleKeyValuePairs.ContainsKey(personKey))
|
||||||
|
@ -5,10 +5,11 @@ public interface IFaceDistance
|
|||||||
|
|
||||||
const int HiddenImageFactor = 2;
|
const int HiddenImageFactor = 2;
|
||||||
const int Permyriad = 10000;
|
const int Permyriad = 10000;
|
||||||
const double MinimumConfidence = 0.95d;
|
const double MinimumConfidence = 1.25d;
|
||||||
const double Tolerance = 0.21d;
|
const double Tolerance = 0.23d;
|
||||||
|
|
||||||
// (637987888254767613) Tolerance = 0.31d; MinimumConfidence = 0.80d; => 1003 in 20 minutes with 9 failures
|
// (637987888254767613) Tolerance = 0.31d; MinimumConfidence = 0.80d; => 1003 in 20 minutes with 9 failures
|
||||||
// (637987913910140924) Tolerance = 0.21d; MinimumConfidence = 0.95d;
|
// (637987913910140924) Tolerance = 0.21d; MinimumConfidence = 0.95d; => 0254 in 04 minutes with 1 failures
|
||||||
|
// (??????????????????) Tolerance = 0.23d; MinimumConfidence = 1.25d; => ____ in __ minutes with _ failures
|
||||||
|
|
||||||
}
|
}
|
@ -3,12 +3,6 @@
|
|||||||
public interface IMapping
|
public interface IMapping
|
||||||
{
|
{
|
||||||
|
|
||||||
// 637972153144596958
|
|
||||||
// const bool UseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToNamed = true;
|
|
||||||
// const bool OnlyUseNamedWithNormalizedPixelPercentagePopulatedForGetKeyValuePairs = false;
|
|
||||||
|
|
||||||
const bool UseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping = false;
|
|
||||||
const bool UseDeterministicHashCodeUnknownFaceKeyValuePairsForSaveMapping = false;
|
|
||||||
const bool SaveFaceEncoding = false;
|
const bool SaveFaceEncoding = false;
|
||||||
const bool SaveMapped = false;
|
const bool SaveMapped = false;
|
||||||
|
|
||||||
|
@ -3,11 +3,14 @@
|
|||||||
public interface ISorting
|
public interface ISorting
|
||||||
{
|
{
|
||||||
|
|
||||||
|
const int DaysDeltaTolerance = 700;
|
||||||
const int FacesToSkipAfterSortBeforeLoad = 0;
|
const int FacesToSkipAfterSortBeforeLoad = 0;
|
||||||
const int FacesToTakeAfterSortBeforeLoad = 123000;
|
const int FacesToTakeAfterSortBeforeLoad = 123000;
|
||||||
|
const int ForceSingleImage = 3;
|
||||||
|
const int Mapping = 1;
|
||||||
const int MaximumPerFaceShouldBeHigh = 1000;
|
const int MaximumPerFaceShouldBeHigh = 1000;
|
||||||
const int DaysDeltaTolerance = 700;
|
|
||||||
const int MaximumPerKey = 27;
|
const int MaximumPerKey = 27;
|
||||||
const int Sigma = 3;
|
const int Sigma = 3;
|
||||||
|
const int Sorting = 2;
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user