(bool? IsWrongYear, string PersonKey,

TimeSpan? TimeSpan)
This commit is contained in:
2022-08-02 19:41:36 -07:00
parent 62bdc17f7a
commit 2158b4cfc2
7 changed files with 105 additions and 66 deletions

View File

@ -401,10 +401,14 @@ internal class E_Distance
}
}
private static Dictionary<string, List<(string directory, string personKey, D_Face face)>> Convert(string argZero, List<PropertyHolder[]> propertyHolderCollections)
private static Dictionary<string, List<(string personKey, D_Face face)>> Convert(string argZero, List<PropertyHolder[]> propertyHolderCollections)
{
Dictionary<string, List<(string directory, string personKey, D_Face face)>> results = new();
Dictionary<string, List<(string personKey, D_Face face)>> results = new();
string key;
string personKey;
bool? isWrongYear;
TimeSpan? timeSpan;
string isWrongYearFlag;
foreach (PropertyHolder[] propertyHolderCollection in propertyHolderCollections)
{
if (!propertyHolderCollection.Any())
@ -415,16 +419,27 @@ internal class E_Distance
{
if (propertyHolder.ImageFileInfo is null || propertyHolder.Property is null || !propertyHolder.Named.Any())
continue;
foreach ((string directory, string personKey, object @object) in propertyHolder.Named)
if (propertyHolder.Named.Count != 1 || propertyHolder.Faces.Count != 1)
continue;
for (int i = 0; i < propertyHolder.Named.Count; i++)
{
if (string.IsNullOrEmpty(directory) || string.IsNullOrEmpty(personKey) || !directory.Contains(personKey))
if (propertyHolder.MinimumDateTime is null)
continue;
if (@object is not D_Face face || face.FaceEncoding is null)
if (propertyHolder.Faces[i] is not D_Face face)
continue;
key = directory.Split(personKey)[1];
timeSpan = propertyHolder.Named[i].TimeSpan;
personKey = propertyHolder.Named[i].PersonKey;
isWrongYear = propertyHolder.Named[i].IsWrongYear;
isWrongYearFlag = PropertyHolder.GetWrongYearFlag(isWrongYear);
if (timeSpan is null)
key = $"{personKey}\t{isWrongYearFlag}{propertyHolder.MinimumDateTime.Value:yyyy}";
else if (timeSpan.Value.Ticks < 0)
key = $"{personKey}\t{isWrongYearFlag}!---";
else
key = $"{personKey}\t^{Math.Floor(timeSpan.Value.TotalDays / 365):000}";
if (!results.ContainsKey(key))
results.Add(key, new());
results[key].Add(new(directory, personKey, face));
results[key].Add(new(personKey, face));
}
}
}
@ -440,14 +455,14 @@ internal class E_Distance
List<string> checkDirectories = new();
List<Shared.Models.Properties.IFace> collection;
const string pattern = @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]";
Dictionary<string, List<(string personKey, D_Face face)>> keyValuePairs = Convert(argZero, propertyHolderCollections);
string eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model, predictorModel, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[_]");
Dictionary<string, List<(string directory, string personKey, D_Face face)>> keyValuePairs = Convert(argZero, propertyHolderCollections);
foreach (KeyValuePair<string, List<(string directory, string personKey, D_Face face)>> keyValuePair in keyValuePairs)
foreach (KeyValuePair<string, List<(string personKey, D_Face face)>> keyValuePair in keyValuePairs)
{
collection = new();
checkDirectories.Clear();
checkFile = string.Empty;
foreach ((string _, string personKey, D_Face face) in keyValuePair.Value)
foreach ((string personKey, D_Face face) in keyValuePair.Value)
{
if (string.IsNullOrEmpty(personKey) || !peopleCollection.ContainsKey(personKey))
continue;