Mass push
This commit is contained in:
@ -39,7 +39,7 @@
|
||||
<PackageReference Include="Serilog" Version="2.12.0" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.2.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.1.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="7.0.0" />
|
||||
<PackageReference Include="System.Text.Json" Version="7.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||
|
@ -14,6 +14,7 @@ public class Configuration
|
||||
public string MappingDefaultName { init; get; }
|
||||
public int PersonBirthdayFirstYear { init; get; }
|
||||
public string PersonBirthdayFormat { init; get; }
|
||||
public string PhotoPrismDirectory { init; get; }
|
||||
public int RangeDaysDeltaTolerance { init; get; }
|
||||
public double RangeDistanceTolerance { init; get; }
|
||||
public int SortingMaximumPerKey { init; get; }
|
||||
@ -25,6 +26,7 @@ public class Configuration
|
||||
string mappingDefaultName,
|
||||
int personBirthdayFirstYear,
|
||||
string personBirthdayFormat,
|
||||
string photoPrismDirectory,
|
||||
int[] rangeDaysDeltaTolerance,
|
||||
double[] rangeDistanceTolerance,
|
||||
int sortingMaximumPerKey,
|
||||
@ -34,6 +36,7 @@ public class Configuration
|
||||
string facePartsFileNameExtension)
|
||||
{
|
||||
MappingDefaultName = mappingDefaultName;
|
||||
PhotoPrismDirectory = photoPrismDirectory;
|
||||
PersonBirthdayFormat = personBirthdayFormat;
|
||||
SortingMaximumPerKey = sortingMaximumPerKey;
|
||||
FaceConfidencePercent = faceConfidencePercent;
|
||||
|
54
Map/Models/DatabaseFile.cs
Normal file
54
Map/Models/DatabaseFile.cs
Normal file
@ -0,0 +1,54 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Map.Models;
|
||||
|
||||
public record DatabaseFile(
|
||||
[property: JsonPropertyName("id")] int Id,
|
||||
[property: JsonPropertyName("photo_id")] int PhotoId,
|
||||
[property: JsonPropertyName("photo_uid")] string PhotoUid,
|
||||
[property: JsonPropertyName("photo_taken_at")] string PhotoTakenAt,
|
||||
[property: JsonPropertyName("time_index")] string TimeIndex,
|
||||
[property: JsonPropertyName("media_id")] string MediaId,
|
||||
[property: JsonPropertyName("media_utc")] object MediaUtc,
|
||||
[property: JsonPropertyName("instance_id")] string InstanceId,
|
||||
[property: JsonPropertyName("file_uid")] string FileUid,
|
||||
[property: JsonPropertyName("file_name")] string FileName,
|
||||
[property: JsonPropertyName("file_root")] string FileRoot,
|
||||
[property: JsonPropertyName("original_name")] string OriginalName,
|
||||
[property: JsonPropertyName("file_hash")] string FileHash,
|
||||
[property: JsonPropertyName("file_size")] int FileSize,
|
||||
[property: JsonPropertyName("file_codec")] string FileCodec,
|
||||
[property: JsonPropertyName("file_type")] string FileType,
|
||||
[property: JsonPropertyName("media_type")] string MediaType,
|
||||
[property: JsonPropertyName("file_mime")] string FileMime,
|
||||
[property: JsonPropertyName("file_primary")] long FilePrimary,
|
||||
[property: JsonPropertyName("file_sidecar")] long FileSidecar,
|
||||
[property: JsonPropertyName("file_missing")] long FileMissing,
|
||||
[property: JsonPropertyName("file_portrait")] long FilePortrait,
|
||||
[property: JsonPropertyName("file_video")] long FileVideo,
|
||||
[property: JsonPropertyName("file_duration")] long FileDuration,
|
||||
[property: JsonPropertyName("file_fps")] object FileFps,
|
||||
[property: JsonPropertyName("file_frames")] object FileFrames,
|
||||
[property: JsonPropertyName("file_width")] int FileWidth,
|
||||
[property: JsonPropertyName("file_height")] int FileHeight,
|
||||
[property: JsonPropertyName("file_orientation")] int FileOrientation,
|
||||
[property: JsonPropertyName("file_projection")] string FileProjection,
|
||||
[property: JsonPropertyName("file_aspect_ratio")] double FileAspectRatio,
|
||||
[property: JsonPropertyName("file_hdr")] long FileHdr,
|
||||
[property: JsonPropertyName("file_watermark")] long FileWatermark,
|
||||
[property: JsonPropertyName("file_color_profile")] string FileColorProfile,
|
||||
[property: JsonPropertyName("file_main_color")] string FileMainColor,
|
||||
[property: JsonPropertyName("file_colors")] string FileColors,
|
||||
[property: JsonPropertyName("file_luminance")] string FileLuminance,
|
||||
[property: JsonPropertyName("file_diff")] long FileDiff,
|
||||
[property: JsonPropertyName("file_chroma")] long FileChroma,
|
||||
[property: JsonPropertyName("file_software")] string FileSoftware,
|
||||
[property: JsonPropertyName("file_error")] string FileError,
|
||||
[property: JsonPropertyName("mod_time")] long ModTime,
|
||||
[property: JsonPropertyName("created_at")] string CreatedAt,
|
||||
[property: JsonPropertyName("created_in")] long CreatedIn,
|
||||
[property: JsonPropertyName("updated_at")] string UpdatedAt,
|
||||
[property: JsonPropertyName("updated_in")] long UpdatedIn,
|
||||
[property: JsonPropertyName("published_at")] object PublishedAt,
|
||||
[property: JsonPropertyName("deleted_at")] object DeletedAt
|
||||
);
|
8
Map/Models/DatabaseFileRoot.cs
Normal file
8
Map/Models/DatabaseFileRoot.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Map.Models;
|
||||
|
||||
public record DatabaseFileRoot(
|
||||
[property: JsonPropertyName("table")] string Table,
|
||||
[property: JsonPropertyName("rows")] IReadOnlyList<DatabaseFile> Files
|
||||
);
|
@ -1,5 +1,6 @@
|
||||
using Humanizer;
|
||||
using ShellProgressBar;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using View_by_Distance.Map.Models.Stateless;
|
||||
using View_by_Distance.Shared.Models;
|
||||
@ -15,7 +16,7 @@ public class MapLogic
|
||||
protected readonly List<PersonContainer> _NotMappedPersonContainers;
|
||||
protected readonly Dictionary<long, PersonContainer> _PersonKeyToPersonContainer;
|
||||
protected readonly Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> _PersonKeyToRanges;
|
||||
protected readonly Dictionary<int, Dictionary<int, PersonContainer[]>> _IdThenNormalizedPixelPercentageToPersonContainers;
|
||||
protected readonly Dictionary<int, Dictionary<int, PersonContainer[]>> _IdThenNormalizedRectangleToPersonContainers;
|
||||
|
||||
public Dictionary<int, int[]> KeyValuePairs => throw new NotImplementedException();
|
||||
public Dictionary<int, int[]> IndicesFromNew => throw new NotImplementedException();
|
||||
@ -51,7 +52,7 @@ public class MapLogic
|
||||
string? rootDirectoryParent = Path.GetDirectoryName(propertyConfiguration.RootDirectory);
|
||||
Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges = new();
|
||||
string eDistanceContentTicksDirectory = Path.Combine(eDistanceContentDirectory, $"({ticks})");
|
||||
Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers = new();
|
||||
Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers = new();
|
||||
for (int i = 1; i < 5; i++)
|
||||
_ = IPath.DeleteEmptyDirectories(eDistanceContentDirectory);
|
||||
_ = IPath.DeleteEmptyDirectories(eDistanceContentDirectory);
|
||||
@ -76,7 +77,7 @@ public class MapLogic
|
||||
personKeyToRanges,
|
||||
notMappedPersonContainers,
|
||||
skipCollection,
|
||||
idThenNormalizedPixelPercentageToPersonContainers);
|
||||
idThenNormalizedRectangleToPersonContainers);
|
||||
if (personContainerCollection.Count == personContainers.Length)
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
@ -97,7 +98,7 @@ public class MapLogic
|
||||
_NotMappedPersonContainers = notMappedPersonContainers;
|
||||
_PersonKeyToPersonContainer = personKeyToPersonContainer;
|
||||
_EDistanceContentTicksDirectory = eDistanceContentTicksDirectory;
|
||||
_IdThenNormalizedPixelPercentageToPersonContainers = idThenNormalizedPixelPercentageToPersonContainers;
|
||||
_IdThenNormalizedRectangleToPersonContainers = idThenNormalizedRectangleToPersonContainers;
|
||||
}
|
||||
|
||||
public MapLogic(int maxDegreeOfParallelism, Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, Configuration? configuration, long ticks, PersonContainer[] personContainers, string a2PeopleSingletonDirectory, string eDistanceContentDirectory) :
|
||||
@ -123,15 +124,15 @@ public class MapLogic
|
||||
PersonContainer[]? collection;
|
||||
List<PersonContainer> personContainers = new();
|
||||
Dictionary<long, int> personKeyToCount = new();
|
||||
Dictionary<int, PersonContainer[]>? normalizedPixelPercentageToPersonContainers;
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
personContainers.Clear();
|
||||
if (!_IdThenNormalizedPixelPercentageToPersonContainers.TryGetValue(mapping.MappingFromItem.Id, out normalizedPixelPercentageToPersonContainers))
|
||||
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromItem.Id, out normalizedRectangleToPersonContainers))
|
||||
result += 1;
|
||||
else
|
||||
{
|
||||
if (!normalizedPixelPercentageToPersonContainers.TryGetValue(mapping.MappingFromLocation.NormalizedPixelPercentage, out collection))
|
||||
if (!normalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromLocation.NormalizedRectangle, out collection))
|
||||
result += 1;
|
||||
else
|
||||
personContainers.AddRange(collection);
|
||||
@ -152,7 +153,7 @@ public class MapLogic
|
||||
return new(personKeyToCount, result);
|
||||
}
|
||||
|
||||
private void SaveContainers(int totalNotMapped, int? updated, List<SaveContainer> saveContainers)
|
||||
public void SaveContainers(int totalNotMapped, int? updated, List<SaveContainer> saveContainers)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
@ -342,7 +343,7 @@ public class MapLogic
|
||||
string personKeyFormatted;
|
||||
PersonBirthday personBirthday;
|
||||
PersonContainer personContainer;
|
||||
result = Path.Combine(_EDistanceContentTicksDirectory, by, sortingContainer.Sorting.Id.ToString(), sortingContainer.Sorting.NormalizedPixelPercentage.ToString());
|
||||
result = Path.Combine(_EDistanceContentTicksDirectory, by, sortingContainer.Sorting.Id.ToString(), sortingContainer.Sorting.NormalizedRectangle.ToString());
|
||||
for (int i = 0; i < _NotMappedPersonContainers.Count; i++)
|
||||
{
|
||||
personContainer = _NotMappedPersonContainers[i];
|
||||
@ -358,7 +359,7 @@ public class MapLogic
|
||||
return result;
|
||||
}
|
||||
|
||||
private List<SaveContainer> GetSaveContainers(string dFacesContentDirectory, string d2FacePartsContentDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedPixelPercentageToMapping, Dictionary<long, int> personKeyToCount, int? useFiltersCounter, bool saveMapped)
|
||||
private List<SaveContainer> GetSaveContainers(string dFacesContentDirectory, string d2FacePartsContentDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping, Dictionary<long, int> personKeyToCount, int? useFiltersCounter, bool saveNullPerson, bool saveMapped)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
@ -379,7 +380,7 @@ public class MapLogic
|
||||
SaveContainer? saveContainer;
|
||||
FileHolder facePartsFileHolder;
|
||||
FileHolder hiddenFaceFileHolder;
|
||||
Dictionary<int, Mapping>? normalizedPixelPercentageToMapping;
|
||||
Dictionary<int, Mapping>? normalizedRectangleToMapping;
|
||||
string forceSingleImageHumanized = nameof(IMapLogic.ForceSingleImage).Humanize(LetterCasing.Title);
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
@ -391,6 +392,8 @@ public class MapLogic
|
||||
continue;
|
||||
if (mapping.MappingFromPerson is null)
|
||||
{
|
||||
if (!saveNullPerson)
|
||||
continue;
|
||||
if (mapping.SortingContainer is null)
|
||||
continue;
|
||||
directory = GetDirectory(by, mapping.MappingFromItem, mapping.SortingContainer);
|
||||
@ -404,7 +407,10 @@ public class MapLogic
|
||||
throw new NotSupportedException();
|
||||
personKey = mapping.MappingFromPerson.PersonBirthday.Value.Ticks;
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, mapping.MappingFromPerson.PersonBirthday);
|
||||
directory = Path.Combine(_EDistanceContentTicksDirectory, by, personKeyFormatted, mapping.MappingFromPerson.SegmentB);
|
||||
if (string.IsNullOrEmpty(mapping.SegmentC))
|
||||
directory = Path.Combine(_EDistanceContentTicksDirectory, by, personKeyFormatted, mapping.MappingFromPerson.SegmentB);
|
||||
else
|
||||
directory = Path.Combine(_EDistanceContentTicksDirectory, by, personKeyFormatted, mapping.MappingFromPerson.SegmentB, mapping.SegmentC);
|
||||
if (isByMapping)
|
||||
personDirectory = Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName);
|
||||
else if (mapping.By is not null)
|
||||
@ -435,7 +441,10 @@ public class MapLogic
|
||||
facePartsDirectory = GetFacePartsDirectory(d2FacePartsContentDirectory, mapping.MappingFromItem);
|
||||
if (facePartsDirectory is null)
|
||||
continue;
|
||||
checkFile = Path.Combine(directory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}");
|
||||
if (!isBySorting || mapping.MappingFromPerson is not null)
|
||||
checkFile = Path.Combine(directory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}");
|
||||
else
|
||||
checkFile = Path.Combine(directory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}-Source{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}");
|
||||
shortcutFile = Path.Combine(personDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}.lnk");
|
||||
hiddenFaceFileHolder = new(Path.Combine(facesDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacesHiddenFileNameExtension}"));
|
||||
facePartsFileHolder = new(Path.Combine(facePartsDirectory, $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacePartsFileNameExtension}"));
|
||||
@ -444,43 +453,43 @@ public class MapLogic
|
||||
results.Add(saveContainer);
|
||||
if (!isBySorting || mapping.SortingContainer is null)
|
||||
continue;
|
||||
if (!idToNormalizedPixelPercentageToMapping.TryGetValue(mapping.SortingContainer.Sorting.Id, out normalizedPixelPercentageToMapping))
|
||||
if (!idToNormalizedRectangleToMapping.TryGetValue(mapping.SortingContainer.Sorting.Id, out normalizedRectangleToMapping))
|
||||
continue;
|
||||
if (!normalizedPixelPercentageToMapping.ContainsKey(mapping.SortingContainer.Sorting.NormalizedPixelPercentage))
|
||||
if (!normalizedRectangleToMapping.ContainsKey(mapping.SortingContainer.Sorting.NormalizedRectangle))
|
||||
continue;
|
||||
if (isBySorting && mapping.MappingFromPerson is null)
|
||||
{
|
||||
saveContainer = GetMatchSaveContainer(dFacesContentDirectory, d2FacePartsContentDirectory, directory, normalizedPixelPercentageToMapping[mapping.SortingContainer.Sorting.NormalizedPixelPercentage]);
|
||||
saveContainer = GetMatchSaveContainer(dFacesContentDirectory, d2FacePartsContentDirectory, directory, normalizedRectangleToMapping[mapping.SortingContainer.Sorting.NormalizedRectangle]);
|
||||
if (saveContainer is not null)
|
||||
results.Add(saveContainer);
|
||||
}
|
||||
saveContainer = Stateless.MapLogic.GetDebugSaveContainer(directory, mapping.SortingContainer, normalizedPixelPercentageToMapping[mapping.SortingContainer.Sorting.NormalizedPixelPercentage]);
|
||||
saveContainer = Stateless.MapLogic.GetDebugSaveContainer(directory, mapping.SortingContainer, normalizedRectangleToMapping[mapping.SortingContainer.Sorting.NormalizedRectangle]);
|
||||
results.Add(saveContainer);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public void UpdateFromSortingContainersThenSaveContainers(string dFacesContentDirectory, string d2FacePartsContentDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedPixelPercentageToMapping, int? useFiltersCounter, SortingContainer[] sortingContainers, int totalNotMapped)
|
||||
public List<SaveContainer> GetSaveContainers(string dFacesContentDirectory, string d2FacePartsContentDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping, int? useFiltersCounter, bool saveNullPerson)
|
||||
{
|
||||
if (_MapLogicSupport is not null)
|
||||
{
|
||||
string counts = _MapLogicSupport.GetCounts();
|
||||
_ = Directory.CreateDirectory(Path.Combine(_EDistanceContentTicksDirectory, counts));
|
||||
}
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
List<SaveContainer> results;
|
||||
bool saveMapped = false;
|
||||
Dictionary<long, int> personKeyToCount = new();
|
||||
int updated = UpdateFromSortingContainers(sortingContainers);
|
||||
List<SaveContainer> saveContainers = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, mappingCollection, idToNormalizedPixelPercentageToMapping, personKeyToCount, useFiltersCounter, saveMapped: false);
|
||||
SaveContainers(totalNotMapped, updated, saveContainers);
|
||||
results = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, mappingCollection, idToNormalizedRectangleToMapping, personKeyToCount, useFiltersCounter, saveNullPerson, saveMapped);
|
||||
return results;
|
||||
}
|
||||
|
||||
public void SaveMapped(string dFacesContentDirectory, string d2FacePartsContentDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedPixelPercentageToMapping, Dictionary<long, int> personKeyToCount, int totalNotMapped)
|
||||
public void SaveMapped(string dFacesContentDirectory, string d2FacePartsContentDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping, Dictionary<long, int> personKeyToCount, int totalNotMapped)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
int? updated = null;
|
||||
bool saveMapped = true;
|
||||
bool saveNullPerson = false;
|
||||
int? useFiltersCounter = null;
|
||||
string mappingDirectory = Path.Combine(_EDistanceContentTicksDirectory, nameof(IMapLogic.Mapping));
|
||||
List<SaveContainer> saveContainers = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, mappingCollection, idToNormalizedPixelPercentageToMapping, personKeyToCount, useFiltersCounter, saveMapped: true);
|
||||
List<SaveContainer> saveContainers = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, mappingCollection, idToNormalizedRectangleToMapping, personKeyToCount, useFiltersCounter, saveNullPerson, saveMapped);
|
||||
SaveContainers(totalNotMapped, updated, saveContainers);
|
||||
if (!string.IsNullOrEmpty(_EDistanceContentTicksDirectory) && Directory.Exists(mappingDirectory))
|
||||
Stateless.MapLogic.SaveMappingShortcuts(mappingDirectory);
|
||||
@ -504,18 +513,18 @@ public class MapLogic
|
||||
public bool Used(FaceDistance faceDistanceEncoding)
|
||||
{
|
||||
bool result = false;
|
||||
if (faceDistanceEncoding.NormalizedPixelPercentage is null)
|
||||
if (faceDistanceEncoding.NormalizedRectangle is null)
|
||||
throw new NotSupportedException();
|
||||
List<int>? normalizedPixelPercentages;
|
||||
Dictionary<int, PersonContainer[]>? normalizedPixelPercentageToPersonContainers;
|
||||
if (_SkipCollection.TryGetValue(faceDistanceEncoding.Id, out normalizedPixelPercentages))
|
||||
List<int>? normalizedRectangles;
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
if (_SkipCollection.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangles))
|
||||
{
|
||||
if (normalizedPixelPercentages.Contains(faceDistanceEncoding.NormalizedPixelPercentage.Value))
|
||||
if (normalizedRectangles.Contains(faceDistanceEncoding.NormalizedRectangle.Value))
|
||||
result = true;
|
||||
}
|
||||
if (!result && _IdThenNormalizedPixelPercentageToPersonContainers.TryGetValue(faceDistanceEncoding.Id, out normalizedPixelPercentageToPersonContainers))
|
||||
if (!result && _IdThenNormalizedRectangleToPersonContainers.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangleToPersonContainers))
|
||||
{
|
||||
if (normalizedPixelPercentageToPersonContainers.ContainsKey(faceDistanceEncoding.NormalizedPixelPercentage.Value))
|
||||
if (normalizedRectangleToPersonContainers.ContainsKey(faceDistanceEncoding.NormalizedRectangle.Value))
|
||||
result = true;
|
||||
}
|
||||
return result;
|
||||
@ -528,45 +537,45 @@ public class MapLogic
|
||||
List<Sorting> results = new();
|
||||
Sorting sorting;
|
||||
FaceDistance faceDistanceLength;
|
||||
List<int>? normalizedPixelPercentages;
|
||||
Dictionary<int, PersonContainer[]>? normalizedPixelPercentageToPersonContainers;
|
||||
List<int>? normalizedRectangles;
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
List<(long lcl, long minimum, long maximum, long ucl)> personKeysRangesCollection;
|
||||
for (int j = 0; j < faceDistanceLengths.Count; j++)
|
||||
{
|
||||
if (faceDistanceEncoding.NormalizedPixelPercentage is null)
|
||||
if (faceDistanceEncoding.NormalizedRectangle is null)
|
||||
throw new NotSupportedException();
|
||||
if (j == i)
|
||||
continue;
|
||||
if (_SkipCollection.TryGetValue(faceDistanceEncoding.Id, out normalizedPixelPercentages))
|
||||
if (_SkipCollection.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangles))
|
||||
{
|
||||
if (normalizedPixelPercentages.Contains(faceDistanceEncoding.NormalizedPixelPercentage.Value))
|
||||
if (normalizedRectangles.Contains(faceDistanceEncoding.NormalizedRectangle.Value))
|
||||
continue;
|
||||
}
|
||||
if (_IdThenNormalizedPixelPercentageToPersonContainers.TryGetValue(faceDistanceEncoding.Id, out normalizedPixelPercentageToPersonContainers))
|
||||
if (_IdThenNormalizedRectangleToPersonContainers.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangleToPersonContainers))
|
||||
{
|
||||
if (normalizedPixelPercentageToPersonContainers.ContainsKey(faceDistanceEncoding.NormalizedPixelPercentage.Value))
|
||||
if (normalizedRectangleToPersonContainers.ContainsKey(faceDistanceEncoding.NormalizedRectangle.Value))
|
||||
continue;
|
||||
}
|
||||
faceDistanceLength = faceDistanceLengths[j];
|
||||
if (faceDistanceLength.NormalizedPixelPercentage is null || faceDistanceLength.Length is null)
|
||||
if (faceDistanceLength.NormalizedRectangle is null || faceDistanceLength.Length is null)
|
||||
throw new NotSupportedException();
|
||||
if (faceDistanceLength.Length == 0)
|
||||
continue;
|
||||
if (!_IdThenNormalizedPixelPercentageToPersonContainers.TryGetValue(faceDistanceLength.Id, out normalizedPixelPercentageToPersonContainers))
|
||||
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(faceDistanceLength.Id, out normalizedRectangleToPersonContainers))
|
||||
personKeysRangesCollection = new();
|
||||
else
|
||||
{
|
||||
if (!normalizedPixelPercentageToPersonContainers.ContainsKey(faceDistanceLength.NormalizedPixelPercentage.Value))
|
||||
if (!normalizedRectangleToPersonContainers.ContainsKey(faceDistanceLength.NormalizedRectangle.Value))
|
||||
personKeysRangesCollection = new();
|
||||
else
|
||||
personKeysRangesCollection = GetPersonKeysRangesCollection(normalizedPixelPercentageToPersonContainers[faceDistanceLength.NormalizedPixelPercentage.Value]);
|
||||
personKeysRangesCollection = GetPersonKeysRangesCollection(normalizedRectangleToPersonContainers[faceDistanceLength.NormalizedRectangle.Value]);
|
||||
}
|
||||
sorting = ISorting.Get(_Configuration.FaceDistancePermyriad, _Configuration.RangeDistanceTolerance, faceDistanceEncoding, faceDistanceLength, personKeysRangesCollection);
|
||||
if (sorting.DistancePermyriad == 0)
|
||||
continue;
|
||||
if (sorting.Id == faceDistanceEncoding.Id)
|
||||
{
|
||||
if (sorting.NormalizedPixelPercentage == faceDistanceEncoding.NormalizedPixelPercentage.Value)
|
||||
if (sorting.NormalizedRectangle == faceDistanceEncoding.NormalizedRectangle.Value)
|
||||
throw new NotSupportedException();
|
||||
continue;
|
||||
}
|
||||
@ -575,10 +584,15 @@ public class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
public int UpdateFromSortingContainers(SortingContainer[] sortingContainers)
|
||||
public int UpdateFromSortingContainers(SortingContainer[] sortingContainers, bool saveNullPerson)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
if (_MapLogicSupport is not null)
|
||||
{
|
||||
string counts = _MapLogicSupport.GetCounts();
|
||||
_ = Directory.CreateDirectory(Path.Combine(_EDistanceContentTicksDirectory, counts));
|
||||
}
|
||||
int result = 0;
|
||||
string key;
|
||||
const int zero = 0;
|
||||
@ -587,12 +601,13 @@ public class MapLogic
|
||||
PersonBirthday personBirthday;
|
||||
const int by = IMapLogic.Sorting;
|
||||
PersonContainer[] personContainers;
|
||||
List<int> normalizedPixelPercentageCollectionForA;
|
||||
List<int> normalizedPixelPercentageCollectionForB;
|
||||
Dictionary<string, int> checkKeyValuePairs = new();
|
||||
Dictionary<int, List<int>> idToNormalizedPixelPercentageCollectionForA = new();
|
||||
Dictionary<int, List<int>> idToNormalizedPixelPercentageCollectionForB = new();
|
||||
Dictionary<int, PersonContainer[]>? normalizedPixelPercentageToPersonContainers;
|
||||
Dictionary<string, int> keyToCount = new();
|
||||
Dictionary<string, string> keyToSegmentC = new();
|
||||
List<int> normalizedRectangleCollectionForA;
|
||||
List<int> normalizedRectangleCollectionForB;
|
||||
Dictionary<int, List<int>> idToNormalizedRectangleCollectionForA = new();
|
||||
Dictionary<int, List<int>> idToNormalizedRectangleCollectionForB = new();
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - _Ticks).TotalSeconds);
|
||||
string message = $") {sortingContainers.Length:000} Update From Sorting Container(s) - {totalSeconds} total second(s)";
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
@ -602,35 +617,39 @@ public class MapLogic
|
||||
progressBar.Tick();
|
||||
if (sortingContainer.Mapping is null)
|
||||
throw new NotSupportedException();
|
||||
if (!idToNormalizedPixelPercentageCollectionForA.ContainsKey(sortingContainer.Mapping.MappingFromItem.Id))
|
||||
idToNormalizedPixelPercentageCollectionForA.Add(sortingContainer.Mapping.MappingFromItem.Id, new());
|
||||
normalizedPixelPercentageCollectionForA = idToNormalizedPixelPercentageCollectionForA[sortingContainer.Mapping.MappingFromItem.Id];
|
||||
if (!idToNormalizedPixelPercentageCollectionForB.ContainsKey(sortingContainer.Mapping.MappingFromItem.Id))
|
||||
idToNormalizedPixelPercentageCollectionForB.Add(sortingContainer.Mapping.MappingFromItem.Id, new());
|
||||
normalizedPixelPercentageCollectionForB = idToNormalizedPixelPercentageCollectionForB[sortingContainer.Mapping.MappingFromItem.Id];
|
||||
if (!_IdThenNormalizedPixelPercentageToPersonContainers.TryGetValue(sortingContainer.Sorting.Id, out normalizedPixelPercentageToPersonContainers))
|
||||
if (!idToNormalizedRectangleCollectionForA.ContainsKey(sortingContainer.Mapping.MappingFromItem.Id))
|
||||
idToNormalizedRectangleCollectionForA.Add(sortingContainer.Mapping.MappingFromItem.Id, new());
|
||||
normalizedRectangleCollectionForA = idToNormalizedRectangleCollectionForA[sortingContainer.Mapping.MappingFromItem.Id];
|
||||
if (!idToNormalizedRectangleCollectionForB.ContainsKey(sortingContainer.Mapping.MappingFromItem.Id))
|
||||
idToNormalizedRectangleCollectionForB.Add(sortingContainer.Mapping.MappingFromItem.Id, new());
|
||||
normalizedRectangleCollectionForB = idToNormalizedRectangleCollectionForB[sortingContainer.Mapping.MappingFromItem.Id];
|
||||
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(sortingContainer.Sorting.Id, out normalizedRectangleToPersonContainers))
|
||||
{
|
||||
personContainers = Array.Empty<PersonContainer>();
|
||||
if (normalizedPixelPercentageCollectionForA.Contains(sortingContainer.Mapping.MappingFromLocation.NormalizedPixelPercentage))
|
||||
if (!saveNullPerson)
|
||||
continue;
|
||||
key = string.Concat(sortingContainer.Mapping.MappingFromItem.Id, '\t', sortingContainer.Mapping.MappingFromLocation.NormalizedPixelPercentage);
|
||||
if (!checkKeyValuePairs.ContainsKey(key))
|
||||
checkKeyValuePairs.Add(key, new());
|
||||
checkKeyValuePairs[key]++;
|
||||
if (checkKeyValuePairs[key] > _Configuration.SortingMaximumPerKey)
|
||||
personContainers = Array.Empty<PersonContainer>();
|
||||
if (normalizedRectangleCollectionForA.Contains(sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle))
|
||||
continue;
|
||||
key = string.Concat(sortingContainer.Mapping.MappingFromItem.Id, '\t', sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle);
|
||||
if (!keyToCount.ContainsKey(key))
|
||||
keyToCount.Add(key, 0);
|
||||
if (!keyToSegmentC.ContainsKey(key))
|
||||
keyToSegmentC.Add(key, string.Empty);
|
||||
keyToCount[key]++;
|
||||
if (keyToCount[key] > _Configuration.SortingMaximumPerKey)
|
||||
continue;
|
||||
sortingContainer.Mapping.UpdateMappingFromUnknownPerson(by, sortingContainer);
|
||||
normalizedPixelPercentageCollectionForA.Add(sortingContainer.Mapping.MappingFromLocation.NormalizedPixelPercentage);
|
||||
normalizedRectangleCollectionForA.Add(sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle);
|
||||
result += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (normalizedPixelPercentageCollectionForB.Contains(sortingContainer.Mapping.MappingFromLocation.NormalizedPixelPercentage))
|
||||
if (normalizedRectangleCollectionForB.Contains(sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle))
|
||||
continue;
|
||||
if (!normalizedPixelPercentageToPersonContainers.ContainsKey(sortingContainer.Sorting.NormalizedPixelPercentage))
|
||||
if (!normalizedRectangleToPersonContainers.ContainsKey(sortingContainer.Sorting.NormalizedRectangle))
|
||||
personContainers = Array.Empty<PersonContainer>();
|
||||
else
|
||||
personContainers = normalizedPixelPercentageToPersonContainers[sortingContainer.Sorting.NormalizedPixelPercentage];
|
||||
personContainers = normalizedRectangleToPersonContainers[sortingContainer.Sorting.NormalizedRectangle];
|
||||
foreach (PersonContainer personContainer in personContainers)
|
||||
{
|
||||
if (personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
|
||||
@ -639,13 +658,20 @@ public class MapLogic
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personBirthday);
|
||||
mappingSegmentB = Stateless.MapLogic.GetMappingSegmentB(_Ticks, personBirthday, personContainer.ApproximateYears, sortingContainer.Mapping.MappingFromItem);
|
||||
key = string.Concat(personKeyFormatted, '\t', mappingSegmentB);
|
||||
if (!checkKeyValuePairs.ContainsKey(key))
|
||||
checkKeyValuePairs.Add(key, new());
|
||||
checkKeyValuePairs[key]++;
|
||||
if (checkKeyValuePairs[key] > _Configuration.SortingMaximumPerKey)
|
||||
continue;
|
||||
sortingContainer.Mapping.UpdateMappingFromPerson(personContainer.ApproximateYears, by, personContainer.DisplayDirectoryName, personBirthday, mappingSegmentB, sortingContainer);
|
||||
normalizedPixelPercentageCollectionForB.Add(sortingContainer.Mapping.MappingFromLocation.NormalizedPixelPercentage);
|
||||
if (!keyToCount.ContainsKey(key))
|
||||
keyToCount.Add(key, new());
|
||||
if (!keyToCount.ContainsKey(key))
|
||||
keyToCount.Add(key, 0);
|
||||
if (!keyToSegmentC.ContainsKey(key))
|
||||
keyToSegmentC.Add(key, string.Empty);
|
||||
keyToCount[key]++;
|
||||
if (keyToCount[key] > _Configuration.SortingMaximumPerKey)
|
||||
{
|
||||
keyToCount[key] = 0;
|
||||
keyToSegmentC[key] = sortingContainer.Sorting.DistancePermyriad.ToString();
|
||||
}
|
||||
sortingContainer.Mapping.UpdateMappingFromPerson(personContainer.ApproximateYears, by, personContainer.DisplayDirectoryName, personBirthday, mappingSegmentB, keyToSegmentC[key], sortingContainer);
|
||||
normalizedRectangleCollectionForB.Add(sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle);
|
||||
result += 1;
|
||||
break;
|
||||
}
|
||||
@ -654,7 +680,7 @@ public class MapLogic
|
||||
return result;
|
||||
}
|
||||
|
||||
public void CopyManualFiles(string dFacesContentDirectory, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedPixelPercentageToMapping)
|
||||
public void CopyManualFiles(string dFacesContentDirectory, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
@ -675,11 +701,11 @@ public class MapLogic
|
||||
string personDisplayFileName;
|
||||
PersonBirthday personBirthday;
|
||||
string? personDisplayDirectory;
|
||||
int? normalizedPixelPercentage;
|
||||
int? normalizedRectangle;
|
||||
WindowsShortcut windowsShortcut;
|
||||
string by = nameof(IMapLogic.ManualCopy);
|
||||
Dictionary<int, Mapping>? normalizedPixelPercentageToMapping;
|
||||
Dictionary<int, PersonContainer[]>? normalizedPixelPercentageToPeronContainerCollection;
|
||||
Dictionary<int, Mapping>? normalizedRectangleToMapping;
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPeronContainerCollection;
|
||||
string successfull = $"_ {nameof(IMapLogic.ManualCopy).Humanize(LetterCasing.Title)} Successfull";
|
||||
foreach (KeyValuePair<long, PersonContainer> keyValuePair in _PersonKeyToPersonContainer)
|
||||
{
|
||||
@ -692,8 +718,8 @@ public class MapLogic
|
||||
continue;
|
||||
if (!personDisplayDirectoryAllFile.EndsWith(_Configuration.FacesFileNameExtension))
|
||||
continue;
|
||||
(id, normalizedPixelPercentage, _) = IMapping.GetReversedDeterministicHashCodeKey(_Configuration.FacesFileNameExtension, personDisplayDirectoryAllFile);
|
||||
if (id is null || normalizedPixelPercentage is null)
|
||||
(id, normalizedRectangle, _) = IMapping.GetConverted(_Configuration.FacesFileNameExtension, personDisplayDirectoryAllFile);
|
||||
if (id is null || normalizedRectangle is null)
|
||||
continue;
|
||||
fileInfo = new(personDisplayDirectoryAllFile);
|
||||
if (!fileInfo.Exists)
|
||||
@ -704,11 +730,11 @@ public class MapLogic
|
||||
mappingSegmentB = Stateless.MapLogic.GetMappingSegmentB(_Ticks, personBirthday, keyValuePair.Value.ApproximateYears, fileInfo.CreationTime, isWrongYear: null);
|
||||
directory = Path.Combine(_EDistanceContentTicksDirectory, by, personKeyFormatted, mappingSegmentB);
|
||||
personDirectory = Path.Combine(directory, keyValuePair.Value.DisplayDirectoryName, "lnk");
|
||||
if (!idToNormalizedPixelPercentageToMapping.TryGetValue(id.Value, out normalizedPixelPercentageToMapping))
|
||||
if (!idToNormalizedRectangleToMapping.TryGetValue(id.Value, out normalizedRectangleToMapping))
|
||||
continue;
|
||||
if (!normalizedPixelPercentageToMapping.ContainsKey(normalizedPixelPercentage.Value))
|
||||
if (!normalizedRectangleToMapping.ContainsKey(normalizedRectangle.Value))
|
||||
continue;
|
||||
mapping = normalizedPixelPercentageToMapping[normalizedPixelPercentage.Value];
|
||||
mapping = normalizedRectangleToMapping[normalizedRectangle.Value];
|
||||
if (string.IsNullOrEmpty(personDisplayDirectory))
|
||||
throw new NotSupportedException();
|
||||
directoryName = Path.GetDirectoryName(mapping.MappingFromItem.RelativePath);
|
||||
@ -720,7 +746,7 @@ public class MapLogic
|
||||
continue;
|
||||
faceFileName = $"{mapping.MappingFromLocation.DeterministicHashCodeKey}{mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}{_Configuration.FacesFileNameExtension}";
|
||||
checkFile = Path.Combine(directory, fileInfo.Name);
|
||||
if (!_IdThenNormalizedPixelPercentageToPersonContainers.TryGetValue(id.Value, out normalizedPixelPercentageToPeronContainerCollection) || !normalizedPixelPercentageToPeronContainerCollection.ContainsKey(normalizedPixelPercentage.Value))
|
||||
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(id.Value, out normalizedRectangleToPeronContainerCollection) || !normalizedRectangleToPeronContainerCollection.ContainsKey(normalizedRectangle.Value))
|
||||
{
|
||||
if (!Directory.Exists(personDirectory))
|
||||
_ = Directory.CreateDirectory(personDirectory);
|
||||
@ -946,7 +972,7 @@ public class MapLogic
|
||||
SaveContainers(totalNotMapped, null, saveContainers);
|
||||
}
|
||||
|
||||
private List<(string, string, string, string)> GetCollectionForSaveShortcuts(string[] jLinks, string a2PeopleSingletonDirectory, PersonContainer[] personContainers, List<Item> filteredItems, Mapping[] mappingCollection, Dictionary<long, int> personKeyToCount)
|
||||
private (List<(string, DateTime[])>, List<(string, string, string, string)>) GetCollectionForSaveShortcutsForOutputResolutions(List<Item> filteredItems, Mapping[] mappingCollection, Dictionary<long, int> personKeyToCount)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
@ -956,19 +982,44 @@ public class MapLogic
|
||||
string? directoryName;
|
||||
string personDirectory;
|
||||
string personKeyFormatted;
|
||||
List<string> distinct = new();
|
||||
List<(string, string, string, string)> collection = new();
|
||||
List<string> personKeyFormattedCollection = GetPersonKeyFormattedCollection(jLinks, a2PeopleSingletonDirectory, personContainers, personKeyToCount);
|
||||
List<(string, DateTime[])> directoriesAndDateTimes = new();
|
||||
foreach (Item item in filteredItems)
|
||||
{
|
||||
directoryName = Path.GetDirectoryName(item.RelativePath);
|
||||
if (directoryName is null)
|
||||
throw new NotSupportedException();
|
||||
if (item.Property?.Id is null || item.ResizedFileHolder?.DirectoryName is null || !item.ResizedFileHolder.Exists)
|
||||
if (item.ResizedFileHolder is null)
|
||||
continue;
|
||||
directory = Path.Combine(item.ResizedFileHolder.DirectoryName, $"{_PropertyConfiguration.ResultAllInOne}Shortcuts", _PropertyConfiguration.ResultAllInOne);
|
||||
personDirectory = Path.Combine(directory, "No Faces");
|
||||
fileName = Path.Combine(personDirectory, $"{item.ResizedFileHolder.Name}.lnk");
|
||||
collection.Add(new(item.ResizedFileHolder.FullName, personDirectory, fileName, item.Property.Id.Value.ToString()));
|
||||
foreach (Face face in item.Faces)
|
||||
{
|
||||
if (face.FaceEncoding is null || face.Location is null || face.OutputResolution is null || face.Mapping is null)
|
||||
continue;
|
||||
directoryName = Path.GetDirectoryName(face.Mapping.MappingFromItem.RelativePath);
|
||||
if (directoryName is null)
|
||||
throw new NotSupportedException();
|
||||
if (item.ResizedFileHolder?.DirectoryName is null || !item.ResizedFileHolder.Exists)
|
||||
continue;
|
||||
directory = Path.Combine(item.ResizedFileHolder.DirectoryName, $"{_PropertyConfiguration.ResultAllInOne}Shortcuts", _PropertyConfiguration.ResultAllInOne);
|
||||
personDirectory = Path.Combine(directory, "No Faces");
|
||||
fileName = Path.Combine(personDirectory, $"{item.ResizedFileHolder.Name}.lnk");
|
||||
collection.Add(new(item.ResizedFileHolder.FullName, personDirectory, fileName, face.Mapping.MappingFromItem.Id.ToString()));
|
||||
if (face.Mapping.MappingFromItem.ContainerDateTimes.Any() && !distinct.Contains(item.ResizedFileHolder.DirectoryName))
|
||||
{
|
||||
distinct.Add(item.ResizedFileHolder.DirectoryName);
|
||||
directoriesAndDateTimes.Add(new(item.ResizedFileHolder.DirectoryName, face.Mapping.MappingFromItem.ContainerDateTimes));
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
if (mapping.MappingFromItem.ResizedFileHolder.DirectoryName is null || !mapping.MappingFromItem.ResizedFileHolder.Exists)
|
||||
continue;
|
||||
if (mapping.By is null or IMapLogic.Sorting || mapping.MappingFromPerson?.ApproximateYears is null)
|
||||
continue;
|
||||
if (string.IsNullOrEmpty(mapping.MappingFromPerson.SegmentB))
|
||||
throw new NotSupportedException();
|
||||
if (string.IsNullOrEmpty(mapping.MappingFromPerson.DisplayDirectoryName))
|
||||
throw new NotSupportedException();
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, mapping.MappingFromPerson.PersonBirthday);
|
||||
}
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
@ -979,6 +1030,11 @@ public class MapLogic
|
||||
continue;
|
||||
if (mapping.By is null or IMapLogic.Sorting || mapping.MappingFromPerson?.ApproximateYears is null)
|
||||
{
|
||||
if (mapping.MappingFromItem.ContainerDateTimes.Any() && !distinct.Contains(mapping.MappingFromItem.ResizedFileHolder.DirectoryName))
|
||||
{
|
||||
distinct.Add(mapping.MappingFromItem.ResizedFileHolder.DirectoryName);
|
||||
directoriesAndDateTimes.Add(new(mapping.MappingFromItem.ResizedFileHolder.DirectoryName, mapping.MappingFromItem.ContainerDateTimes));
|
||||
}
|
||||
directory = Path.Combine(mapping.MappingFromItem.ResizedFileHolder.DirectoryName, $"{_PropertyConfiguration.ResultAllInOne}Shortcuts", _PropertyConfiguration.ResultAllInOne);
|
||||
personDirectory = Path.Combine(directory, "Unknown");
|
||||
fileName = Path.Combine(personDirectory, $"{mapping.MappingFromItem.ResizedFileHolder.Name}.lnk");
|
||||
@ -991,9 +1047,12 @@ public class MapLogic
|
||||
if (string.IsNullOrEmpty(mapping.MappingFromPerson.DisplayDirectoryName))
|
||||
throw new NotSupportedException();
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, mapping.MappingFromPerson.PersonBirthday);
|
||||
if (!personKeyFormattedCollection.Contains(personKeyFormatted))
|
||||
continue;
|
||||
personKey = mapping.MappingFromPerson.PersonBirthday.Value.Ticks;
|
||||
if (mapping.MappingFromItem.ContainerDateTimes.Any() && !distinct.Contains(mapping.MappingFromItem.ResizedFileHolder.DirectoryName))
|
||||
{
|
||||
distinct.Add(mapping.MappingFromItem.ResizedFileHolder.DirectoryName);
|
||||
directoriesAndDateTimes.Add(new(mapping.MappingFromItem.ResizedFileHolder.DirectoryName, mapping.MappingFromItem.ContainerDateTimes));
|
||||
}
|
||||
directory = Path.Combine(mapping.MappingFromItem.ResizedFileHolder.DirectoryName, $"{_PropertyConfiguration.ResultAllInOne}Shortcuts", personKeyFormatted);
|
||||
if (!personKeyToCount.ContainsKey(personKey))
|
||||
personDirectory = Path.Combine(directory, mapping.MappingFromPerson.DisplayDirectoryName);
|
||||
@ -1003,16 +1062,17 @@ public class MapLogic
|
||||
collection.Add(new(mapping.MappingFromItem.ResizedFileHolder.FullName, personDirectory, fileName, mapping.MappingFromLocation.DeterministicHashCodeKey));
|
||||
}
|
||||
}
|
||||
return collection;
|
||||
return new(directoriesAndDateTimes, collection);
|
||||
}
|
||||
|
||||
public void SaveShortcuts(string a2PeopleSingletonDirectory, PersonContainer[] personContainers, List<Item> filteredItems, Mapping[] mappingCollection, Dictionary<long, int> personKeyToCount)
|
||||
public void SaveShortcutsForOutputResolutions(List<Item> filteredItems, Mapping[] mappingCollection, Dictionary<long, int> personKeyToCount)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
WindowsShortcut windowsShortcut;
|
||||
string[] jLinks = new string[] { "All" };
|
||||
List<(string, string Directory, string, string)> collection = GetCollectionForSaveShortcuts(jLinks, a2PeopleSingletonDirectory, personContainers, filteredItems, mappingCollection, personKeyToCount);
|
||||
List<(string, DateTime[])> directoriesAndDateTimes;
|
||||
List<(string, string Directory, string, string)> collection;
|
||||
(directoriesAndDateTimes, collection) = GetCollectionForSaveShortcutsForOutputResolutions(filteredItems, mappingCollection, personKeyToCount);
|
||||
string[] directories = (from l in collection select l.Directory).Distinct().ToArray();
|
||||
foreach (string directory in directories)
|
||||
{
|
||||
@ -1034,9 +1094,16 @@ public class MapLogic
|
||||
catch (Exception)
|
||||
{ }
|
||||
}
|
||||
foreach ((string directory, DateTime[] dateTimes) in directoriesAndDateTimes)
|
||||
{
|
||||
if (!dateTimes.Any())
|
||||
continue;
|
||||
Directory.SetCreationTime(directory, dateTimes[0]);
|
||||
Directory.SetLastWriteTime(directory, dateTimes[1]);
|
||||
}
|
||||
}
|
||||
|
||||
private List<(string, FileHolder, string)> GetCollection(string dFacesContentDirectory, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedPixelPercentageToMapping)
|
||||
private List<(string, FileHolder, string)> GetCollection(string dFacesContentDirectory, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
@ -1047,19 +1114,19 @@ public class MapLogic
|
||||
string? directoryName;
|
||||
string? facesDirectory;
|
||||
FileHolder faceFileHolder;
|
||||
List<int>? normalizedPixelPercentages;
|
||||
List<int>? normalizedRectangles;
|
||||
string by = nameof(IMapLogic.CopyNotMappedFaces);
|
||||
Dictionary<int, PersonContainer[]>? normalizedPixelPercentageToPersonContainers;
|
||||
foreach (KeyValuePair<int, Dictionary<int, Mapping>> keyValuePair in idToNormalizedPixelPercentageToMapping)
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
foreach (KeyValuePair<int, Dictionary<int, Mapping>> keyValuePair in idToNormalizedRectangleToMapping)
|
||||
{
|
||||
_ = _IdThenNormalizedPixelPercentageToPersonContainers.TryGetValue(keyValuePair.Key, out normalizedPixelPercentageToPersonContainers);
|
||||
foreach (KeyValuePair<int, Mapping> normalizedPixelPercentageAndMapping in keyValuePair.Value)
|
||||
_ = _IdThenNormalizedRectangleToPersonContainers.TryGetValue(keyValuePair.Key, out normalizedRectangleToPersonContainers);
|
||||
foreach (KeyValuePair<int, Mapping> normalizedRectangleAndMapping in keyValuePair.Value)
|
||||
{
|
||||
mapping = normalizedPixelPercentageAndMapping.Value;
|
||||
if (normalizedPixelPercentageToPersonContainers is not null && normalizedPixelPercentageToPersonContainers.ContainsKey(mapping.MappingFromLocation.NormalizedPixelPercentage))
|
||||
mapping = normalizedRectangleAndMapping.Value;
|
||||
if (normalizedRectangleToPersonContainers is not null && normalizedRectangleToPersonContainers.ContainsKey(mapping.MappingFromLocation.NormalizedRectangle))
|
||||
continue;
|
||||
_ = _SkipCollection.TryGetValue(keyValuePair.Key, out normalizedPixelPercentages);
|
||||
if (normalizedPixelPercentages is not null && normalizedPixelPercentages.Contains(mapping.MappingFromLocation.NormalizedPixelPercentage))
|
||||
_ = _SkipCollection.TryGetValue(keyValuePair.Key, out normalizedRectangles);
|
||||
if (normalizedRectangles is not null && normalizedRectangles.Contains(mapping.MappingFromLocation.NormalizedRectangle))
|
||||
continue;
|
||||
directoryName = Path.GetDirectoryName(mapping.MappingFromItem.RelativePath);
|
||||
facesDirectory = GetFacesDirectory(dFacesContentDirectory, mapping.MappingFromItem); // Path.Combine($"{dFacesContentDirectory}{directoryName}", mapping.MappingFromItem.ImageFileHolder.NameWithoutExtension);
|
||||
@ -1076,11 +1143,11 @@ public class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
public void CopyNotMappedFaces(int[] rangeFaceAreaPermilleTolerance, string dFacesContentDirectory, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedPixelPercentageToMapping)
|
||||
public void CopyNotMappedFaces(int[] rangeFaceAreaPermilleTolerance, string dFacesContentDirectory, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
List<(string Directory, FileHolder FaceFileHolder, string CheckFile)> collection = GetCollection(dFacesContentDirectory, idToNormalizedPixelPercentageToMapping);
|
||||
List<(string Directory, FileHolder FaceFileHolder, string CheckFile)> collection = GetCollection(dFacesContentDirectory, idToNormalizedRectangleToMapping);
|
||||
string[] directories = (from l in collection select l.Directory).Distinct().ToArray();
|
||||
foreach (string directory in directories)
|
||||
{
|
||||
@ -1097,4 +1164,249 @@ public class MapLogic
|
||||
}
|
||||
}
|
||||
|
||||
private DatabaseFileRoot GetDatabaseFileRoot()
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
string file = Path.Combine(_Configuration.PhotoPrismDirectory, "files.json");
|
||||
string json = File.ReadAllText(file);
|
||||
DatabaseFileRoot? databaseFileRoot = JsonSerializer.Deserialize<DatabaseFileRoot>(json);
|
||||
if (databaseFileRoot is null)
|
||||
throw new NullReferenceException(nameof(databaseFileRoot));
|
||||
return databaseFileRoot;
|
||||
}
|
||||
|
||||
private Marker[] GetMarkers()
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
string file = Path.Combine(_Configuration.PhotoPrismDirectory, "markers.json");
|
||||
string json = File.ReadAllText(file);
|
||||
Marker[]? markerRoot = JsonSerializer.Deserialize<Marker[]>(json);
|
||||
if (markerRoot is null)
|
||||
throw new NullReferenceException(nameof(markerRoot));
|
||||
return markerRoot;
|
||||
}
|
||||
|
||||
private static Dictionary<string, DatabaseFile> Get(DatabaseFileRoot databaseFileRoot)
|
||||
{
|
||||
Dictionary<string, DatabaseFile> fileUidToFile = new();
|
||||
for (int i = 0; i < databaseFileRoot.Files.Count; i++)
|
||||
fileUidToFile.Add(databaseFileRoot.Files[i].FileUid, databaseFileRoot.Files[i]);
|
||||
return fileUidToFile;
|
||||
}
|
||||
|
||||
private static MarkerWith GetMarkerWith(int? dlib, DatabaseFile databaseFile, Marker marker, int? count, double? percent, int? normalizedRectangle, long? personKey, string personKeyFormatted)
|
||||
{
|
||||
return new(marker.MarkerUid,
|
||||
marker.FileUid,
|
||||
marker.MarkerType,
|
||||
marker.MarkerSrc,
|
||||
marker.MarkerName,
|
||||
marker.MarkerReview,
|
||||
marker.MarkerInvalid,
|
||||
marker.SubjUid,
|
||||
marker.SubjSrc,
|
||||
marker.FaceId,
|
||||
marker.FaceDist,
|
||||
marker.EmbeddingsJson,
|
||||
marker.LandmarksJson,
|
||||
marker.X,
|
||||
marker.Y,
|
||||
marker.W,
|
||||
marker.H,
|
||||
marker.Q,
|
||||
marker.Size,
|
||||
marker.Score,
|
||||
marker.Thumb,
|
||||
marker.MatchedAt,
|
||||
marker.CreatedAt,
|
||||
marker.UpdatedAt,
|
||||
databaseFile.Id,
|
||||
databaseFile.FileName,
|
||||
dlib,
|
||||
count,
|
||||
percent,
|
||||
normalizedRectangle,
|
||||
personKey,
|
||||
personKeyFormatted);
|
||||
}
|
||||
|
||||
private static Dictionary<string, List<Face>> GetFacesByFileName(List<Item> filteredItems)
|
||||
{
|
||||
Dictionary<string, List<Face>> results = new();
|
||||
string key;
|
||||
foreach (Item item in filteredItems)
|
||||
{
|
||||
foreach (Face face in item.Faces)
|
||||
{
|
||||
if (face.FaceEncoding is null || face.Location is null || face.OutputResolution is null || face.Mapping is null)
|
||||
continue;
|
||||
key = Path.GetFileNameWithoutExtension(face.Mapping.MappingFromItem.RelativePath);
|
||||
if (!results.ContainsKey(key))
|
||||
results.Add(key, new());
|
||||
results[key].Add(face);
|
||||
}
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
public void FindMatch(List<Item> filteredItems)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
int? dlib;
|
||||
double? percent;
|
||||
long? personKey;
|
||||
const int zero = 0;
|
||||
List<Face>? matches;
|
||||
MarkerWith markerWith;
|
||||
int? normalizedRectangle;
|
||||
string personKeyFormatted;
|
||||
DatabaseFile? databaseFile;
|
||||
PersonBirthday personBirthday;
|
||||
Marker[] markers = GetMarkers();
|
||||
string fileNameWithoutExtension;
|
||||
PersonContainer[]? personContainers;
|
||||
System.Drawing.Rectangle dlibRectangle;
|
||||
System.Drawing.Rectangle prismRectangle;
|
||||
System.Drawing.Rectangle intersectRectangle;
|
||||
(Face Face, double Percent)[] sortedCollection;
|
||||
List<(Face Face, double Percent)> collection = new();
|
||||
DatabaseFileRoot databaseFileRoot = GetDatabaseFileRoot();
|
||||
Dictionary<string, DatabaseFile> fileUidToFile = Get(databaseFileRoot);
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
Dictionary<string, List<Face>> keyValuePairs = GetFacesByFileName(filteredItems);
|
||||
foreach (Marker marker in markers)
|
||||
{
|
||||
dlib = null;
|
||||
personKey = null;
|
||||
collection.Clear();
|
||||
normalizedRectangle = null;
|
||||
personKeyFormatted = string.Empty;
|
||||
normalizedRectangleToPersonContainers = null;
|
||||
if (!fileUidToFile.TryGetValue(marker.FileUid, out databaseFile))
|
||||
continue;
|
||||
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(Path.Combine("C:", databaseFile.FileName));
|
||||
prismRectangle = new((int)(marker.X * databaseFile.FileWidth), (int)(marker.Y * databaseFile.FileHeight), (int)(marker.W * databaseFile.FileWidth), (int)(marker.H * databaseFile.FileHeight));
|
||||
if (!keyValuePairs.TryGetValue(fileNameWithoutExtension, out matches) || !int.TryParse(fileNameWithoutExtension, out int id))
|
||||
percent = null;
|
||||
else
|
||||
{
|
||||
dlib = id;
|
||||
_ = _IdThenNormalizedRectangleToPersonContainers.TryGetValue(dlib.Value, out normalizedRectangleToPersonContainers);
|
||||
foreach (Face face in matches)
|
||||
{
|
||||
if (face.Location is null || face.OutputResolution is null)
|
||||
continue;
|
||||
dlibRectangle = new(face.Location.Left, face.Location.Top, face.Location.Right - face.Location.Left, face.Location.Bottom - face.Location.Top);
|
||||
intersectRectangle = System.Drawing.Rectangle.Intersect(prismRectangle, dlibRectangle);
|
||||
if (intersectRectangle.Width == 0 || intersectRectangle.Height == 0)
|
||||
continue;
|
||||
percent = (double)intersectRectangle.Width * intersectRectangle.Height / (dlibRectangle.Width * dlibRectangle.Height);
|
||||
if (percent < 0.000001)
|
||||
continue;
|
||||
collection.Add(new(face, percent.Value));
|
||||
}
|
||||
}
|
||||
if (!collection.Any())
|
||||
percent = null;
|
||||
else
|
||||
{
|
||||
sortedCollection = collection.OrderByDescending(l => l.Percent).ToArray();
|
||||
percent = sortedCollection[zero].Percent;
|
||||
normalizedRectangle = sortedCollection[zero].Face.Mapping?.MappingFromLocation.NormalizedRectangle;
|
||||
if (normalizedRectangleToPersonContainers is null || normalizedRectangle is null || !normalizedRectangleToPersonContainers.TryGetValue(normalizedRectangle.Value, out personContainers))
|
||||
personContainers = null;
|
||||
else
|
||||
{
|
||||
foreach (PersonContainer personContainer in personContainers)
|
||||
{
|
||||
if (personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
|
||||
continue;
|
||||
personBirthday = personContainer.Birthdays[zero];
|
||||
personKey = personBirthday.Value.Ticks;
|
||||
personKeyFormatted = IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, personBirthday);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
markerWith = GetMarkerWith(dlib, databaseFile, marker, collection.Count, percent, normalizedRectangle, personKey, personKeyFormatted);
|
||||
string json = JsonSerializer.Serialize(markerWith, new JsonSerializerOptions() { WriteIndented = true });
|
||||
if (IPath.WriteAllText(Path.Combine(_Configuration.PhotoPrismDirectory, "With", $"{marker.MarkerUid}.json"), json, updateDateWhenMatches: false, compareBeforeWrite: true))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveMarkers()
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
double[]? encoding;
|
||||
string file = Path.Combine(_Configuration.PhotoPrismDirectory, "markers.json");
|
||||
string json = File.ReadAllText(file);
|
||||
Marker[]? markers = JsonSerializer.Deserialize<Marker[]>(json);
|
||||
if (markers is null)
|
||||
throw new NullReferenceException(nameof(markers));
|
||||
foreach (Marker marker in markers)
|
||||
{
|
||||
encoding = JsonSerializer.Deserialize<double[]>(marker.EmbeddingsJson[1..^1]);
|
||||
File.WriteAllText(Path.Combine(_Configuration.PhotoPrismDirectory, "EmbeddingsJson", $"{marker.MarkerUid}.json"), marker.EmbeddingsJson);
|
||||
if (encoding is null)
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadMatches()
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
string json;
|
||||
MarkerWith? markerWith;
|
||||
List<MarkerWith> collection = new();
|
||||
StringBuilder stringBuilder = new();
|
||||
List<(int Count, MarkerWith MarkerWith)> countCollection = new();
|
||||
List<(double Percent, MarkerWith MarkerWith)> percentCollection = new();
|
||||
string[] files = Directory.GetFiles(Path.Combine(_Configuration.PhotoPrismDirectory, "With"), "*.json", SearchOption.TopDirectoryOnly);
|
||||
foreach (string file in files)
|
||||
{
|
||||
json = File.ReadAllText(file);
|
||||
markerWith = JsonSerializer.Deserialize<MarkerWith>(json);
|
||||
if (markerWith is null || markerWith.DlibId is null)
|
||||
continue;
|
||||
collection.Add(markerWith);
|
||||
if (markerWith.Count is null || markerWith.Count.Value == 0)
|
||||
continue;
|
||||
countCollection.Add(new(markerWith.Count.Value, markerWith));
|
||||
if (markerWith.Percent is null)
|
||||
continue;
|
||||
percentCollection.Add(new(markerWith.Percent.Value, markerWith));
|
||||
if (string.IsNullOrEmpty(markerWith.PersonKeyFormatted))
|
||||
continue;
|
||||
_ = stringBuilder.
|
||||
Append("update `markers` set subj_src = 'manual' marker_name = '").
|
||||
Append(markerWith.PersonKeyFormatted).
|
||||
Append("' where marker_uid = '").
|
||||
Append(markerWith.MarkerUid).
|
||||
AppendLine("';");
|
||||
}
|
||||
(int, MarkerWith)[] countSorted = countCollection.OrderByDescending(l => l.Count).ToArray();
|
||||
(double, MarkerWith)[] percentSorted = percentCollection.OrderBy(l => l.Percent).ToArray();
|
||||
if (collection.Any())
|
||||
{ }
|
||||
File.WriteAllText(Path.Combine(_Configuration.PhotoPrismDirectory, "marker_name_update.sql"), stringBuilder.ToString());
|
||||
}
|
||||
|
||||
public Dictionary<int, Dictionary<int, PersonContainer[]>> GetMissing(Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping)
|
||||
{
|
||||
Dictionary<int, Dictionary<int, PersonContainer[]>> results = new();
|
||||
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> normalizedRectangleToPersonContainers in _IdThenNormalizedRectangleToPersonContainers)
|
||||
{
|
||||
if (idToNormalizedRectangleToMapping.ContainsKey(normalizedRectangleToPersonContainers.Key))
|
||||
continue;
|
||||
results.Add(normalizedRectangleToPersonContainers.Key, normalizedRectangleToPersonContainers.Value);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
@ -39,7 +39,7 @@ internal abstract class MapLogic
|
||||
int? id;
|
||||
long personKey;
|
||||
string personKeyFormatted;
|
||||
int? normalizedPixelPercentage;
|
||||
int? normalizedRectangle;
|
||||
string newestPersonKeyFormatted;
|
||||
foreach (PersonContainer personContainer in personContainers)
|
||||
{
|
||||
@ -47,12 +47,12 @@ internal abstract class MapLogic
|
||||
{
|
||||
if (!personDisplayDirectoryAllFile.EndsWith(configuration.FacesFileNameExtension))
|
||||
continue;
|
||||
(id, normalizedPixelPercentage, _) = IMapping.GetReversedDeterministicHashCodeKey(configuration.FacesFileNameExtension, personDisplayDirectoryAllFile);
|
||||
if (id is null || normalizedPixelPercentage is null)
|
||||
(id, normalizedRectangle, _) = IMapping.GetConverted(configuration.FacesFileNameExtension, personDisplayDirectoryAllFile);
|
||||
if (id is null || normalizedRectangle is null)
|
||||
continue;
|
||||
if (!skipCollection.ContainsKey(id.Value))
|
||||
skipCollection.Add(id.Value, new());
|
||||
skipCollection[id.Value].Add(normalizedPixelPercentage.Value);
|
||||
skipCollection[id.Value].Add(normalizedRectangle.Value);
|
||||
}
|
||||
if (personContainer.Person is null || personContainer.Key is null || personContainer.Birthdays is null || !personContainer.Birthdays.Any())
|
||||
continue;
|
||||
@ -86,7 +86,7 @@ internal abstract class MapLogic
|
||||
string? personFirstInitial;
|
||||
DirectoryInfo directoryInfo;
|
||||
string[] personKeyDirectories;
|
||||
int? normalizedPixelPercentage;
|
||||
int? normalizedRectangle;
|
||||
string[] personNameDirectories;
|
||||
string[] personNameLinkDirectories;
|
||||
string? personFirstInitialDirectory;
|
||||
@ -141,6 +141,16 @@ internal abstract class MapLogic
|
||||
else
|
||||
{
|
||||
personFirstInitial = personDisplayDirectoryNames[^1][..1];
|
||||
if (personFirstInitial.All(l => char.IsDigit(l)))
|
||||
{
|
||||
foreach (string file in files)
|
||||
File.Delete(file);
|
||||
files = Directory.GetFiles(personNameDirectory, "*", SearchOption.AllDirectories);
|
||||
foreach (string file in files)
|
||||
File.Delete(file);
|
||||
_ = IPath.DeleteEmptyDirectories(personNameDirectory);
|
||||
continue;
|
||||
}
|
||||
personFirstInitialDirectory = Path.Combine(yearDirectory, personFirstInitial.ToString());
|
||||
Directory.Move(personNameDirectory, personFirstInitialDirectory);
|
||||
files = Directory.GetFiles(personFirstInitialDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
@ -149,8 +159,8 @@ internal abstract class MapLogic
|
||||
{
|
||||
if (file.EndsWith(".lnk") || file.EndsWith(".json"))
|
||||
continue;
|
||||
(id, normalizedPixelPercentage, _) = IMapping.GetReversedDeterministicHashCodeKey(configuration.FacesFileNameExtension, file);
|
||||
if (id is null || normalizedPixelPercentage is null)
|
||||
(id, normalizedRectangle, _) = IMapping.GetConverted(configuration.FacesFileNameExtension, file);
|
||||
if (id is null || normalizedRectangle is null)
|
||||
continue;
|
||||
results.Add(new(personKeyFormatted, personDisplayDirectoryNames, file));
|
||||
}
|
||||
@ -182,15 +192,15 @@ internal abstract class MapLogic
|
||||
{
|
||||
Dictionary<int, List<(string, int)>> results = new();
|
||||
int? id;
|
||||
int? normalizedPixelPercentage;
|
||||
int? normalizedRectangle;
|
||||
foreach ((string personKeyFormatted, string[] personDisplayDirectoryNames, string mappedFaceFile) in collection)
|
||||
{
|
||||
(id, normalizedPixelPercentage, _) = IMapping.GetReversedDeterministicHashCodeKey(configuration.FacesFileNameExtension, mappedFaceFile);
|
||||
if (id is null || normalizedPixelPercentage is null)
|
||||
(id, normalizedRectangle, _) = IMapping.GetConverted(configuration.FacesFileNameExtension, mappedFaceFile);
|
||||
if (id is null || normalizedRectangle is null)
|
||||
continue;
|
||||
if (!results.ContainsKey(id.Value))
|
||||
results.Add(id.Value, new());
|
||||
results[id.Value].Add(new(mappedFaceFile, normalizedPixelPercentage.Value));
|
||||
results[id.Value].Add(new(mappedFaceFile, normalizedRectangle.Value));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
@ -211,7 +221,11 @@ internal abstract class MapLogic
|
||||
if (!Directory.Exists(eDistanceContentDirectory))
|
||||
_ = Directory.CreateDirectory(eDistanceContentDirectory);
|
||||
else
|
||||
{
|
||||
_ = IPath.DeleteEmptyDirectories(eDistanceContentDirectory);
|
||||
if (!Directory.Exists(eDistanceContentDirectory))
|
||||
_ = Directory.CreateDirectory(eDistanceContentDirectory);
|
||||
}
|
||||
ticksDirectories = Directory.GetDirectories(eDistanceContentDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
}
|
||||
string message = $") {ticksDirectories.Length:000} collect from and clean ticks Director(ies) - A - {totalSeconds} total second(s)";
|
||||
@ -246,23 +260,23 @@ internal abstract class MapLogic
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
private static void SetKeyValuePairs(Configuration configuration, long ticks, List<PersonContainer> personContainers, Mapping[] mappingCollection, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers, List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedPixelPercentageToPersonContainers, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges)
|
||||
private static void SetKeyValuePairs(Configuration configuration, long ticks, List<PersonContainer> personContainers, Mapping[] mappingCollection, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers, List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedRectangleToPersonContainers, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges)
|
||||
{
|
||||
PersonBirthday? personBirthday;
|
||||
PersonContainer[] distinctPersonContainers;
|
||||
Dictionary<string, PersonContainer> personKeyFormattedToPersonContainer = new();
|
||||
Dictionary<int, Dictionary<int, List<PersonContainer>>> idThenNormalizedPixelPercentageToPersonContainerCollection = new();
|
||||
Dictionary<int, Dictionary<int, List<PersonContainer>>> incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection = new();
|
||||
Dictionary<int, Dictionary<int, List<PersonContainer>>> idThenNormalizedRectangleToPersonContainerCollection = new();
|
||||
Dictionary<int, Dictionary<int, List<PersonContainer>>> incorrectIdThenNormalizedRectangleToPersonContainerCollection = new();
|
||||
List<(long, PersonContainer)> collection = GetDistinctCollection(configuration, personContainers, personKeyFormattedToPersonContainer);
|
||||
foreach ((long personKey, PersonContainer personContainer) in collection)
|
||||
personKeyToPersonContainer.Add(personKey, personContainer);
|
||||
if (personKeyFormattedIdThenNormalizedPixelPercentageCollection.Any())
|
||||
if (personKeyFormattedIdThenNormalizedRectangleCollection.Any())
|
||||
{
|
||||
string personDisplayDirectory;
|
||||
PersonContainer personContainer;
|
||||
string personDisplayDirectoryName;
|
||||
Dictionary<string, (string[], PersonContainer)> personDisplayDirectoryTo = new();
|
||||
foreach ((string personKeyFormatted, string[] personDisplayDirectoryNames, int id, int normalizedPixelPercentage) in personKeyFormattedIdThenNormalizedPixelPercentageCollection)
|
||||
foreach ((string personKeyFormatted, string[] personDisplayDirectoryNames, int id, int normalizedRectangle) in personKeyFormattedIdThenNormalizedRectangleCollection)
|
||||
{
|
||||
personBirthday = IPersonBirthday.GetPersonBirthday(configuration.PersonBirthdayFormat, personKeyFormatted);
|
||||
if (personBirthday is null)
|
||||
@ -276,52 +290,52 @@ internal abstract class MapLogic
|
||||
}
|
||||
if (personDisplayDirectoryName.Length != 1 && personDisplayDirectoryName != configuration.MappingDefaultName && !personDisplayDirectoryTo.ContainsKey(personDisplayDirectory))
|
||||
personDisplayDirectoryTo.Add(personDisplayDirectory, new(personDisplayDirectoryNames, personKeyFormattedToPersonContainer[personKeyFormatted]));
|
||||
if (!idThenNormalizedPixelPercentageToPersonContainerCollection.ContainsKey(id))
|
||||
idThenNormalizedPixelPercentageToPersonContainerCollection.Add(id, new());
|
||||
if (!idThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentage))
|
||||
idThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentage, new());
|
||||
idThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
||||
if (!idThenNormalizedRectangleToPersonContainerCollection.ContainsKey(id))
|
||||
idThenNormalizedRectangleToPersonContainerCollection.Add(id, new());
|
||||
if (!idThenNormalizedRectangleToPersonContainerCollection[id].ContainsKey(normalizedRectangle))
|
||||
idThenNormalizedRectangleToPersonContainerCollection[id].Add(normalizedRectangle, new());
|
||||
idThenNormalizedRectangleToPersonContainerCollection[id][normalizedRectangle].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
||||
}
|
||||
foreach (KeyValuePair<string, (string[], PersonContainer)> keyValuePair in personDisplayDirectoryTo)
|
||||
possiblyNewPersonDisplayDirectoryNamesAndPersonContainer.Add(keyValuePair.Value);
|
||||
}
|
||||
foreach (KeyValuePair<int, Dictionary<int, List<PersonContainer>>> keyValuePair in idThenNormalizedPixelPercentageToPersonContainerCollection)
|
||||
foreach (KeyValuePair<int, Dictionary<int, List<PersonContainer>>> keyValuePair in idThenNormalizedRectangleToPersonContainerCollection)
|
||||
{
|
||||
idThenNormalizedPixelPercentageToPersonContainers.Add(keyValuePair.Key, new());
|
||||
idThenNormalizedRectangleToPersonContainers.Add(keyValuePair.Key, new());
|
||||
foreach (KeyValuePair<int, List<PersonContainer>> innerKeyValuePair in keyValuePair.Value)
|
||||
{
|
||||
distinctPersonContainers = GetDistinctPersonContainers(innerKeyValuePair.Value);
|
||||
idThenNormalizedPixelPercentageToPersonContainers[keyValuePair.Key].Add(innerKeyValuePair.Key, distinctPersonContainers);
|
||||
idThenNormalizedRectangleToPersonContainers[keyValuePair.Key].Add(innerKeyValuePair.Key, distinctPersonContainers);
|
||||
}
|
||||
};
|
||||
SetPersonTicks(configuration, ticks, mappingCollection, personKeyToRanges, idThenNormalizedPixelPercentageToPersonContainers);
|
||||
if (incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection.Any())
|
||||
SetPersonTicks(configuration, ticks, mappingCollection, personKeyToRanges, idThenNormalizedRectangleToPersonContainers);
|
||||
if (incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection.Any())
|
||||
{
|
||||
PersonContainer personContainer;
|
||||
foreach ((string personKeyFormatted, int id, int normalizedPixelPercentage) in incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection)
|
||||
foreach ((string personKeyFormatted, int id, int normalizedRectangle) in incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection)
|
||||
{
|
||||
personBirthday = IPersonBirthday.GetPersonBirthday(configuration.PersonBirthdayFormat, personKeyFormatted);
|
||||
if (personBirthday is null)
|
||||
continue;
|
||||
if (!incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection.ContainsKey(id))
|
||||
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection.Add(id, new());
|
||||
if (!incorrectIdThenNormalizedRectangleToPersonContainerCollection.ContainsKey(id))
|
||||
incorrectIdThenNormalizedRectangleToPersonContainerCollection.Add(id, new());
|
||||
if (!personKeyFormattedToPersonContainer.ContainsKey(personKeyFormatted))
|
||||
{
|
||||
personContainer = new(personBirthday, configuration.MappingDefaultName);
|
||||
personKeyFormattedToPersonContainer.Add(personKeyFormatted, personContainer);
|
||||
}
|
||||
if (!incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].ContainsKey(normalizedPixelPercentage))
|
||||
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id].Add(normalizedPixelPercentage, new());
|
||||
incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection[id][normalizedPixelPercentage].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
||||
if (!incorrectIdThenNormalizedRectangleToPersonContainerCollection[id].ContainsKey(normalizedRectangle))
|
||||
incorrectIdThenNormalizedRectangleToPersonContainerCollection[id].Add(normalizedRectangle, new());
|
||||
incorrectIdThenNormalizedRectangleToPersonContainerCollection[id][normalizedRectangle].Add(personKeyFormattedToPersonContainer[personKeyFormatted]);
|
||||
}
|
||||
}
|
||||
foreach (KeyValuePair<int, Dictionary<int, List<PersonContainer>>> keyValuePair in incorrectIdThenNormalizedPixelPercentageToPersonContainerCollection)
|
||||
foreach (KeyValuePair<int, Dictionary<int, List<PersonContainer>>> keyValuePair in incorrectIdThenNormalizedRectangleToPersonContainerCollection)
|
||||
{
|
||||
incorrectIdThenNormalizedPixelPercentageToPersonContainers.Add(keyValuePair.Key, new());
|
||||
incorrectIdThenNormalizedRectangleToPersonContainers.Add(keyValuePair.Key, new());
|
||||
foreach (KeyValuePair<int, List<PersonContainer>> innerKeyValuePair in keyValuePair.Value)
|
||||
{
|
||||
distinctPersonContainers = GetDistinctPersonContainers(innerKeyValuePair.Value);
|
||||
incorrectIdThenNormalizedPixelPercentageToPersonContainers[keyValuePair.Key].Add(innerKeyValuePair.Key, distinctPersonContainers);
|
||||
incorrectIdThenNormalizedRectangleToPersonContainers[keyValuePair.Key].Add(innerKeyValuePair.Key, distinctPersonContainers);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -352,19 +366,19 @@ internal abstract class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
private static (int, int) SetCollectionsAndGetUnableToMatchCount(Configuration configuration, long ticks, Dictionary<int, List<Mapping>> idToMappingCollection, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, List<(string, string[], string)> collection)
|
||||
private static (int, int) SetCollectionsAndGetUnableToMatchCount(Configuration configuration, long ticks, Dictionary<int, List<Mapping>> idToMappingCollection, Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted, List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection, List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, List<(string, string[], string)> collection)
|
||||
{
|
||||
int result = 0;
|
||||
int? id;
|
||||
int? normalizedPixelPercentage;
|
||||
int? normalizedRectangle;
|
||||
string newestPersonKeyFormatted;
|
||||
List<Mapping>? mappingCollection;
|
||||
string personDisplayDirectoryName;
|
||||
List<int> normalizedPixelPercentages;
|
||||
List<int> normalizedRectangles;
|
||||
List<Mapping> checkMappingCollection = new();
|
||||
List<string> duplicateMappedFaceFiles = new();
|
||||
bool idToMappingCollectionAny = idToMappingCollection.Any();
|
||||
Dictionary<int, List<int>> idToNormalizedPixelPercentages = new();
|
||||
Dictionary<int, List<int>> idToNormalizedRectangles = new();
|
||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
string message = $") {collection.Count:000} join from ticks Director(ies) - C - {totalSeconds} total second(s)";
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
@ -372,53 +386,51 @@ internal abstract class MapLogic
|
||||
foreach ((string personKeyFormatted, string[] personDisplayDirectoryNames, string mappedFaceFile) in collection)
|
||||
{
|
||||
progressBar.Tick();
|
||||
(id, normalizedPixelPercentage, mappingCollection) = IMapping.GetReversedDeterministicHashCodeKey(configuration.FacesFileNameExtension, idToMappingCollectionAny, idToMappingCollection, mappedFaceFile);
|
||||
if (id is null || normalizedPixelPercentage is null)
|
||||
{
|
||||
result++;
|
||||
continue;
|
||||
}
|
||||
if (!idToNormalizedPixelPercentages.ContainsKey(id.Value))
|
||||
idToNormalizedPixelPercentages.Add(id.Value, new());
|
||||
normalizedPixelPercentages = idToNormalizedPixelPercentages[id.Value];
|
||||
if (mappingCollection is null)
|
||||
(id, normalizedRectangle, mappingCollection) = IMapping.GetConverted(configuration.FacesFileNameExtension, idToMappingCollectionAny, idToMappingCollection, mappedFaceFile);
|
||||
if (id is null || normalizedRectangle is null)
|
||||
{
|
||||
result++;
|
||||
continue;
|
||||
}
|
||||
if (!idToNormalizedRectangles.ContainsKey(id.Value))
|
||||
idToNormalizedRectangles.Add(id.Value, new());
|
||||
normalizedRectangles = idToNormalizedRectangles[id.Value];
|
||||
checkMappingCollection.Clear();
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
if (mappingCollection is not null)
|
||||
{
|
||||
if (normalizedPixelPercentage.Value != mapping.MappingFromLocation.NormalizedPixelPercentage)
|
||||
continue;
|
||||
if (normalizedPixelPercentages.Contains(mapping.MappingFromLocation.NormalizedPixelPercentage))
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
duplicateMappedFaceFiles.Add(mappedFaceFile);
|
||||
if (normalizedRectangle.Value != mapping.MappingFromLocation.NormalizedRectangle)
|
||||
continue;
|
||||
if (normalizedRectangles.Contains(mapping.MappingFromLocation.NormalizedRectangle))
|
||||
{
|
||||
duplicateMappedFaceFiles.Add(mappedFaceFile);
|
||||
continue;
|
||||
}
|
||||
checkMappingCollection.Add(mapping);
|
||||
}
|
||||
if (!checkMappingCollection.Any())
|
||||
{
|
||||
result++;
|
||||
continue;
|
||||
}
|
||||
if (checkMappingCollection.Count != 1)
|
||||
{
|
||||
result++;
|
||||
continue;
|
||||
}
|
||||
checkMappingCollection.Add(mapping);
|
||||
}
|
||||
if (!checkMappingCollection.Any())
|
||||
{
|
||||
result++;
|
||||
continue;
|
||||
}
|
||||
if (checkMappingCollection.Count != 1)
|
||||
{
|
||||
result++;
|
||||
continue;
|
||||
}
|
||||
normalizedPixelPercentages.Add(normalizedPixelPercentage.Value);
|
||||
idToNormalizedPixelPercentages[id.Value].Add(normalizedPixelPercentage.Value);
|
||||
normalizedRectangles.Add(normalizedRectangle.Value);
|
||||
idToNormalizedRectangles[id.Value].Add(normalizedRectangle.Value);
|
||||
if (!personKeyFormattedToNewestPersonKeyFormatted.ContainsKey(personKeyFormatted))
|
||||
newestPersonKeyFormatted = personKeyFormatted;
|
||||
else
|
||||
newestPersonKeyFormatted = personKeyFormattedToNewestPersonKeyFormatted[personKeyFormatted];
|
||||
personDisplayDirectoryName = personDisplayDirectoryNames[^1];
|
||||
if (string.IsNullOrEmpty(personDisplayDirectoryName) || personDisplayDirectoryName[0] == '!')
|
||||
incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection.Add(new(newestPersonKeyFormatted, id.Value, normalizedPixelPercentage.Value));
|
||||
incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection.Add(new(newestPersonKeyFormatted, id.Value, normalizedRectangle.Value));
|
||||
else
|
||||
personKeyFormattedIdThenNormalizedPixelPercentageCollection.Add(new(newestPersonKeyFormatted, personDisplayDirectoryNames, id.Value, normalizedPixelPercentage.Value));
|
||||
personKeyFormattedIdThenNormalizedRectangleCollection.Add(new(newestPersonKeyFormatted, personDisplayDirectoryNames, id.Value, normalizedRectangle.Value));
|
||||
}
|
||||
if (duplicateMappedFaceFiles.Any())
|
||||
{
|
||||
@ -494,7 +506,7 @@ internal abstract class MapLogic
|
||||
}
|
||||
}
|
||||
|
||||
private static void SetPersonTicks(Configuration configuration, long ticks, Mapping[] mappingCollection, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers)
|
||||
private static void SetPersonTicks(Configuration configuration, long ticks, Mapping[] mappingCollection, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers)
|
||||
{
|
||||
PersonContainer[]? personContainers;
|
||||
Dictionary<int, PersonContainer[]>? keyValuePairs;
|
||||
@ -506,9 +518,9 @@ internal abstract class MapLogic
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
progressBar.Tick();
|
||||
if (!idThenNormalizedPixelPercentageToPersonContainers.TryGetValue(mapping.MappingFromItem.Id, out keyValuePairs))
|
||||
if (!idThenNormalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromItem.Id, out keyValuePairs))
|
||||
continue;
|
||||
if (!keyValuePairs.TryGetValue(mapping.MappingFromLocation.NormalizedPixelPercentage, out personContainers))
|
||||
if (!keyValuePairs.TryGetValue(mapping.MappingFromLocation.NormalizedRectangle, out personContainers))
|
||||
continue;
|
||||
foreach (PersonContainer personContainer in personContainers)
|
||||
{
|
||||
@ -543,14 +555,14 @@ internal abstract class MapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
private static void AppendToSkipCollection(Dictionary<int, List<int>> skipCollection, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers, Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedPixelPercentageToPersonContainers)
|
||||
private static void AppendToSkipCollection(Dictionary<int, List<int>> skipCollection, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers, Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedRectangleToPersonContainers)
|
||||
{
|
||||
Dictionary<int, PersonContainer[]>? keyValuePairs;
|
||||
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> keyValuePair in incorrectIdThenNormalizedPixelPercentageToPersonContainers)
|
||||
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> keyValuePair in incorrectIdThenNormalizedRectangleToPersonContainers)
|
||||
{
|
||||
if (!skipCollection.ContainsKey(keyValuePair.Key))
|
||||
skipCollection.Add(keyValuePair.Key, new());
|
||||
if (idThenNormalizedPixelPercentageToPersonContainers.TryGetValue(keyValuePair.Key, out keyValuePairs))
|
||||
if (idThenNormalizedRectangleToPersonContainers.TryGetValue(keyValuePair.Key, out keyValuePairs))
|
||||
{
|
||||
if (keyValuePairs.ContainsKey(keyValuePair.Value.ElementAt(0).Key))
|
||||
continue;
|
||||
@ -600,7 +612,7 @@ internal abstract class MapLogic
|
||||
}
|
||||
}
|
||||
|
||||
internal static void Set(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, Configuration? configuration, long ticks, List<PersonContainer> personContainers, string? a2PeopleContentDirectory, string eDistanceContentDirectory, Mapping[] mappingCollection, Shared.Models.Methods.IMapLogicSupport mapLogicSupport, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges, List<PersonContainer> notMappedPersonContainers, Dictionary<int, List<int>> skipCollection, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedPixelPercentageToPersonContainers)
|
||||
internal static void Set(Shared.Models.Properties.IPropertyConfiguration propertyConfiguration, Configuration? configuration, long ticks, List<PersonContainer> personContainers, string? a2PeopleContentDirectory, string eDistanceContentDirectory, Mapping[] mappingCollection, Shared.Models.Methods.IMapLogicSupport mapLogicSupport, Dictionary<long, PersonContainer> personKeyToPersonContainer, Dictionary<long, (long LCL, long Minimum, long Maximum, long UCL)> personKeyToRanges, List<PersonContainer> notMappedPersonContainers, Dictionary<int, List<int>> skipCollection, Dictionary<int, Dictionary<int, PersonContainer[]>> idThenNormalizedRectangleToPersonContainers)
|
||||
{
|
||||
if (configuration is null)
|
||||
throw new NullReferenceException(nameof(configuration));
|
||||
@ -612,9 +624,9 @@ internal abstract class MapLogic
|
||||
Dictionary<int, List<Mapping>> idToMappingCollection = new();
|
||||
Dictionary<string, string> personKeyFormattedToNewestPersonKeyFormatted = new();
|
||||
List<(string[], PersonContainer)> possiblyNewPersonDisplayDirectoryNamesAndPersonContainer = new();
|
||||
List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedPixelPercentageCollection = new();
|
||||
List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection = new();
|
||||
Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedPixelPercentageToPersonContainers = new();
|
||||
List<(string, string[], int, int)> personKeyFormattedIdThenNormalizedRectangleCollection = new();
|
||||
List<(string, int, int)> incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection = new();
|
||||
Dictionary<int, Dictionary<int, PersonContainer[]>> incorrectIdThenNormalizedRectangleToPersonContainers = new();
|
||||
SetPersonCollections(configuration, personContainers, personKeys, personKeyFormattedToNewestPersonKeyFormatted, personKeyFormattedCollection, skipCollection);
|
||||
personContainers.AddRange(AddToPersonKeysThenGetNonSpecificPeopleCollection(configuration, personKeys));
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
@ -627,14 +639,14 @@ internal abstract class MapLogic
|
||||
string[] ticksDirectories = Directory.GetDirectories(eDistanceContentDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||
message = $") {ticksDirectories.Length:000} compile from and clean ticks Director(ies) - B - {totalSeconds} total second(s)";
|
||||
List<(string, string[], string)> collection = DeleteEmptyDirectoriesAndGetCollection(configuration, personKeyFormattedCollection, ticksDirectories, message);
|
||||
(int unableToMatchCount, int duplicateCount) = SetCollectionsAndGetUnableToMatchCount(configuration, ticks, idToMappingCollection, personKeyFormattedToNewestPersonKeyFormatted, personKeyFormattedIdThenNormalizedPixelPercentageCollection, incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, collection);
|
||||
SetKeyValuePairs(configuration, ticks, personContainers, mappingCollection, personKeyFormattedIdThenNormalizedPixelPercentageCollection, incorrectPersonKeyFormattedIdThenNormalizedPixelPercentageCollection, personKeyToPersonContainer, idThenNormalizedPixelPercentageToPersonContainers, possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, incorrectIdThenNormalizedPixelPercentageToPersonContainers, personKeyToRanges);
|
||||
(int unableToMatchCount, int duplicateCount) = SetCollectionsAndGetUnableToMatchCount(configuration, ticks, idToMappingCollection, personKeyFormattedToNewestPersonKeyFormatted, personKeyFormattedIdThenNormalizedRectangleCollection, incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, collection);
|
||||
SetKeyValuePairs(configuration, ticks, personContainers, mappingCollection, personKeyFormattedIdThenNormalizedRectangleCollection, incorrectPersonKeyFormattedIdThenNormalizedRectangleCollection, personKeyToPersonContainer, idThenNormalizedRectangleToPersonContainers, possiblyNewPersonDisplayDirectoryNamesAndPersonContainer, incorrectIdThenNormalizedRectangleToPersonContainers, personKeyToRanges);
|
||||
totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
message = $") {collection.Count:000} message from ticks Director(ies) - D - {duplicateCount} Duplicate Count {unableToMatchCount} Unable To Match Count / {collection.Count} Collection - {totalSeconds} total second(s)";
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
using (ProgressBar progressBar = new(collection.Count, message, options))
|
||||
{
|
||||
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> keyValuePair in idThenNormalizedPixelPercentageToPersonContainers)
|
||||
foreach (KeyValuePair<int, Dictionary<int, PersonContainer[]>> keyValuePair in idThenNormalizedRectangleToPersonContainers)
|
||||
{
|
||||
progressBar.Tick();
|
||||
foreach (KeyValuePair<int, PersonContainer[]> keyValue in keyValuePair.Value)
|
||||
@ -644,7 +656,7 @@ internal abstract class MapLogic
|
||||
long[] personKeyCollection = (from l in nullablePersonKeyCollection where l is not null select l.Value).Distinct().ToArray();
|
||||
SetPersonKeyToPersonContainer(configuration, personContainers, personKeyCollection, personKeyToPersonContainer);
|
||||
notMappedPersonContainers.AddRange(GetNotMappedPersonContainers(configuration, personContainers, personKeyCollection));
|
||||
AppendToSkipCollection(skipCollection, idThenNormalizedPixelPercentageToPersonContainers, incorrectIdThenNormalizedPixelPercentageToPersonContainers);
|
||||
AppendToSkipCollection(skipCollection, idThenNormalizedRectangleToPersonContainers, incorrectIdThenNormalizedRectangleToPersonContainers);
|
||||
if (possiblyNewPersonDisplayDirectoryNamesAndPersonContainer.Any())
|
||||
mapLogicSupport.SavePossiblyNewPersonContainers(propertyConfiguration, configuration.PersonBirthdayFormat, configuration.FacesFileNameExtension, a2PeopleContentDirectory, personKeyToPersonContainer, possiblyNewPersonDisplayDirectoryNamesAndPersonContainer);
|
||||
}
|
||||
@ -690,7 +702,7 @@ internal abstract class MapLogic
|
||||
internal static SaveContainer GetDebugSaveContainer(string directory, SortingContainer sortingContainer, Mapping mapping)
|
||||
{
|
||||
SaveContainer result;
|
||||
FileHolder faceFileHolder = new($"C:/{sortingContainer.Sorting.Id}.{sortingContainer.Sorting.NormalizedPixelPercentage}");
|
||||
FileHolder faceFileHolder = new($"C:/{sortingContainer.Sorting.Id}.{sortingContainer.Sorting.NormalizedRectangle}");
|
||||
string shortcutFile = Path.Combine(directory, $"{sortingContainer.Mapping.MappingFromLocation.DeterministicHashCodeKey}{sortingContainer.Mapping.MappingFromItem.ImageFileHolder.ExtensionLowered}.debug.lnk");
|
||||
result = new(directory, faceFileHolder, mapping.MappingFromItem.ResizedFileHolder, shortcutFile);
|
||||
return result;
|
||||
|
Reference in New Issue
Block a user