Face => Mapping
This commit is contained in:
@ -27,55 +27,51 @@ internal abstract class Mapping
|
||||
return new(id, normalizedPixelPercentage, extensionLowered, needsFacesFileNameExtension);
|
||||
}
|
||||
|
||||
private static (int?, int?, List<Models.Face>?) GetReversedDeterministicHashCodeKeysFromSegments(string facesFileNameExtension, bool idToFacesAny, Dictionary<int, List<Models.Face>> idToFaces, string fileName)
|
||||
private static (int?, int?, List<Models.Mapping>?) GetReversedDeterministicHashCodeKeysFromSegments(string facesFileNameExtension, bool idToMappingCollectionAny, Dictionary<int, List<Models.Mapping>> idToMappingCollection, string fileName)
|
||||
{
|
||||
int? id;
|
||||
List<Models.Face>? faces;
|
||||
int? normalizedPixelPercentage;
|
||||
List<Models.Mapping>? mappingCollection;
|
||||
(string? Id, string? NormalizedPixelPercentage, string? ExtensionLowered, bool? Check) segments = GetSegments(facesFileNameExtension, fileName);
|
||||
if (string.IsNullOrEmpty(segments.Id) || string.IsNullOrEmpty(segments.NormalizedPixelPercentage) || string.IsNullOrEmpty(segments.ExtensionLowered) || segments.Check is null)
|
||||
{
|
||||
id = null;
|
||||
faces = null;
|
||||
mappingCollection = null;
|
||||
normalizedPixelPercentage = null;
|
||||
}
|
||||
else if (!int.TryParse(segments.Id, out int idValue) || !int.TryParse(segments.NormalizedPixelPercentage, out int normalizedPixelPercentageValue))
|
||||
{
|
||||
id = null;
|
||||
faces = null;
|
||||
mappingCollection = null;
|
||||
normalizedPixelPercentage = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
id = idValue;
|
||||
normalizedPixelPercentage = normalizedPixelPercentageValue;
|
||||
if (!idToFacesAny || !idToFaces.ContainsKey(idValue))
|
||||
faces = null;
|
||||
if (!idToMappingCollectionAny || !idToMappingCollection.ContainsKey(idValue))
|
||||
mappingCollection = null;
|
||||
else
|
||||
faces = idToFaces[idValue];
|
||||
mappingCollection = idToMappingCollection[idValue];
|
||||
}
|
||||
return new(id, normalizedPixelPercentage, faces);
|
||||
return new(id, normalizedPixelPercentage, mappingCollection);
|
||||
}
|
||||
|
||||
internal static (int?, int?, List<Models.Face>?) GetReversedDeterministicHashCodeKey(string facesFileNameExtension, bool idToFacesAny, Dictionary<int, List<Models.Face>> idToFaces, string file)
|
||||
internal static (int?, int?, List<Models.Mapping>?) GetReversedDeterministicHashCodeKey(string facesFileNameExtension, bool idToMappingCollectionAny, Dictionary<int, List<Models.Mapping>> idToMappingCollection, string file)
|
||||
{
|
||||
int? id;
|
||||
List<Models.Face>? faces;
|
||||
int? normalizedPixelPercentage;
|
||||
List<Models.Mapping>? mappingCollection;
|
||||
string fileName = Path.GetFileName(file);
|
||||
if (fileName.Length < 2 || fileName[1..].Contains('-'))
|
||||
{
|
||||
id = null;
|
||||
faces = null;
|
||||
mappingCollection = null;
|
||||
normalizedPixelPercentage = null;
|
||||
}
|
||||
else
|
||||
(id, normalizedPixelPercentage, faces) = GetReversedDeterministicHashCodeKeysFromSegments(
|
||||
facesFileNameExtension,
|
||||
idToFacesAny,
|
||||
idToFaces,
|
||||
fileName);
|
||||
return new(id, normalizedPixelPercentage, faces);
|
||||
(id, normalizedPixelPercentage, mappingCollection) = GetReversedDeterministicHashCodeKeysFromSegments(facesFileNameExtension, idToMappingCollectionAny, idToMappingCollection, fileName);
|
||||
return new(id, normalizedPixelPercentage, mappingCollection);
|
||||
}
|
||||
|
||||
internal static int GetAreaPermille(int bottom, int height, int left, int right, int top, int width)
|
||||
|
Reference in New Issue
Block a user