SaveSortingWithoutPerson
This commit is contained in:
Delete-By-Distinct
Distance/Models
Drag-Drop
Instance
Map/Models
PhotoPrism/Models
Property/Models/Stateless
Shared/Models
@ -174,17 +174,22 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
const int zero = 0;
|
||||
string mappingSegmentB;
|
||||
PersonBirthday personBirthday;
|
||||
List<int>? normalizedRectangles;
|
||||
PersonContainer[]? personContainers;
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
{
|
||||
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromItem.Id, out normalizedRectangleToPersonContainers))
|
||||
{
|
||||
if (_SkipCollection.TryGetValue(mapping.MappingFromItem.Id, out normalizedRectangles) && normalizedRectangles.Contains(mapping.MappingFromLocation.NormalizedRectangle))
|
||||
continue;
|
||||
result += 1;
|
||||
continue;
|
||||
}
|
||||
if (!normalizedRectangleToPersonContainers.TryGetValue(mapping.MappingFromLocation.NormalizedRectangle, out personContainers))
|
||||
{
|
||||
if (_SkipCollection.TryGetValue(mapping.MappingFromItem.Id, out normalizedRectangles) && normalizedRectangles.Contains(mapping.MappingFromLocation.NormalizedRectangle))
|
||||
continue;
|
||||
result += 1;
|
||||
continue;
|
||||
}
|
||||
@ -378,7 +383,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
return result;
|
||||
}
|
||||
|
||||
private static (string, bool, bool) Get(int? useFiltersCounter, string forceSingleImageHumanized, Mapping mapping)
|
||||
private static (string, bool, bool) Get(int? useFiltersCounter, bool sortingContainersAny, string forceSingleImageHumanized, Mapping mapping)
|
||||
{
|
||||
string by;
|
||||
bool isByMapping;
|
||||
@ -386,7 +391,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
if (mapping.By is null)
|
||||
{
|
||||
isByMapping = false;
|
||||
isBySorting = false;
|
||||
isBySorting = !sortingContainersAny;
|
||||
by = $"{nameof(Shared.Models.Stateless.IMapLogic.Mapping)}Null";
|
||||
}
|
||||
else
|
||||
@ -437,7 +442,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
return result;
|
||||
}
|
||||
|
||||
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)
|
||||
private List<SaveContainer> GetSaveContainers(string dFacesContentDirectory, string d2FacePartsContentDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping, Dictionary<long, int> personKeyToCount, int? useFiltersCounter, bool saveMapped, bool sortingContainersAny)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
@ -459,6 +464,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
SaveContainer? saveContainer;
|
||||
FileHolder facePartsFileHolder;
|
||||
FileHolder hiddenFaceFileHolder;
|
||||
List<int>? normalizedRectangles;
|
||||
Dictionary<int, Mapping>? normalizedRectangleToMapping;
|
||||
string forceSingleImageHumanized = nameof(Shared.Models.Stateless.IMapLogic.ForceSingleImage).Humanize(LetterCasing.Title);
|
||||
foreach (Mapping mapping in mappingCollection)
|
||||
@ -466,15 +472,23 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
directoryName = Path.GetDirectoryName(mapping.MappingFromItem.RelativePath);
|
||||
if (directoryName is null)
|
||||
throw new NotSupportedException();
|
||||
(by, isByMapping, isBySorting) = Get(useFiltersCounter, forceSingleImageHumanized, mapping);
|
||||
if (_SkipCollection.TryGetValue(mapping.MappingFromItem.Id, out normalizedRectangles) && normalizedRectangles.Contains(mapping.MappingFromLocation.NormalizedRectangle))
|
||||
continue;
|
||||
(by, isByMapping, isBySorting) = Get(useFiltersCounter, sortingContainersAny, forceSingleImageHumanized, mapping);
|
||||
if (isByMapping && !saveMapped)
|
||||
continue;
|
||||
if (mapping.MappingFromPerson is null)
|
||||
{
|
||||
if (!saveNullPerson)
|
||||
if (!_Configuration.SaveSortingWithoutPerson)
|
||||
continue;
|
||||
if (mapping.SortingContainer is null)
|
||||
continue;
|
||||
{
|
||||
if (sortingContainersAny)
|
||||
continue;
|
||||
mapping.UpdateMappingFromUnknownPerson(new(mapping, new(mapping)));
|
||||
if (mapping.SortingContainer is null)
|
||||
continue;
|
||||
}
|
||||
if (distinct.Contains(mapping.MappingFromItem.Id))
|
||||
continue;
|
||||
if (distinct.Contains(mapping.SortingContainer.Sorting.Id))
|
||||
@ -554,14 +568,14 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
public List<SaveContainer> GetSaveContainers(string dFacesContentDirectory, string d2FacePartsContentDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping, int? useFiltersCounter, bool saveNullPerson)
|
||||
public List<SaveContainer> GetSaveContainers(string dFacesContentDirectory, string d2FacePartsContentDirectory, Mapping[] mappingCollection, Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping, int? useFiltersCounter, bool sortingContainersAny)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
List<SaveContainer> results;
|
||||
bool saveMapped = false;
|
||||
Dictionary<long, int> personKeyToCount = new();
|
||||
results = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, mappingCollection, idToNormalizedRectangleToMapping, personKeyToCount, useFiltersCounter, saveNullPerson, saveMapped);
|
||||
results = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, mappingCollection, idToNormalizedRectangleToMapping, personKeyToCount, useFiltersCounter, saveMapped, sortingContainersAny);
|
||||
return results;
|
||||
}
|
||||
|
||||
@ -571,10 +585,9 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
int? updated = null;
|
||||
bool saveMapped = true;
|
||||
bool saveNullPerson = false;
|
||||
int? useFiltersCounter = null;
|
||||
string mappingDirectory = Path.Combine(_EDistanceContentTicksDirectory, nameof(Shared.Models.Stateless.IMapLogic.Mapping));
|
||||
List<SaveContainer> saveContainers = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, mappingCollection, idToNormalizedRectangleToMapping, personKeyToCount, useFiltersCounter, saveNullPerson, saveMapped);
|
||||
List<SaveContainer> saveContainers = GetSaveContainers(dFacesContentDirectory, d2FacePartsContentDirectory, mappingCollection, idToNormalizedRectangleToMapping, personKeyToCount, useFiltersCounter, saveMapped, sortingContainersAny: true);
|
||||
SaveContainers(totalNotMapped, updated, saveContainers);
|
||||
if (!string.IsNullOrEmpty(_EDistanceContentTicksDirectory) && Directory.Exists(mappingDirectory))
|
||||
Stateless.MapLogic.SaveMappingShortcuts(mappingDirectory);
|
||||
@ -604,11 +617,8 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
throw new NotSupportedException();
|
||||
List<int>? normalizedRectangles;
|
||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||
if (_SkipCollection.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangles))
|
||||
{
|
||||
if (normalizedRectangles.Contains(faceDistanceEncoding.NormalizedRectangle.Value))
|
||||
result = true;
|
||||
}
|
||||
if (_SkipCollection.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangles) && normalizedRectangles.Contains(faceDistanceEncoding.NormalizedRectangle.Value))
|
||||
result = true;
|
||||
if (!result && _IdThenNormalizedRectangleToPersonContainers.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangleToPersonContainers))
|
||||
{
|
||||
if (normalizedRectangleToPersonContainers.ContainsKey(faceDistanceEncoding.NormalizedRectangle.Value))
|
||||
@ -633,11 +643,8 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
throw new NotSupportedException();
|
||||
if (j == i)
|
||||
continue;
|
||||
if (_SkipCollection.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangles))
|
||||
{
|
||||
if (normalizedRectangles.Contains(faceDistanceEncoding.NormalizedRectangle.Value))
|
||||
continue;
|
||||
}
|
||||
if (_SkipCollection.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangles) && normalizedRectangles.Contains(faceDistanceEncoding.NormalizedRectangle.Value))
|
||||
continue;
|
||||
if (_IdThenNormalizedRectangleToPersonContainers.TryGetValue(faceDistanceEncoding.Id, out normalizedRectangleToPersonContainers))
|
||||
{
|
||||
if (normalizedRectangleToPersonContainers.ContainsKey(faceDistanceEncoding.NormalizedRectangle.Value))
|
||||
@ -671,7 +678,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
return results;
|
||||
}
|
||||
|
||||
public int UpdateFromSortingContainers(SortingContainer[] sortingContainers, bool saveNullPerson)
|
||||
public int UpdateFromSortingContainers(SortingContainer[] sortingContainers)
|
||||
{
|
||||
if (_Configuration is null)
|
||||
throw new NullReferenceException(nameof(_Configuration));
|
||||
@ -711,7 +718,7 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
normalizedRectangleCollectionForB = idToNormalizedRectangleCollectionForB[sortingContainer.Mapping.MappingFromItem.Id];
|
||||
if (!_IdThenNormalizedRectangleToPersonContainers.TryGetValue(sortingContainer.Sorting.Id, out normalizedRectangleToPersonContainers) || !normalizedRectangleToPersonContainers.TryGetValue(sortingContainer.Sorting.NormalizedRectangle, out personContainers))
|
||||
{
|
||||
if (!saveNullPerson)
|
||||
if (!_Configuration.SaveSortingWithoutPerson)
|
||||
continue;
|
||||
if (normalizedRectangleCollectionForA.Contains(sortingContainer.Mapping.MappingFromLocation.NormalizedRectangle))
|
||||
continue;
|
||||
@ -1299,4 +1306,19 @@ public class MapLogic : Shared.Models.Methods.IMapLogic
|
||||
_PersonKeyToRanges = personKeyToRanges;
|
||||
}
|
||||
|
||||
public List<Face> GetFurtherFilterBySkipCollection(List<Face> distinctFilteredFaces)
|
||||
{
|
||||
List<Face> results = new();
|
||||
List<int>? normalizedRectangles;
|
||||
foreach (Face face in distinctFilteredFaces)
|
||||
{
|
||||
if (face.Mapping is null)
|
||||
continue;
|
||||
if (_SkipCollection.TryGetValue(face.Mapping.MappingFromItem.Id, out normalizedRectangles) && normalizedRectangles.Contains(face.Mapping.MappingFromLocation.NormalizedRectangle))
|
||||
continue;
|
||||
results.Add(face);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user