Remove Person Require People File,
PersonContainer and bug fix for GetRightPadded
This commit is contained in:
@ -10,6 +10,7 @@ public class Configuration
|
||||
|
||||
#nullable disable
|
||||
|
||||
[Display(Name = "Check D Face and Up Dates"), Required] public bool? CheckDFaceAndUpWriteDates { get; set; }
|
||||
[Display(Name = "Check Json For Distance Results"), Required] public bool? CheckJsonForDistanceResults { get; set; }
|
||||
[Display(Name = "CrossDirectory Max Items In Distance Collection"), Required] public int? CrossDirectoryMaxItemsInDistanceCollection { get; set; }
|
||||
[Display(Name = "Distance Factor"), Required] public int? DistanceFactor { get; set; }
|
||||
@ -31,6 +32,7 @@ public class Configuration
|
||||
[Display(Name = "Location Factor"), Required] public int? LocationFactor { get; set; }
|
||||
[Display(Name = "Map Logic Sigma"), Required] public int? MapLogicSigma { get; set; }
|
||||
[Display(Name = "Mapped Max Index"), Required] public int? MappedMaxIndex { get; set; }
|
||||
[Display(Name = "Mapping Move Unable to Match by 1 Tick"), Required] public bool? MappingMoveUnableToMatch { get; set; }
|
||||
[Display(Name = "Mapping Save Face Encoding"), Required] public bool? MappingSaveFaceEncoding { get; set; }
|
||||
[Display(Name = "Mapping Save Mapped"), Required] public bool? MappingSaveMapped { get; set; }
|
||||
[Display(Name = "Mapping Save Not Mapped"), Required] public bool? MappingSaveNotMapped { get; set; }
|
||||
@ -52,7 +54,6 @@ public class Configuration
|
||||
[Display(Name = "Person Birthday First Year"), Required] public int? PersonBirthdayFirstYear { get; set; }
|
||||
[Display(Name = "Person Birthday Format"), Required] public string PersonBirthdayFormat { get; set; }
|
||||
[Display(Name = "PersonKey Format"), Required] public string PersonKeyFormat { get; set; }
|
||||
[Display(Name = "Person Require People File"), Required] public bool? PersonRequirePeopleFile { get; set; }
|
||||
[Display(Name = "Predictor Model Name"), Required] public string PredictorModelName { get; set; }
|
||||
[Display(Name = "Properties Changed For Distance"), Required] public bool? PropertiesChangedForDistance { get; set; }
|
||||
[Display(Name = "Properties Changed For Faces"), Required] public bool? PropertiesChangedForFaces { get; set; }
|
||||
@ -86,6 +87,8 @@ public class Configuration
|
||||
private static Models.Configuration Get(Configuration configuration)
|
||||
{
|
||||
Models.Configuration result;
|
||||
if (configuration.CheckDFaceAndUpWriteDates is null)
|
||||
throw new NullReferenceException(nameof(configuration.CheckDFaceAndUpWriteDates));
|
||||
if (configuration.CheckJsonForDistanceResults is null)
|
||||
throw new NullReferenceException(nameof(configuration.CheckJsonForDistanceResults));
|
||||
if (configuration.CrossDirectoryMaxItemsInDistanceCollection is null)
|
||||
@ -124,6 +127,8 @@ public class Configuration
|
||||
throw new NullReferenceException(nameof(configuration.LocationFactor));
|
||||
if (configuration.MapLogicSigma is null)
|
||||
throw new NullReferenceException(nameof(configuration.MapLogicSigma));
|
||||
if (configuration.MappingMoveUnableToMatch is null)
|
||||
throw new NullReferenceException(nameof(configuration.MappingMoveUnableToMatch));
|
||||
if (configuration.MappingSaveFaceEncoding is null)
|
||||
throw new NullReferenceException(nameof(configuration.MappingSaveFaceEncoding));
|
||||
if (configuration.MappingSaveNotMapped is null)
|
||||
@ -160,8 +165,6 @@ public class Configuration
|
||||
throw new NullReferenceException(nameof(configuration.PersonBirthdayFormat));
|
||||
if (configuration.PersonKeyFormat is null)
|
||||
throw new NullReferenceException(nameof(configuration.PersonKeyFormat));
|
||||
if (configuration.PersonRequirePeopleFile is null)
|
||||
throw new NullReferenceException(nameof(configuration.PersonRequirePeopleFile));
|
||||
if (configuration.PropertiesChangedForDistance is null)
|
||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForDistance));
|
||||
if (configuration.PropertiesChangedForFaces is null)
|
||||
@ -211,6 +214,7 @@ public class Configuration
|
||||
if (configuration.SaveShortcutsForOutputResolutions is null)
|
||||
configuration.SaveShortcutsForOutputResolutions = Array.Empty<string>();
|
||||
result = new(configuration.PropertyConfiguration,
|
||||
configuration.CheckDFaceAndUpWriteDates.Value,
|
||||
configuration.CheckJsonForDistanceResults.Value,
|
||||
configuration.CrossDirectoryMaxItemsInDistanceCollection.Value,
|
||||
configuration.DistanceFactor.Value,
|
||||
@ -232,6 +236,7 @@ public class Configuration
|
||||
configuration.LocationFactor.Value,
|
||||
configuration.MapLogicSigma.Value,
|
||||
configuration.MappedMaxIndex,
|
||||
configuration.MappingMoveUnableToMatch.Value,
|
||||
configuration.MappingSaveFaceEncoding.Value,
|
||||
configuration.MappingSaveNotMapped.Value,
|
||||
configuration.MappingSaveMapped.Value,
|
||||
@ -253,7 +258,6 @@ public class Configuration
|
||||
configuration.PersonBirthdayFirstYear.Value,
|
||||
configuration.PersonBirthdayFormat,
|
||||
configuration.PersonKeyFormat,
|
||||
configuration.PersonRequirePeopleFile.Value,
|
||||
configuration.PredictorModelName,
|
||||
configuration.PropertiesChangedForDistance.Value,
|
||||
configuration.PropertiesChangedForFaces.Value,
|
||||
|
@ -9,6 +9,7 @@ public class Configuration
|
||||
protected Property.Models.Configuration _PropertyConfiguration;
|
||||
public Property.Models.Configuration PropertyConfiguration => _PropertyConfiguration;
|
||||
|
||||
public bool CheckDFaceAndUpWriteDates { init; get; }
|
||||
public bool CheckJsonForDistanceResults { init; get; }
|
||||
public int CrossDirectoryMaxItemsInDistanceCollection { init; get; }
|
||||
public int DistanceFactor { init; get; }
|
||||
@ -30,6 +31,7 @@ public class Configuration
|
||||
public int LocationFactor { init; get; }
|
||||
public int MapLogicSigma { init; get; }
|
||||
public int? MappedMaxIndex { init; get; }
|
||||
public bool MappingMoveUnableToMatch { init; get; }
|
||||
public bool MappingSaveFaceEncoding { init; get; }
|
||||
public bool MappingSaveNotMapped { init; get; }
|
||||
public bool MappingSaveMapped { init; get; }
|
||||
@ -58,7 +60,6 @@ public class Configuration
|
||||
public bool PropertiesChangedForMetadata { init; get; }
|
||||
public bool PropertiesChangedForResize { init; get; }
|
||||
public bool Reverse { init; get; }
|
||||
public bool PersonRequirePeopleFile { init; get; }
|
||||
public string[] SaveFaceLandmarkForOutputResolutions { init; get; }
|
||||
public bool SaveFullYearOfRandomFiles { init; get; }
|
||||
public bool SaveResizedSubfiles { init; get; }
|
||||
@ -75,6 +76,7 @@ public class Configuration
|
||||
|
||||
[JsonConstructor]
|
||||
public Configuration(Property.Models.Configuration propertyConfiguration,
|
||||
bool checkDFaceAndUpWriteDates,
|
||||
bool checkJsonForDistanceResults,
|
||||
int crossDirectoryMaxItemsInDistanceCollection,
|
||||
int distanceFactor,
|
||||
@ -96,6 +98,7 @@ public class Configuration
|
||||
int locationFactor,
|
||||
int mapLogicSigma,
|
||||
int? mappedMaxIndex,
|
||||
bool mappingMoveUnableToMatch,
|
||||
bool mappingSaveFaceEncoding,
|
||||
bool mappingSaveNotMapped,
|
||||
bool mappingSaveMapped,
|
||||
@ -117,7 +120,6 @@ public class Configuration
|
||||
int personBirthdayFirstYear,
|
||||
string personBirthdayFormat,
|
||||
string personKeyFormat,
|
||||
bool personRequirePeopleFile,
|
||||
string predictorModelName,
|
||||
bool propertiesChangedForDistance,
|
||||
bool propertiesChangedForFaces,
|
||||
@ -140,6 +142,7 @@ public class Configuration
|
||||
string[] validResolutions)
|
||||
{
|
||||
_PropertyConfiguration = propertyConfiguration;
|
||||
CheckDFaceAndUpWriteDates = checkDFaceAndUpWriteDates;
|
||||
CheckJsonForDistanceResults = checkJsonForDistanceResults;
|
||||
CrossDirectoryMaxItemsInDistanceCollection = crossDirectoryMaxItemsInDistanceCollection;
|
||||
DistanceFactor = distanceFactor;
|
||||
@ -161,6 +164,7 @@ public class Configuration
|
||||
LocationFactor = locationFactor;
|
||||
MapLogicSigma = mapLogicSigma;
|
||||
MappedMaxIndex = mappedMaxIndex;
|
||||
MappingMoveUnableToMatch = mappingMoveUnableToMatch;
|
||||
MappingSaveFaceEncoding = mappingSaveFaceEncoding;
|
||||
MappingSaveNotMapped = mappingSaveNotMapped;
|
||||
MappingSaveMapped = mappingSaveMapped;
|
||||
@ -182,7 +186,6 @@ public class Configuration
|
||||
PersonBirthdayFirstYear = personBirthdayFirstYear;
|
||||
PersonBirthdayFormat = personBirthdayFormat;
|
||||
PersonKeyFormat = personKeyFormat;
|
||||
PersonRequirePeopleFile = personRequirePeopleFile;
|
||||
PredictorModelName = predictorModelName;
|
||||
PropertiesChangedForDistance = propertiesChangedForDistance;
|
||||
PropertiesChangedForFaces = propertiesChangedForFaces;
|
||||
|
@ -9,24 +9,7 @@ namespace View_by_Distance.Instance.Models;
|
||||
internal class A2_People
|
||||
{
|
||||
|
||||
private readonly Serilog.ILogger? _Log;
|
||||
private readonly Configuration _Configuration;
|
||||
private readonly JsonSerializerOptions _WriteIndentedJsonSerializerOptions;
|
||||
|
||||
internal A2_People(Configuration configuration)
|
||||
{
|
||||
_Configuration = configuration;
|
||||
_Log = Serilog.Log.ForContext<A2_People>();
|
||||
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
internal void WriteAllText(Property.Models.Configuration configuration, string outputResolution, List<G2_Identify> identifiedCollection)
|
||||
internal static void WriteAllText(Property.Models.Configuration configuration, string outputResolution, List<G2_Identify> identifiedCollection)
|
||||
{
|
||||
string key;
|
||||
string json;
|
||||
@ -35,6 +18,7 @@ internal class A2_People
|
||||
string[] segments;
|
||||
string directoryFullName;
|
||||
Dictionary<string, List<G2_Identify>> keyValuePairs = new();
|
||||
JsonSerializerOptions writeIndentedJsonSerializerOptions = new() { WriteIndented = true };
|
||||
string hPeopleCollectionDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(A2_People), "[]");
|
||||
string aPropertySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(Property.Models.A_Property), "{}");
|
||||
foreach (G2_Identify identified in identifiedCollection)
|
||||
@ -54,23 +38,23 @@ internal class A2_People
|
||||
if (!Directory.Exists(directoryFullName))
|
||||
_ = Directory.CreateDirectory(directoryFullName);
|
||||
jsonFile = Path.Combine(directoryFullName, $"{segments[1]}.json");
|
||||
json = JsonSerializer.Serialize(keyValuePair.Value, _WriteIndentedJsonSerializerOptions);
|
||||
json = JsonSerializer.Serialize(keyValuePair.Value, writeIndentedJsonSerializerOptions);
|
||||
if (!Shared.Models.Stateless.Methods.IPath.WriteAllText(jsonFile, json, updateDateWhenMatches: true, compareBeforeWrite: true))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
internal Person[] GetPeople(Property.Models.Configuration configuration)
|
||||
internal static List<PersonContainer> GetPersonContainers(Configuration configuration, Property.Models.Configuration propertyConfiguration)
|
||||
{
|
||||
Person[] results;
|
||||
string rootDirectory = _Configuration.PropertyConfiguration.RootDirectory;
|
||||
string peopleRootDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(A2_People));
|
||||
List<PersonContainer> results;
|
||||
string rootDirectory = configuration.PropertyConfiguration.RootDirectory;
|
||||
string peopleRootDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(propertyConfiguration, nameof(A2_People));
|
||||
string? rootResultsDirectory = Path.GetDirectoryName(Path.GetDirectoryName(peopleRootDirectory));
|
||||
if (rootResultsDirectory is null)
|
||||
throw new Exception();
|
||||
Storage storage = new(rootDirectory, rootResultsDirectory, peopleRootDirectory);
|
||||
results = Shared.Models.Stateless.Methods.IPerson.GetPeople(storage, _Configuration.PersonBirthdayFirstYear, _Configuration.PersonBirthdayFormat, _Configuration.PersonKeyFormat, _Configuration.PersonRequirePeopleFile);
|
||||
return results.ToArray();
|
||||
results = Shared.Models.Stateless.Methods.IPersonContainer.GetPersonContainers(storage, configuration.PersonBirthdayFormat);
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
@ -167,7 +167,7 @@ internal class D2_FaceParts
|
||||
check = true;
|
||||
else if (saveRotated && !rotatedFileInfo.Exists)
|
||||
check = true;
|
||||
else if (dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime)
|
||||
else if (_Configuration.CheckDFaceAndUpWriteDates && dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime)
|
||||
check = true;
|
||||
if (check && !updateDateWhenMatches)
|
||||
{
|
||||
|
@ -294,7 +294,7 @@ public class D_Face
|
||||
results = null;
|
||||
else if (!fileInfo.Exists)
|
||||
results = null;
|
||||
else if (dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime)
|
||||
else if (_Configuration.CheckDFaceAndUpWriteDates && dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime)
|
||||
results = null;
|
||||
else
|
||||
{
|
||||
@ -304,6 +304,7 @@ public class D_Face
|
||||
results = JsonSerializer.Deserialize<List<Face>>(json);
|
||||
if (results is null)
|
||||
throw new NullReferenceException(nameof(results));
|
||||
results = Shared.Models.Stateless.Methods.IFace.GetVerifiedFaces(_Configuration.LocationDigits, _Configuration.LocationFactor, results);
|
||||
if (!_Configuration.ForceFaceLastWriteTimeToCreationTime)
|
||||
{
|
||||
normalizedPixelPercentageCollection = Shared.Models.Stateless.Methods.IFace.GetInts(results);
|
||||
@ -387,7 +388,7 @@ public class D_Face
|
||||
check = true;
|
||||
else if (!fileInfo.Exists)
|
||||
check = true;
|
||||
else if (dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime)
|
||||
else if (_Configuration.CheckDFaceAndUpWriteDates && dateTimes.Any() && dateTimes.Max() > fileInfo.LastWriteTime)
|
||||
check = true;
|
||||
}
|
||||
if (check)
|
||||
|
@ -8,11 +8,15 @@ namespace View_by_Distance.Instance.Models;
|
||||
internal class E_Distance : Shared.Models.Methods.IFaceDistance
|
||||
{
|
||||
|
||||
internal static void SaveFaceDistances(string eDistanceContentFileName, SortingContainer[] sortingContainers)
|
||||
internal static void SaveFaceDistances(Property.Models.Configuration propertyConfiguration, string eResultsFullGroupDirectory, SortingContainer[] sortingContainers)
|
||||
{
|
||||
string eDistanceContentCollectionDirectory = Path.Combine(eResultsFullGroupDirectory, "([])");
|
||||
if (!Directory.Exists(eDistanceContentCollectionDirectory))
|
||||
_ = Directory.CreateDirectory(eDistanceContentCollectionDirectory);
|
||||
#pragma warning disable
|
||||
string[] results = (from l in sortingContainers select string.Concat(l.Sorting.WithinRange, '\t', l.Sorting.DistancePermyriad, '\t', l.Sorting.DaysDelta, '\t', l.Sorting.Id, '\t', l.Sorting.NormalizedPixelPercentage, '\t', l.Sorting.Older, '\t', l.Face.Mapping.MappingFromItem.Id, '\t', l.Face.Mapping.MappingFromLocation.NormalizedPixelPercentage)).ToArray();
|
||||
#pragma warning restore
|
||||
string eDistanceContentFileName = Path.Combine(eDistanceContentCollectionDirectory, $"{propertyConfiguration.ResultAllInOne}.tvs");
|
||||
File.WriteAllLines(eDistanceContentFileName, results);
|
||||
}
|
||||
|
||||
|
@ -67,7 +67,7 @@ public class G2_Identify : Shared.Models.Properties.IIdentify, IIdentify
|
||||
return result;
|
||||
}
|
||||
|
||||
private void CheckLastWriteTimes(Property.Models.Configuration configuration, IsEnvironment isEnvironment, A2_People a2People, FileInfo named, string g2IdentifySingletonDirectory)
|
||||
private void CheckLastWriteTimes(Property.Models.Configuration configuration, IsEnvironment isEnvironment, FileInfo named, string g2IdentifySingletonDirectory)
|
||||
{
|
||||
string json;
|
||||
FileInfo fileInfo;
|
||||
@ -87,9 +87,9 @@ public class G2_Identify : Shared.Models.Properties.IIdentify, IIdentify
|
||||
File.Delete(file);
|
||||
}
|
||||
json = File.ReadAllText(named.FullName);
|
||||
Person[] people = a2People.GetPeople(configuration);
|
||||
Dictionary<string, string[]> resultKeyValuePairs = new();
|
||||
string[] peopleBirthDates = (from l in people select Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, l.Birthday)).ToArray();
|
||||
List<PersonContainer> personContainers = A2_People.GetPersonContainers(_Configuration, configuration);
|
||||
string[] peopleBirthDates = (from l in personContainers select Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(_Configuration.PersonBirthdayFormat, l.Person.Birthday)).ToArray();
|
||||
Dictionary<string, string[]> sourceKeyValuePairs = JsonSerializer.Deserialize<Dictionary<string, string[]>>(json);
|
||||
foreach (KeyValuePair<string, string[]> keyValuePair in sourceKeyValuePairs)
|
||||
{
|
||||
@ -106,7 +106,7 @@ public class G2_Identify : Shared.Models.Properties.IIdentify, IIdentify
|
||||
}
|
||||
}
|
||||
|
||||
internal List<G2_Identify> GetIdentifiedCollection(Property.Models.Configuration configuration, IsEnvironment isEnvironment, A2_People a2People)
|
||||
internal List<G2_Identify> GetIdentifiedCollection(Property.Models.Configuration configuration, IsEnvironment isEnvironment)
|
||||
{
|
||||
List<G2_Identify> results = new();
|
||||
string json;
|
||||
@ -125,7 +125,7 @@ public class G2_Identify : Shared.Models.Properties.IIdentify, IIdentify
|
||||
string g2IdentifySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(G2_Identify), "[]");
|
||||
string jsonRootDirectory = Path.Combine(string.Concat(_Configuration.PropertyConfiguration.RootDirectory, " - Copied"), string.Concat(directoryName, " - 4) Info"), _Configuration.PropertyConfiguration.DateGroup, "[]");
|
||||
if (named is not null && named.Exists)
|
||||
CheckLastWriteTimes(configuration, isEnvironment, a2People, named, g2IdentifySingletonDirectory);
|
||||
CheckLastWriteTimes(configuration, isEnvironment, named, g2IdentifySingletonDirectory);
|
||||
if (Directory.Exists(jsonRootDirectory))
|
||||
{
|
||||
jsonFiles = Directory.GetFiles(jsonRootDirectory, "*.json", SearchOption.AllDirectories);
|
||||
|
Reference in New Issue
Block a user