NullReferenceException
This commit is contained in:
@ -41,7 +41,7 @@ public class DlibDotNet
|
||||
Person[] people;
|
||||
_AppSettings = appSettings;
|
||||
if (appSettings.MaxDegreeOfParallelism is null)
|
||||
throw new ArgumentNullException(nameof(appSettings.MaxDegreeOfParallelism));
|
||||
throw new NullReferenceException(nameof(appSettings.MaxDegreeOfParallelism));
|
||||
_IsEnvironment = isEnvironment;
|
||||
_Exceptions = new List<string>();
|
||||
_Log = Serilog.Log.ForContext<DlibDotNet>();
|
||||
@ -61,21 +61,21 @@ public class DlibDotNet
|
||||
_Distance = new E_Distance(configuration);
|
||||
_FaceLandmarks = new D2_FaceLandmarks(configuration);
|
||||
if (configuration.ForceMetadataLastWriteTimeToCreationTime is null)
|
||||
throw new ArgumentNullException(nameof(configuration.ForceMetadataLastWriteTimeToCreationTime));
|
||||
throw new NullReferenceException(nameof(configuration.ForceMetadataLastWriteTimeToCreationTime));
|
||||
if (configuration.ForceResizeLastWriteTimeToCreationTime is null)
|
||||
throw new ArgumentNullException(nameof(configuration.ForceResizeLastWriteTimeToCreationTime));
|
||||
throw new NullReferenceException(nameof(configuration.ForceResizeLastWriteTimeToCreationTime));
|
||||
if (configuration.IgnoreExtensions is null)
|
||||
throw new ArgumentNullException(nameof(configuration.IgnoreExtensions));
|
||||
throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||
if (configuration.OutputQuality is null)
|
||||
throw new ArgumentNullException(nameof(configuration.OutputQuality));
|
||||
throw new NullReferenceException(nameof(configuration.OutputQuality));
|
||||
if (configuration.OverrideForResizeImages is null)
|
||||
throw new ArgumentNullException(nameof(configuration.OverrideForResizeImages));
|
||||
throw new NullReferenceException(nameof(configuration.OverrideForResizeImages));
|
||||
if (configuration.PropertiesChangedForMetadata is null)
|
||||
throw new ArgumentNullException(nameof(configuration.PropertiesChangedForMetadata));
|
||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForMetadata));
|
||||
if (configuration.PropertiesChangedForResize is null)
|
||||
throw new ArgumentNullException(nameof(configuration.PropertiesChangedForResize));
|
||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForResize));
|
||||
if (configuration.Reverse is null)
|
||||
throw new ArgumentNullException(nameof(configuration.Reverse));
|
||||
throw new NullReferenceException(nameof(configuration.Reverse));
|
||||
_Metadata = new(configuration.ForceMetadataLastWriteTimeToCreationTime.Value, configuration.PropertiesChangedForMetadata.Value);
|
||||
if (args.Count > 0)
|
||||
argZero = Path.GetFullPath(args[0]);
|
||||
@ -88,7 +88,7 @@ public class DlibDotNet
|
||||
(Model model, PredictorModel predictorModel, ModelParameter modelParameter) = GetModel(configuration);
|
||||
_Faces = new D_Face(configuration, argZero, model, modelParameter, predictorModel);
|
||||
if (configuration.SkipSearch is null)
|
||||
throw new ArgumentNullException(nameof(configuration.SkipSearch));
|
||||
throw new NullReferenceException(nameof(configuration.SkipSearch));
|
||||
if (!_ArgZeroIsConfigurationRootDirectory)
|
||||
people = Array.Empty<Person>();
|
||||
else
|
||||
@ -134,7 +134,7 @@ public class DlibDotNet
|
||||
{
|
||||
long result;
|
||||
if (_Log is null)
|
||||
throw new ArgumentNullException(nameof(_Log));
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
double delta = new TimeSpan(DateTime.Now.Ticks - ticks).TotalMilliseconds;
|
||||
_Log.Debug($"{methodName} took {Math.Floor(delta)} millisecond(s)");
|
||||
result = DateTime.Now.Ticks;
|
||||
@ -188,7 +188,7 @@ public class DlibDotNet
|
||||
private void Verify(Models.Configuration configuration)
|
||||
{
|
||||
if (!configuration.OutputResolutions.Any() || string.IsNullOrEmpty(configuration.OutputResolutions[0]) || !configuration.ValidResolutions.Contains(configuration.OutputResolutions[0]))
|
||||
throw new ArgumentNullException(nameof(configuration.OutputResolutions), "must be a valid outputResolution!");
|
||||
throw new NullReferenceException($"{nameof(configuration.OutputResolutions)} must be a valid outputResolution!");
|
||||
if ((from l in configuration.OutputResolutions where !configuration.ValidResolutions.Contains(l) select false).Any())
|
||||
throw new Exception($"One or more {nameof(configuration.OutputResolutions)} are not in the ValidResolutions list!");
|
||||
if ((from l in configuration.LoadOrCreateThenSaveDirectoryDistanceResultsForOutputResolutions where !configuration.ValidResolutions.Contains(l) select false).Any())
|
||||
@ -202,81 +202,81 @@ public class DlibDotNet
|
||||
if ((from l in configuration.SaveFaceLandmarkForOutputResolutions where !configuration.ValidResolutions.Contains(l) select false).Any())
|
||||
throw new Exception($"One or more {nameof(configuration.SaveFaceLandmarkForOutputResolutions)} are not in the ValidResolutions list!");
|
||||
if (configuration.CheckJsonForDistanceResults is null)
|
||||
throw new ArgumentNullException(nameof(configuration.CheckJsonForDistanceResults));
|
||||
throw new NullReferenceException(nameof(configuration.CheckJsonForDistanceResults));
|
||||
if (configuration.CrossDirectoryMaxItemsInDistanceCollection is null)
|
||||
throw new ArgumentNullException(nameof(configuration.CrossDirectoryMaxItemsInDistanceCollection));
|
||||
throw new NullReferenceException(nameof(configuration.CrossDirectoryMaxItemsInDistanceCollection));
|
||||
if (configuration.DistanceFactor is null)
|
||||
throw new ArgumentNullException(nameof(configuration.DistanceFactor));
|
||||
throw new NullReferenceException(nameof(configuration.DistanceFactor));
|
||||
if (configuration.ForceMetadataLastWriteTimeToCreationTime is null)
|
||||
throw new ArgumentNullException(nameof(configuration.ForceMetadataLastWriteTimeToCreationTime));
|
||||
throw new NullReferenceException(nameof(configuration.ForceMetadataLastWriteTimeToCreationTime));
|
||||
if (configuration.ForceResizeLastWriteTimeToCreationTime is null)
|
||||
throw new ArgumentNullException(nameof(configuration.ForceResizeLastWriteTimeToCreationTime));
|
||||
throw new NullReferenceException(nameof(configuration.ForceResizeLastWriteTimeToCreationTime));
|
||||
if (configuration.IgnoreExtensions is null)
|
||||
throw new ArgumentNullException(nameof(configuration.IgnoreExtensions));
|
||||
throw new NullReferenceException(nameof(configuration.IgnoreExtensions));
|
||||
if (configuration.IgnoreRelativePaths is null)
|
||||
throw new ArgumentNullException(nameof(configuration.IgnoreRelativePaths));
|
||||
throw new NullReferenceException(nameof(configuration.IgnoreRelativePaths));
|
||||
if (configuration.LoadOrCreateThenSaveIndex is null)
|
||||
throw new ArgumentNullException(nameof(configuration.LoadOrCreateThenSaveIndex));
|
||||
throw new NullReferenceException(nameof(configuration.LoadOrCreateThenSaveIndex));
|
||||
if (configuration.LocationConfidenceFactor is null)
|
||||
throw new ArgumentNullException(nameof(configuration.LocationConfidenceFactor));
|
||||
throw new NullReferenceException(nameof(configuration.LocationConfidenceFactor));
|
||||
if (configuration.MappedMaxIndex is null)
|
||||
throw new ArgumentNullException(nameof(configuration.MappedMaxIndex));
|
||||
throw new NullReferenceException(nameof(configuration.MappedMaxIndex));
|
||||
if (configuration.MappedMaxIndex.HasValue && configuration.LoadOrCreateThenSaveIndex.Value && !_IsEnvironment.DebuggerWasAttachedDuringConstructor)
|
||||
throw new ArgumentNullException(nameof(configuration.MappedMaxIndex));
|
||||
throw new NullReferenceException(nameof(configuration.MappedMaxIndex));
|
||||
if (configuration.MaxItemsInDistanceCollection is null)
|
||||
throw new ArgumentNullException(nameof(configuration.MaxItemsInDistanceCollection));
|
||||
throw new NullReferenceException(nameof(configuration.MaxItemsInDistanceCollection));
|
||||
if (configuration.MixedYearRelativePaths is null)
|
||||
throw new ArgumentNullException(nameof(configuration.MixedYearRelativePaths));
|
||||
throw new NullReferenceException(nameof(configuration.MixedYearRelativePaths));
|
||||
if (configuration.NumberOfJitters is null)
|
||||
throw new ArgumentNullException(nameof(configuration.NumberOfJitters));
|
||||
throw new NullReferenceException(nameof(configuration.NumberOfJitters));
|
||||
if (configuration.NumberOfTimesToUpsample is null)
|
||||
throw new ArgumentNullException(nameof(configuration.NumberOfTimesToUpsample));
|
||||
throw new NullReferenceException(nameof(configuration.NumberOfTimesToUpsample));
|
||||
if (configuration.OutputQuality is null)
|
||||
throw new ArgumentNullException(nameof(configuration.OutputQuality));
|
||||
throw new NullReferenceException(nameof(configuration.OutputQuality));
|
||||
if (configuration.OutputResolutions is null)
|
||||
throw new ArgumentNullException(nameof(configuration.OutputResolutions));
|
||||
throw new NullReferenceException(nameof(configuration.OutputResolutions));
|
||||
if (configuration.OverrideForFaceImages is null)
|
||||
throw new ArgumentNullException(nameof(configuration.OverrideForFaceImages));
|
||||
throw new NullReferenceException(nameof(configuration.OverrideForFaceImages));
|
||||
if (configuration.OverrideForFaceLandmarkImages is null)
|
||||
throw new ArgumentNullException(nameof(configuration.OverrideForFaceLandmarkImages));
|
||||
throw new NullReferenceException(nameof(configuration.OverrideForFaceLandmarkImages));
|
||||
if (configuration.OverrideForResizeImages is null)
|
||||
throw new ArgumentNullException(nameof(configuration.OverrideForResizeImages));
|
||||
throw new NullReferenceException(nameof(configuration.OverrideForResizeImages));
|
||||
if (configuration.PaddingLoops is null)
|
||||
throw new ArgumentNullException(nameof(configuration.PaddingLoops));
|
||||
throw new NullReferenceException(nameof(configuration.PaddingLoops));
|
||||
if (configuration.PropertiesChangedForDistance is null)
|
||||
throw new ArgumentNullException(nameof(configuration.PropertiesChangedForDistance));
|
||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForDistance));
|
||||
if (configuration.PropertiesChangedForFaces is null)
|
||||
throw new ArgumentNullException(nameof(configuration.PropertiesChangedForFaces));
|
||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForFaces));
|
||||
if (configuration.PropertiesChangedForIndex is null)
|
||||
throw new ArgumentNullException(nameof(configuration.PropertiesChangedForIndex));
|
||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForIndex));
|
||||
if (configuration.PropertiesChangedForMetadata is null)
|
||||
throw new ArgumentNullException(nameof(configuration.PropertiesChangedForMetadata));
|
||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForMetadata));
|
||||
if (configuration.PropertiesChangedForResize is null)
|
||||
throw new ArgumentNullException(nameof(configuration.PropertiesChangedForResize));
|
||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForResize));
|
||||
if (configuration.Reverse is null)
|
||||
throw new ArgumentNullException(nameof(configuration.Reverse));
|
||||
throw new NullReferenceException(nameof(configuration.Reverse));
|
||||
if (configuration.SaveFaceLandmarkForOutputResolutions is null)
|
||||
throw new ArgumentNullException(nameof(configuration.SaveFaceLandmarkForOutputResolutions));
|
||||
throw new NullReferenceException(nameof(configuration.SaveFaceLandmarkForOutputResolutions));
|
||||
if (configuration.SaveFullYearOfRandomFiles is null)
|
||||
throw new ArgumentNullException(nameof(configuration.SaveFullYearOfRandomFiles));
|
||||
throw new NullReferenceException(nameof(configuration.SaveFullYearOfRandomFiles));
|
||||
if (configuration.SaveResizedSubfiles is null)
|
||||
throw new ArgumentNullException(nameof(configuration.SaveResizedSubfiles));
|
||||
throw new NullReferenceException(nameof(configuration.SaveResizedSubfiles));
|
||||
if (configuration.SkipSearch is null)
|
||||
throw new ArgumentNullException(nameof(configuration.SkipSearch));
|
||||
throw new NullReferenceException(nameof(configuration.SkipSearch));
|
||||
if (configuration.TestDistanceResults is null)
|
||||
throw new ArgumentNullException(nameof(configuration.TestDistanceResults));
|
||||
throw new NullReferenceException(nameof(configuration.TestDistanceResults));
|
||||
if (configuration.ValidResolutions is null)
|
||||
throw new ArgumentNullException(nameof(configuration.ValidResolutions));
|
||||
throw new NullReferenceException(nameof(configuration.ValidResolutions));
|
||||
if (string.IsNullOrEmpty(configuration.ModelDirectory) || !Directory.Exists(configuration.ModelDirectory))
|
||||
throw new ArgumentNullException(nameof(configuration.ModelDirectory));
|
||||
throw new NullReferenceException(nameof(configuration.ModelDirectory));
|
||||
if (string.IsNullOrEmpty(configuration.ModelName))
|
||||
throw new ArgumentNullException(nameof(configuration.ModelName));
|
||||
throw new NullReferenceException(nameof(configuration.ModelName));
|
||||
if (string.IsNullOrEmpty(configuration.OutputExtension))
|
||||
throw new ArgumentNullException(nameof(configuration.OutputExtension));
|
||||
throw new NullReferenceException(nameof(configuration.OutputExtension));
|
||||
if (string.IsNullOrEmpty(configuration.PredictorModelName))
|
||||
throw new ArgumentNullException(nameof(configuration.PredictorModelName));
|
||||
throw new NullReferenceException(nameof(configuration.PredictorModelName));
|
||||
if (configuration.DistanceFactor.Value + configuration.LocationConfidenceFactor.Value != 10)
|
||||
throw new ArgumentNullException(nameof(configuration.DistanceFactor));
|
||||
throw new NullReferenceException(nameof(configuration.DistanceFactor));
|
||||
}
|
||||
|
||||
private void VerifyExtra(List<string> args, Property.Models.Configuration propertyConfiguration, Models.Configuration configuration)
|
||||
@ -305,18 +305,18 @@ public class DlibDotNet
|
||||
throw new Exception("Input directory should be the source and not a resized directory!");
|
||||
}
|
||||
|
||||
private void FullParallelForWork(PropertyLogic propertyLogic, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, List<FileHolder?> propertyFileHolderCollection, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollections, List<Dictionary<string, int[]>> resizeKeyValuePairs, List<List<D_Face>> imageFaceCollections, string sourceDirectory, int index, PropertyHolder propertyHolder)
|
||||
private void FullParallelForWork(PropertyLogic propertyLogic, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, List<FileHolder?> propertyFileHolderCollection, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollections, List<Dictionary<string, int[]>> resizeKeyValuePairs, List<List<D_Face>> imageFaceCollections, string sourceDirectory, int index, Item item)
|
||||
{
|
||||
if (propertyHolder.ImageFileHolder is null)
|
||||
throw new ArgumentNullException(nameof(propertyHolder.ImageFileHolder));
|
||||
if (item.ImageFileHolder is null)
|
||||
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new ArgumentNullException(nameof(_AppSettings.MaxDegreeOfParallelism));
|
||||
throw new NullReferenceException(nameof(_AppSettings.MaxDegreeOfParallelism));
|
||||
if (_Configuration.SaveResizedSubfiles is null)
|
||||
throw new ArgumentNullException(nameof(_Configuration.SaveResizedSubfiles));
|
||||
throw new NullReferenceException(nameof(_Configuration.SaveResizedSubfiles));
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new ArgumentNullException(nameof(_Configuration.PropertyConfiguration));
|
||||
throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration));
|
||||
if (_Configuration.PropertyConfiguration.WriteBitmapDataBytes is null)
|
||||
throw new ArgumentNullException(nameof(_Configuration.PropertyConfiguration.WriteBitmapDataBytes));
|
||||
throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration.WriteBitmapDataBytes));
|
||||
A_Property property;
|
||||
List<D_Face> faceCollection;
|
||||
string original = "Original";
|
||||
@ -326,40 +326,44 @@ public class DlibDotNet
|
||||
Dictionary<string, int[]> imageResizeKeyValuePairs;
|
||||
List<Tuple<string, DateTime>> subFileTuples = new();
|
||||
List<KeyValuePair<string, string>> metadataCollection;
|
||||
if (propertyHolder.Property is null)
|
||||
if (item.Property is null)
|
||||
{
|
||||
lock (sourceDirectoryChanges)
|
||||
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), DateTime.Now));
|
||||
property = propertyLogic.GetProperty(propertyLogic.AngleBracketCollection[0], propertyHolder, subFileTuples, parseExceptions);
|
||||
propertyHolder.Update(property);
|
||||
property = propertyLogic.GetProperty(item, subFileTuples, parseExceptions);
|
||||
item.Update(property);
|
||||
if (subFileTuples.Any())
|
||||
{
|
||||
lock (sourceDirectoryChanges)
|
||||
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), (from l in subFileTuples select l.Item2).Max()));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
property = propertyHolder.Property;
|
||||
if (propertyHolder.Changed.HasValue && propertyHolder.Changed.Value)
|
||||
property = item.Property;
|
||||
if (item.Changed.HasValue && item.Changed.Value)
|
||||
{
|
||||
lock (sourceDirectoryChanges)
|
||||
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), DateTime.Now));
|
||||
// lock (sourceDirectoryChanges)
|
||||
// sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), DateTime.Now));
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
(int metadataGroups, metadataCollection) = _Metadata.GetMetadataCollection(subFileTuples, parseExceptions, propertyHolder);
|
||||
(int metadataGroups, metadataCollection) = _Metadata.GetMetadataCollection(subFileTuples, parseExceptions, item);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(B_Metadata.GetMetadataCollection));
|
||||
FileHolder resizedFileHolder = new(Path.Combine(_Resize.AngleBracketCollection[0].Replace("<>", "()"), Path.GetFileName(propertyHolder.ImageFileHolder.FullName)));
|
||||
propertyHolder.SetResizedFileHolder(resizedFileHolder);
|
||||
imageResizeKeyValuePairs = _Resize.GetResizeKeyValuePairs(subFileTuples, parseExceptions, original, metadataCollection, property, propertyHolder);
|
||||
FileHolder resizedFileHolder = new(Path.Combine(_Resize.AngleBracketCollection[0].Replace("<>", "()"), Path.GetFileName(item.ImageFileHolder.FullName)));
|
||||
item.SetResizedFileHolder(resizedFileHolder);
|
||||
imageResizeKeyValuePairs = _Resize.GetResizeKeyValuePairs(subFileTuples, parseExceptions, original, metadataCollection, property, item);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(C_Resize.GetResizeKeyValuePairs));
|
||||
if (_Configuration.SaveResizedSubfiles.Value)
|
||||
{
|
||||
_Resize.SaveResizedSubfile(outputResolution, subFileTuples, propertyHolder, original, property, imageResizeKeyValuePairs);
|
||||
_Resize.SaveResizedSubfile(outputResolution, subFileTuples, item, original, property, imageResizeKeyValuePairs);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(C_Resize.SaveResizedSubfile));
|
||||
propertyHolder.SetResizedFileHolder(FileHolder.Refresh(resizedFileHolder));
|
||||
item.SetResizedFileHolder(FileHolder.Refresh(resizedFileHolder));
|
||||
}
|
||||
else if (outputResolution == _Configuration.OutputResolutions[0] && false)
|
||||
{
|
||||
byte[] bytes = _Resize.GetResizedBytes(outputResolution, subFileTuples, propertyHolder, property, imageResizeKeyValuePairs);
|
||||
byte[] bytes = _Resize.GetResizedBytes(outputResolution, subFileTuples, item, property, imageResizeKeyValuePairs);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(C_Resize.GetResizedBytes));
|
||||
string path = Path.Combine(resizedFileHolder.DirectoryName, resizedFileHolder.NameWithoutExtension);
|
||||
@ -373,15 +377,15 @@ public class DlibDotNet
|
||||
int outputResolutionWidth = outputResolutionCollection[0];
|
||||
int outputResolutionHeight = outputResolutionCollection[1];
|
||||
int outputResolutionOrientation = outputResolutionCollection[2];
|
||||
faceCollection = _Faces.GetFaces(_Configuration.PropertyConfiguration, outputResolution, subFileTuples, parseExceptions, propertyHolder, property, resizedFileHolder, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation);
|
||||
faceCollection = _Faces.GetFaces(_Configuration.PropertyConfiguration, outputResolution, subFileTuples, parseExceptions, item, property, resizedFileHolder, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(D_Face.GetFaces));
|
||||
_Faces.SaveFaces(_Configuration.PropertyConfiguration, subFileTuples, parseExceptions, propertyHolder, faceCollection);
|
||||
_Faces.SaveFaces(_Configuration.PropertyConfiguration, subFileTuples, parseExceptions, item, faceCollection);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(D_Face.SaveFaces));
|
||||
if (_Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution))
|
||||
{
|
||||
_FaceLandmarks.SaveFaceLandmarkImages(subFileTuples, parseExceptions, propertyHolder, faceCollection);
|
||||
_FaceLandmarks.SaveFaceLandmarkImages(subFileTuples, parseExceptions, item, faceCollection);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(D2_FaceLandmarks.SaveFaceLandmarkImages));
|
||||
}
|
||||
@ -392,23 +396,23 @@ public class DlibDotNet
|
||||
imageFaceCollections[index] = faceCollection;
|
||||
metadataCollections[index] = metadataCollection;
|
||||
resizeKeyValuePairs[index] = imageResizeKeyValuePairs;
|
||||
propertyFileHolderCollection[index] = propertyHolder.ImageFileHolder;
|
||||
propertyFileHolderCollection[index] = item.ImageFileHolder;
|
||||
sourceDirectoryChanges.AddRange(from l in subFileTuples where l.Item2 > dateTime select l);
|
||||
}
|
||||
}
|
||||
|
||||
private int FullParallelWork(long ticks, PropertyLogic propertyLogic, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, List<FileHolder?> propertyFileHolderCollection, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollection, List<Dictionary<string, int[]>> resizeKeyValuePairs, List<List<D_Face>> faceCollections, int propertyHolderCollectionsCount, int g, string sourceDirectory, int r, PropertyHolder[] filteredPropertyHolderCollection)
|
||||
private int FullParallelWork(long ticks, PropertyLogic propertyLogic, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, List<FileHolder?> propertyFileHolderCollection, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollection, List<Dictionary<string, int[]>> resizeKeyValuePairs, List<List<D_Face>> faceCollections, int containersCount, Container container, Item[] filteredItems)
|
||||
{
|
||||
int result = 0;
|
||||
if (_Log is null)
|
||||
throw new ArgumentNullException(nameof(_Log));
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new ArgumentNullException(nameof(AppSettings.MaxDegreeOfParallelism));
|
||||
throw new NullReferenceException(nameof(AppSettings.MaxDegreeOfParallelism));
|
||||
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = _AppSettings.MaxDegreeOfParallelism.Value };
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
if (faceCollections.Count != filteredPropertyHolderCollection.Length || metadataCollection.Count != filteredPropertyHolderCollection.Length || resizeKeyValuePairs.Count != filteredPropertyHolderCollection.Length || propertyCollection.Count != filteredPropertyHolderCollection.Length)
|
||||
if (faceCollections.Count != filteredItems.Length || metadataCollection.Count != filteredItems.Length || resizeKeyValuePairs.Count != filteredItems.Length || propertyCollection.Count != filteredItems.Length)
|
||||
{
|
||||
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
|
||||
for (int i = 0; i < filteredItems.Length; i++)
|
||||
{
|
||||
faceCollections.Add(new());
|
||||
metadataCollection.Add(new());
|
||||
@ -418,23 +422,23 @@ public class DlibDotNet
|
||||
}
|
||||
}
|
||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
string message = $"{r + 1:000}.{g} / {propertyHolderCollectionsCount:000}) {filteredPropertyHolderCollection.Length:000} file(s) - {totalSeconds} total second(s) - {outputResolution} - {sourceDirectory}";
|
||||
using (ProgressBar progressBar = new(filteredPropertyHolderCollection.Length, message, options))
|
||||
string message = $"{container.R + 1:000}.{container.G} / {containersCount:000}) {filteredItems.Length:000} file(s) - {totalSeconds} total second(s) - {outputResolution} - {container.SourceDirectory}";
|
||||
using (ProgressBar progressBar = new(filteredItems.Length, message, options))
|
||||
{
|
||||
_ = Parallel.For(0, filteredPropertyHolderCollection.Length, parallelOptions, i =>
|
||||
_ = Parallel.For(0, filteredItems.Length, parallelOptions, i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
FullParallelForWork(propertyLogic, outputResolution, sourceDirectoryChanges, propertyFileHolderCollection, propertyCollection, metadataCollection, resizeKeyValuePairs, faceCollections, sourceDirectory, index: i, filteredPropertyHolderCollection[i]);
|
||||
FullParallelForWork(propertyLogic, outputResolution, sourceDirectoryChanges, propertyFileHolderCollection, propertyCollection, metadataCollection, resizeKeyValuePairs, faceCollections, container.SourceDirectory, index: i, filteredItems[i]);
|
||||
if (i == 0 || sourceDirectoryChanges.Any())
|
||||
progressBar.Tick();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
result += 1;
|
||||
_Log.Error(string.Concat(sourceDirectory, Environment.NewLine, ex.Message, Environment.NewLine, ex.StackTrace), ex);
|
||||
if (result == filteredPropertyHolderCollection.Length)
|
||||
throw new Exception(string.Concat("All in [", sourceDirectory, "] failed!"));
|
||||
_Log.Error(string.Concat(container.SourceDirectory, Environment.NewLine, ex.Message, Environment.NewLine, ex.StackTrace), ex);
|
||||
if (result == filteredItems.Length)
|
||||
throw new Exception(string.Concat("All in [", container.SourceDirectory, "] failed!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -476,20 +480,20 @@ public class DlibDotNet
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteGroup(Property.Models.Configuration configuration, PropertyLogic propertyLogic, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollection, List<List<D_Face>> faceCollections, List<Dictionary<string, int[]>> resizeKeyValuePairs, string sourceDirectory, string outputResolution, PropertyHolder[] filteredPropertyHolderCollection)
|
||||
private void WriteGroup(Property.Models.Configuration configuration, PropertyLogic propertyLogic, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollection, List<List<D_Face>> faceCollections, List<Dictionary<string, int[]>> resizeKeyValuePairs, string sourceDirectory, string outputResolution, Item[] filteredItems)
|
||||
{
|
||||
if (_Configuration.PropertiesChangedForMetadata is null)
|
||||
throw new ArgumentNullException(nameof(_Configuration.PropertiesChangedForMetadata));
|
||||
throw new NullReferenceException(nameof(_Configuration.PropertiesChangedForMetadata));
|
||||
if (configuration.PropertiesChangedForProperty is null)
|
||||
throw new ArgumentNullException(nameof(configuration.PropertiesChangedForProperty));
|
||||
throw new NullReferenceException(nameof(configuration.PropertiesChangedForProperty));
|
||||
if (_Configuration.PropertiesChangedForResize is null)
|
||||
throw new ArgumentNullException(nameof(_Configuration.PropertiesChangedForResize));
|
||||
throw new NullReferenceException(nameof(_Configuration.PropertiesChangedForResize));
|
||||
if (_Configuration.PropertiesChangedForFaces is null)
|
||||
throw new ArgumentNullException(nameof(_Configuration.PropertiesChangedForFaces));
|
||||
throw new NullReferenceException(nameof(_Configuration.PropertiesChangedForFaces));
|
||||
Item item;
|
||||
string key;
|
||||
string json;
|
||||
string checkFile;
|
||||
PropertyHolder propertyHolder;
|
||||
int sourceDirectoryLength = sourceDirectory.Length;
|
||||
_FilePropertiesKeyValuePairs.Add(sourceDirectory, new List<Tuple<string, A_Property>>());
|
||||
JsonSerializerOptions writeIndentedJsonSerializerOptions = new() { WriteIndented = false };
|
||||
@ -502,14 +506,14 @@ public class DlibDotNet
|
||||
List<KeyValuePair<string, List<KeyValuePair<string, string>>>> metadataCollectionKeyValuePairs = new();
|
||||
(int level, List<string> directories) = Property.Models.Stateless.IPath.Get(configuration.RootDirectory, sourceDirectory);
|
||||
string fileName = string.Concat(string.Join(configuration.FileNameDirectorySeparator, directories), ".json");
|
||||
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
|
||||
for (int i = 0; i < filteredItems.Length; i++)
|
||||
{
|
||||
propertyHolder = filteredPropertyHolderCollection[i];
|
||||
if (propertyHolder.Property is null)
|
||||
item = filteredItems[i];
|
||||
if (item.Property is null)
|
||||
continue;
|
||||
if (propertyHolder.ImageFileHolder is null)
|
||||
if (item.ImageFileHolder is null)
|
||||
continue;
|
||||
key = Property.Models.Stateless.IPath.GetRelativePath(propertyHolder.ImageFileHolder.FullName, sourceDirectoryLength);
|
||||
key = Property.Models.Stateless.IPath.GetRelativePath(item.ImageFileHolder.FullName, sourceDirectoryLength);
|
||||
_FileKeyValuePairs.Add(new KeyValuePair<string, string>(sourceDirectory, key));
|
||||
_FilePropertiesKeyValuePairs[sourceDirectory].Add(new Tuple<string, A_Property>(key, propertyCollection[i]));
|
||||
faceCollectionsKeyValuePairs.Add(new KeyValuePair<string, List<D_Face>>(key, faceCollections[i]));
|
||||
@ -560,41 +564,35 @@ public class DlibDotNet
|
||||
}
|
||||
}
|
||||
|
||||
private void FullDoWork(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string argZero, Dictionary<string, List<Person>> peopleCollection, PropertyLogic propertyLogic, List<PropertyHolder[]> propertyHolderCollections)
|
||||
private void FullDoWork(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string argZero, Dictionary<string, List<Person>> peopleCollection, PropertyLogic propertyLogic, List<Container> containers)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new ArgumentNullException(nameof(_Log));
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new ArgumentNullException(nameof(_AppSettings.MaxDegreeOfParallelism));
|
||||
int g;
|
||||
int r;
|
||||
throw new NullReferenceException(nameof(_AppSettings.MaxDegreeOfParallelism));
|
||||
int exceptionCount;
|
||||
string sourceDirectory;
|
||||
Item[] filteredItems;
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
string eDistanceCollectionDirectory;
|
||||
List<List<D_Face>> faceCollections = new();
|
||||
List<A_Property> propertyCollection = new();
|
||||
PropertyHolder[] filteredPropertyHolderCollection;
|
||||
List<FileHolder?> propertyFileHolderCollection = new();
|
||||
List<Dictionary<string, int[]>> resizeKeyValuePairs = new();
|
||||
List<Tuple<string, DateTime>> sourceDirectoryChanges = new();
|
||||
List<List<KeyValuePair<string, string>>> metadataCollection = new();
|
||||
List<(string[], PersonBirthday, FaceRecognitionDotNet.FaceEncoding[])> collection;
|
||||
string aPropertySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(A_Property), "{}");
|
||||
string propertyRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(configuration, nameof(A_Property));
|
||||
foreach (string outputResolution in _Configuration.OutputResolutions)
|
||||
{
|
||||
_FileKeyValuePairs.Clear();
|
||||
_FilePropertiesKeyValuePairs.Clear();
|
||||
eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model, predictorModel, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), $"[{ticks}]");
|
||||
foreach (PropertyHolder[] propertyHolderCollection in propertyHolderCollections)
|
||||
foreach (Container container in containers)
|
||||
{
|
||||
if (!propertyHolderCollection.Any())
|
||||
if (!container.Items.Any())
|
||||
continue;
|
||||
if (!_ArgZeroIsConfigurationRootDirectory && !propertyHolderCollection[0].SourceDirectory.StartsWith(argZero))
|
||||
if (!_ArgZeroIsConfigurationRootDirectory && !container.SourceDirectory.StartsWith(argZero))
|
||||
continue;
|
||||
filteredPropertyHolderCollection = (from l in propertyHolderCollection where l.ImageFileHolder is not null && l.Property is not null && l.ValidImageFormatExtension.HasValue && l.ValidImageFormatExtension.Value && !_Configuration.IgnoreExtensions.Contains(l.ImageFileHolder.Extension) select l).ToArray();
|
||||
if (!filteredPropertyHolderCollection.Any())
|
||||
filteredItems = (from l in container.Items where l.ImageFileHolder is not null && l.ValidImageFormatExtension && !_Configuration.IgnoreExtensions.Contains(l.ImageFileHolder.ExtensionLowered) select l).ToArray();
|
||||
if (!filteredItems.Any())
|
||||
continue;
|
||||
faceCollections.Clear();
|
||||
metadataCollection.Clear();
|
||||
@ -605,15 +603,12 @@ public class DlibDotNet
|
||||
_Faces.AngleBracketCollection.Clear();
|
||||
_Resize.AngleBracketCollection.Clear();
|
||||
_Metadata.AngleBracketCollection.Clear();
|
||||
g = filteredPropertyHolderCollection[0].G;
|
||||
r = filteredPropertyHolderCollection[0].R;
|
||||
propertyLogic.AngleBracketCollection.Clear();
|
||||
_FaceLandmarks.AngleBracketCollection.Clear();
|
||||
sourceDirectory = filteredPropertyHolderCollection[0].SourceDirectory;
|
||||
propertyLogic.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
model,
|
||||
predictorModel,
|
||||
sourceDirectory,
|
||||
container.SourceDirectory,
|
||||
nameof(A_Property),
|
||||
outputResolution,
|
||||
includeResizeGroup: false,
|
||||
@ -625,7 +620,7 @@ public class DlibDotNet
|
||||
_Metadata.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
model,
|
||||
predictorModel,
|
||||
sourceDirectory,
|
||||
container.SourceDirectory,
|
||||
nameof(B_Metadata),
|
||||
outputResolution,
|
||||
includeResizeGroup: false,
|
||||
@ -637,7 +632,7 @@ public class DlibDotNet
|
||||
_Resize.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
model,
|
||||
predictorModel,
|
||||
sourceDirectory,
|
||||
container.SourceDirectory,
|
||||
nameof(C_Resize),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
@ -650,7 +645,7 @@ public class DlibDotNet
|
||||
_Faces.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
model,
|
||||
predictorModel,
|
||||
sourceDirectory,
|
||||
container.SourceDirectory,
|
||||
nameof(D_Face),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
@ -663,7 +658,7 @@ public class DlibDotNet
|
||||
_FaceLandmarks.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
model,
|
||||
predictorModel,
|
||||
sourceDirectory,
|
||||
container.SourceDirectory,
|
||||
nameof(D2_FaceLandmarks),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
@ -672,28 +667,28 @@ public class DlibDotNet
|
||||
contentDescription: "n x 2 png file(s) for each face found",
|
||||
singletonDescription: string.Empty,
|
||||
collectionDescription: string.Empty));
|
||||
exceptionCount = FullParallelWork(ticks, propertyLogic, outputResolution, sourceDirectoryChanges, propertyFileHolderCollection, propertyCollection, metadataCollection, resizeKeyValuePairs, faceCollections, propertyHolderCollections.Count, g, sourceDirectory, r, filteredPropertyHolderCollection);
|
||||
if (metadataCollection.Count != filteredPropertyHolderCollection.Length || propertyCollection.Count != filteredPropertyHolderCollection.Length || resizeKeyValuePairs.Count != filteredPropertyHolderCollection.Length || faceCollections.Count != filteredPropertyHolderCollection.Length)
|
||||
exceptionCount = FullParallelWork(ticks, propertyLogic, outputResolution, sourceDirectoryChanges, propertyFileHolderCollection, propertyCollection, metadataCollection, resizeKeyValuePairs, faceCollections, containers.Count, container, filteredItems);
|
||||
if (metadataCollection.Count != filteredItems.Length || propertyCollection.Count != filteredItems.Length || resizeKeyValuePairs.Count != filteredItems.Length || faceCollections.Count != filteredItems.Length)
|
||||
throw new Exception("Counts don't match!");
|
||||
if (exceptionCount != 0)
|
||||
_Exceptions.Add(sourceDirectory);
|
||||
_Exceptions.Add(container.SourceDirectory);
|
||||
if (_ArgZeroIsConfigurationRootDirectory && exceptionCount == 0)
|
||||
WriteGroup(configuration, propertyLogic, propertyCollection, metadataCollection, faceCollections, resizeKeyValuePairs, sourceDirectory, outputResolution, filteredPropertyHolderCollection);
|
||||
WriteGroup(configuration, propertyLogic, propertyCollection, metadataCollection, faceCollections, resizeKeyValuePairs, container.SourceDirectory, outputResolution, filteredItems);
|
||||
if (_ArgZeroIsConfigurationRootDirectory && exceptionCount == 0 && outputResolution == _Configuration.OutputResolutions[0])
|
||||
propertyLogic.AddToPropertyLogicAllCollection(filteredPropertyHolderCollection);
|
||||
propertyLogic.AddToPropertyLogicAllCollection(filteredItems);
|
||||
if (_ArgZeroIsConfigurationRootDirectory && exceptionCount == 0 && propertyLogic.NamedFaceInfoDeterministicHashCodeIndices.Any())
|
||||
{
|
||||
if (outputResolution == _Configuration.OutputResolutions[0] || _Configuration.SaveShortcutsForOutputResolutions.Contains(outputResolution))
|
||||
{
|
||||
for (int i = 0; i < faceCollections.Count; i++)
|
||||
filteredPropertyHolderCollection[i].Faces.AddRange(from l in faceCollections[i] select l);
|
||||
PropertyHolder.AddToNamed(propertyLogic, filteredPropertyHolderCollection);
|
||||
filteredItems[i].Faces.AddRange(from l in faceCollections[i] select l);
|
||||
Item.AddToNamed(propertyLogic, filteredItems);
|
||||
if (_Configuration.SaveShortcutsForOutputResolutions.Contains(outputResolution))
|
||||
D_Face.SaveShortcuts(configuration, model, predictorModel, _Configuration.JuliePhares, ticks, peopleCollection, propertyLogic, outputResolution, filteredPropertyHolderCollection);
|
||||
D_Face.SaveShortcuts(configuration, model, predictorModel, _Configuration.JuliePhares, ticks, peopleCollection, propertyLogic, outputResolution, filteredItems);
|
||||
}
|
||||
}
|
||||
if (exceptionCount == 0 && _Configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions.Contains(outputResolution))
|
||||
_Distance.LoadOrCreateThenSaveDistanceResultsForOutputResolutions(configuration, model, predictorModel, sourceDirectory, outputResolution, sourceDirectoryChanges, filteredPropertyHolderCollection, faceCollections);
|
||||
_Distance.LoadOrCreateThenSaveDistanceResultsForOutputResolutions(configuration, model, predictorModel, container.SourceDirectory, outputResolution, sourceDirectoryChanges, filteredItems, faceCollections);
|
||||
if (_Resize.AngleBracketCollection.Any())
|
||||
_ = Property.Models.Stateless.IPath.DeleteEmptyDirectories(_Resize.AngleBracketCollection[0].Replace("<>", "()"));
|
||||
if (_Faces.AngleBracketCollection.Any())
|
||||
@ -716,9 +711,22 @@ public class DlibDotNet
|
||||
propertyLogic.SaveAllCollection();
|
||||
if (propertyLogic.NamedFaceInfoDeterministicHashCodeIndices.Any())
|
||||
{
|
||||
collection = E_Distance.GetGroupedFaceEncodings(argZero, propertyHolderCollections);
|
||||
E_Distance.SaveGroupedFaceEncodings(collection, peopleCollection, eDistanceCollectionDirectory);
|
||||
E_Distance.GetClosest(argZero, propertyHolderCollections, collection, peopleCollection, eDistanceCollectionDirectory);
|
||||
const int maxPer = 5;
|
||||
const bool skipIsWrongYear = true;
|
||||
string dFacesContentDirectory;
|
||||
string eDistanceContentDirectory;
|
||||
string eDistanceCollectionDirectory;
|
||||
string zPropertyHolderSingletonDirectory;
|
||||
List<(DateTime, bool?, PersonBirthday, FaceRecognitionDotNet.FaceEncoding[])> collection;
|
||||
dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model, predictorModel, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
eDistanceContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model, predictorModel, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), $"({ticks})");
|
||||
eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model, predictorModel, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), $"[{ticks}]");
|
||||
zPropertyHolderSingletonDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model, predictorModel, $"Z_{nameof(Item)}", outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "{}");
|
||||
collection = E_Distance.GetThreeSigmaFaceEncodings(argZero, containers);
|
||||
E_Distance.AddClosest(argZero, containers, collection, skipIsWrongYear, maxPer);
|
||||
E_Distance.SavePropertyHolders(argZero, containers, zPropertyHolderSingletonDirectory);
|
||||
E_Distance.SaveClosest(argZero, containers, eDistanceContentDirectory, dFacesContentDirectory);
|
||||
E_Distance.SaveThreeSigmaFaceEncodings(collection, peopleCollection, eDistanceCollectionDirectory);
|
||||
}
|
||||
if (!_Configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions.Any())
|
||||
break;
|
||||
@ -739,23 +747,27 @@ public class DlibDotNet
|
||||
}
|
||||
}
|
||||
|
||||
private PropertyLogic GetPropertyLogic()
|
||||
private PropertyLogic GetPropertyLogic(bool reverse, Model? model, PredictorModel? predictorModel)
|
||||
{
|
||||
PropertyLogic result;
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new ArgumentNullException(nameof(_AppSettings.MaxDegreeOfParallelism));
|
||||
throw new NullReferenceException(nameof(_AppSettings.MaxDegreeOfParallelism));
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new ArgumentNullException(nameof(_Configuration.PropertyConfiguration));
|
||||
result = new(_AppSettings.MaxDegreeOfParallelism.Value, _Configuration.PropertyConfiguration);
|
||||
throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration));
|
||||
result = new(_AppSettings.MaxDegreeOfParallelism.Value, _Configuration.PropertyConfiguration, reverse, model, predictorModel);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void Search(Property.Models.Configuration configuration, bool reverse, Model? model, PredictorModel? predictorModel, string argZero, Person[] people)
|
||||
{
|
||||
PropertyLogic propertyLogic = GetPropertyLogic();
|
||||
List<Container> containers;
|
||||
Dictionary<string, List<Person>> peopleCollection = A2_People.Convert(people);
|
||||
List<PropertyHolder[]> propertyHolderCollections = Property.Models.Stateless.A_Property.Get(configuration, reverse, model, predictorModel, propertyLogic);
|
||||
FullDoWork(configuration, model, predictorModel, argZero, peopleCollection, propertyLogic, propertyHolderCollections);
|
||||
PropertyLogic propertyLogic = GetPropertyLogic(reverse, model, predictorModel);
|
||||
if (string.IsNullOrEmpty(configuration.RootDirectory))
|
||||
containers = Property.Models.Stateless.A_Property.Get(configuration, propertyLogic);
|
||||
else
|
||||
containers = Property.Models.Stateless.Container.GetContainers(configuration, propertyLogic);
|
||||
FullDoWork(configuration, model, predictorModel, argZero, peopleCollection, propertyLogic, containers);
|
||||
}
|
||||
|
||||
internal void RenameQueue(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel) => _Rename.RenameQueue(configuration, model, predictorModel);
|
||||
|
@ -65,7 +65,7 @@ internal class A2_People
|
||||
{
|
||||
Person[] results;
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new ArgumentNullException(nameof(_Configuration.PropertyConfiguration));
|
||||
throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration));
|
||||
string rootDirectory = _Configuration.PropertyConfiguration.RootDirectory;
|
||||
string peopleRootDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(A2_People));
|
||||
string? rootResultsDirectory = Path.GetDirectoryName(Path.GetDirectoryName(peopleRootDirectory));
|
||||
|
@ -107,10 +107,12 @@ internal class D2_FaceLandmarks
|
||||
|
||||
#pragma warning restore CA1416
|
||||
|
||||
internal void SaveFaceLandmarkImages(List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, PropertyHolder propertyHolder, List<D_Face> faceCollections)
|
||||
internal void SaveFaceLandmarkImages(List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Item item, List<D_Face> faceCollections)
|
||||
{
|
||||
if (propertyHolder.ResizedFileHolder is null)
|
||||
throw new Exception($"{propertyHolder.ResizedFileHolder} is null!");
|
||||
if (item.ImageFileHolder is null)
|
||||
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
||||
if (item.ResizedFileHolder is null)
|
||||
throw new NullReferenceException(nameof(item.ResizedFileHolder));
|
||||
FileInfo fileInfo;
|
||||
bool check = false;
|
||||
string parentCheck;
|
||||
@ -120,7 +122,7 @@ internal class D2_FaceLandmarks
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
List<string[]> imageFiles = new();
|
||||
bool updateDateWhenMatches = false;
|
||||
string facesDirectory = Path.Combine(AngleBracketCollection[0].Replace("<>", "()"), propertyHolder.ImageFileNameWithoutExtension);
|
||||
string facesDirectory = Path.Combine(AngleBracketCollection[0].Replace("<>", "()"), item.ImageFileHolder.NameWithoutExtension);
|
||||
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata), nameof(C_Resize), nameof(D_Face) };
|
||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
if (!Directory.Exists(facesDirectory))
|
||||
@ -132,7 +134,7 @@ internal class D2_FaceLandmarks
|
||||
imageFiles.Add(Array.Empty<string>());
|
||||
continue;
|
||||
}
|
||||
fileInfo = new FileInfo(Path.Combine(facesDirectory, $"{i} - {propertyHolder.ImageFileNameWithoutExtension}.png"));
|
||||
fileInfo = new FileInfo(Path.Combine(facesDirectory, $"{i} - {item.ImageFileHolder.NameWithoutExtension}.png"));
|
||||
if (!fileInfo.Exists)
|
||||
{
|
||||
if (fileInfo.Directory?.Parent is null)
|
||||
@ -164,7 +166,7 @@ internal class D2_FaceLandmarks
|
||||
}
|
||||
}
|
||||
if (check)
|
||||
SaveFaceLandmarkImages(faceCollections, imageFiles, pointSize, propertyHolder.ResizedFileHolder);
|
||||
SaveFaceLandmarkImages(faceCollections, imageFiles, pointSize, item.ResizedFileHolder);
|
||||
}
|
||||
|
||||
}
|
@ -251,15 +251,17 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
}
|
||||
}
|
||||
|
||||
private List<D_Face> GetFaces(FileHolder resizedFileHolder, PropertyHolder propertyHolder, A_Property property, int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation, string facesDirectory)
|
||||
private List<D_Face> GetFaces(FileHolder resizedFileHolder, Item item, A_Property property, int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation, string facesDirectory)
|
||||
{
|
||||
List<D_Face> results = new();
|
||||
if (_Configuration.PaddingLoops is null)
|
||||
throw new Exception();
|
||||
if (item.ImageFileHolder is null)
|
||||
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
||||
if (_Configuration.NumberOfJitters is null)
|
||||
throw new ArgumentNullException(nameof(_Configuration.NumberOfJitters));
|
||||
throw new NullReferenceException(nameof(_Configuration.NumberOfJitters));
|
||||
if (_Configuration.NumberOfTimesToUpsample is null)
|
||||
throw new ArgumentNullException(nameof(_Configuration.NumberOfTimesToUpsample));
|
||||
throw new NullReferenceException(nameof(_Configuration.NumberOfTimesToUpsample));
|
||||
List<Location> locations;
|
||||
FaceRecognitionDotNet.Image? unknownImage = null;
|
||||
if (resizedFileHolder.Exists)
|
||||
@ -269,13 +271,13 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
catch (Exception) { }
|
||||
}
|
||||
if (unknownImage is null)
|
||||
results.Add(new D_Face(property, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, propertyHolder.RelativePath, i: null, location: null));
|
||||
results.Add(new D_Face(property, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, item.RelativePath, i: null, location: null));
|
||||
else
|
||||
{
|
||||
FaceRecognition faceRecognition = FaceRecognition.Create(_ModelParameter);
|
||||
locations = faceRecognition.FaceLocations(_Model, unknownImage, _Configuration.NumberOfTimesToUpsample.Value, sortByPixelPercentage: true);
|
||||
if (!locations.Any())
|
||||
results.Add(new D_Face(property, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, propertyHolder.RelativePath, i: null, location: null));
|
||||
results.Add(new D_Face(property, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, item.RelativePath, i: null, location: null));
|
||||
else
|
||||
{
|
||||
double? α;
|
||||
@ -312,7 +314,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
locations[i].Top - (padding * p),
|
||||
source.Width,
|
||||
source.Height);
|
||||
face = new(property, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, propertyHolder.RelativePath, i, location);
|
||||
face = new(property, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, item.RelativePath, i, location);
|
||||
width = location.Right - location.Left;
|
||||
height = location.Bottom - location.Top;
|
||||
rectangle = new Rectangle(location.Left, location.Top, width, height);
|
||||
@ -329,7 +331,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
using (knownImage = FaceRecognition.LoadImage(preRotated))
|
||||
{
|
||||
if (knownImage is null || knownImage.IsDisposed)
|
||||
throw new ArgumentNullException(nameof(knownImage));
|
||||
throw new NullReferenceException(nameof(knownImage));
|
||||
facesLandmarks = faceRecognition.GetFaceLandmarkCollection(knownImage, _Configuration.NumberOfTimesToUpsample.Value, faceLocations: null, _PredictorModel, _Model);
|
||||
}
|
||||
if (facesLandmarks.Count == 0 && p < _Configuration.PaddingLoops.Value)
|
||||
@ -361,7 +363,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
using (rotatedImage = FaceRecognition.LoadImage(rotated))
|
||||
{
|
||||
if (rotatedImage is null || rotatedImage.IsDisposed)
|
||||
throw new ArgumentNullException(nameof(rotatedImage));
|
||||
throw new NullReferenceException(nameof(rotatedImage));
|
||||
faceEncodings = faceRecognition.FaceEncodings(rotatedImage, _Configuration.NumberOfTimesToUpsample.Value, knownFaceLocation: null, _Configuration.NumberOfJitters.Value, _PredictorModel, _Model);
|
||||
}
|
||||
if (faceEncodings.Count == 0 && p < _Configuration.PaddingLoops.Value)
|
||||
@ -372,7 +374,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
faceEncoding = new(rawEncoding, faceEncodings[0].Size);
|
||||
face.Update(α, faceEncoding, populated: true);
|
||||
}
|
||||
faceFile = Path.Combine(facesDirectory, $"{i} - {propertyHolder.ImageFileNameWithoutExtension}.png");
|
||||
faceFile = Path.Combine(facesDirectory, $"{i} - {item.ImageFileHolder.NameWithoutExtension}.png");
|
||||
preRotated.Save(faceFile, System.Drawing.Imaging.ImageFormat.Png);
|
||||
results.Add(face);
|
||||
}
|
||||
@ -388,7 +390,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
locations[i].Top,
|
||||
source.Width,
|
||||
source.Height);
|
||||
face = new D_Face(property, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, propertyHolder.RelativePath, i, location);
|
||||
face = new D_Face(property, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, item.RelativePath, i, location);
|
||||
results.Add(face);
|
||||
}
|
||||
}
|
||||
@ -410,18 +412,20 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
_Populated = populated;
|
||||
}
|
||||
|
||||
internal List<D_Face> GetFaces(Property.Models.Configuration configuration, string outputResolution, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, PropertyHolder propertyHolder, A_Property property, FileHolder resizedFileHolder, int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation)
|
||||
internal List<D_Face> GetFaces(Property.Models.Configuration configuration, string outputResolution, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Item item, A_Property property, FileHolder resizedFileHolder, int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation)
|
||||
{
|
||||
List<D_Face>? results;
|
||||
if (_Configuration.PropertiesChangedForFaces is null)
|
||||
throw new Exception();
|
||||
if (item.ImageFileHolder is null)
|
||||
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
||||
string json;
|
||||
D_Face face;
|
||||
bool checkForOutputResolutionChange = false;
|
||||
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata), nameof(C_Resize) };
|
||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
string facesDirectory = Path.Combine(AngleBracketCollection[0].Replace("<>", "()"), propertyHolder.ImageFileNameWithoutExtension);
|
||||
FileInfo fileInfo = new(Path.Combine(AngleBracketCollection[0].Replace("<>", "[]"), $"{propertyHolder.ImageFileNameWithoutExtension}.json"));
|
||||
string facesDirectory = Path.Combine(AngleBracketCollection[0].Replace("<>", "()"), item.ImageFileHolder.NameWithoutExtension);
|
||||
FileInfo fileInfo = new(Path.Combine(AngleBracketCollection[0].Replace("<>", "[]"), $"{item.ImageFileHolder.NameWithoutExtension}.json"));
|
||||
if (!fileInfo.Exists)
|
||||
{
|
||||
if (fileInfo.Directory?.Parent is null)
|
||||
@ -445,7 +449,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
{
|
||||
results = JsonSerializer.Deserialize<List<D_Face>>(json);
|
||||
if (results is null)
|
||||
throw new ArgumentNullException(nameof(results));
|
||||
throw new NullReferenceException(nameof(results));
|
||||
for (int i = 0; i < results.Count; i++)
|
||||
{
|
||||
face = results[i];
|
||||
@ -473,7 +477,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
}
|
||||
else if (results is null)
|
||||
{
|
||||
results = GetFaces(resizedFileHolder, propertyHolder, property, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, facesDirectory);
|
||||
results = GetFaces(resizedFileHolder, item, property, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, facesDirectory);
|
||||
json = JsonSerializer.Serialize(results, _WriteIndentedJsonSerializerOptions);
|
||||
bool updateDateWhenMatches = dateTimes.Any() && fileInfo.Exists && dateTimes.Max() > fileInfo.LastWriteTime;
|
||||
DateTime? dateTime = !updateDateWhenMatches ? null : dateTimes.Max();
|
||||
@ -483,18 +487,20 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
return results;
|
||||
}
|
||||
|
||||
internal void SaveFaces(Property.Models.Configuration configuration, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, PropertyHolder propertyHolder, List<D_Face> faceCollection)
|
||||
internal void SaveFaces(Property.Models.Configuration configuration, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, Item item, List<D_Face> faceCollection)
|
||||
{
|
||||
if (_Configuration.OverrideForFaceImages is null)
|
||||
throw new Exception();
|
||||
if (propertyHolder.ResizedFileHolder is null)
|
||||
throw new Exception($"{propertyHolder.ResizedFileHolder} is null!");
|
||||
if (item.ImageFileHolder is null)
|
||||
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
||||
if (item.ResizedFileHolder is null)
|
||||
throw new NullReferenceException(nameof(item.ResizedFileHolder));
|
||||
FileInfo fileInfo;
|
||||
bool check = false;
|
||||
string parentCheck;
|
||||
List<string> imageFiles = new();
|
||||
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata), nameof(C_Resize) };
|
||||
string facesDirectory = Path.Combine(AngleBracketCollection[0].Replace("<>", "()"), propertyHolder.ImageFileNameWithoutExtension);
|
||||
string facesDirectory = Path.Combine(AngleBracketCollection[0].Replace("<>", "()"), item.ImageFileHolder.NameWithoutExtension);
|
||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
bool facesDirectoryExisted = Directory.Exists(facesDirectory);
|
||||
if (!facesDirectoryExisted)
|
||||
@ -506,7 +512,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
imageFiles.Add(string.Empty);
|
||||
continue;
|
||||
}
|
||||
fileInfo = new FileInfo(Path.Combine(facesDirectory, $"{i} - {propertyHolder.ImageFileNameWithoutExtension}.png"));
|
||||
fileInfo = new FileInfo(Path.Combine(facesDirectory, $"{i} - {item.ImageFileHolder.NameWithoutExtension}.png"));
|
||||
if (!fileInfo.Exists)
|
||||
{
|
||||
if (fileInfo.Directory?.Parent is null)
|
||||
@ -524,19 +530,20 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
check = true;
|
||||
}
|
||||
if (check)
|
||||
SaveFaces(faceCollection, propertyHolder.ResizedFileHolder, imageFiles);
|
||||
SaveFaces(faceCollection, item.ResizedFileHolder, imageFiles);
|
||||
}
|
||||
|
||||
internal static void SaveShortcuts(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string[] juliePhares, long ticks, Dictionary<string, List<Person>> peopleCollection, PropertyLogic propertyLogic, string outputResolution, PropertyHolder[] filteredPropertyHolderCollection)
|
||||
internal static void SaveShortcuts(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string[] juliePhares, long ticks, Dictionary<string, List<Person>> peopleCollection, PropertyLogic propertyLogic, string outputResolution, Item[] filteredItems)
|
||||
{
|
||||
Person person;
|
||||
string fileName;
|
||||
string fullName;
|
||||
DateTime? minimumDateTime;
|
||||
WindowsShortcut windowsShortcut;
|
||||
const string pattern = @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]";
|
||||
string dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model, predictorModel, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), $"({ticks})");
|
||||
List<(PropertyHolder, (string, Shared.Models.Properties.IFace?, (string, string, string, string))[])> collections = PropertyHolder.GetCollection(propertyLogic, filteredPropertyHolderCollection, dFacesContentDirectory);
|
||||
foreach ((PropertyHolder propertyHolder, (string personKey, Shared.Models.Properties.IFace? _, (string, string, string, string))[] collection) in collections)
|
||||
List<(Item, (string, Shared.Models.Properties.IFace?, (string, string, string, string))[])> collections = Item.GetCollection(propertyLogic, filteredItems, dFacesContentDirectory);
|
||||
foreach ((Item item, (string personKey, Shared.Models.Properties.IFace? _, (string, string, string, string))[] collection) in collections)
|
||||
{
|
||||
if (collection.Length != 1)
|
||||
continue;
|
||||
@ -544,7 +551,10 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
{
|
||||
if (string.IsNullOrEmpty(personKey))
|
||||
continue;
|
||||
if (propertyHolder.Property?.Id is null || propertyHolder.ImageFileHolder is null || propertyHolder.MinimumDateTime is null || propertyHolder.ResizedFileHolder is null)
|
||||
if (item.Property?.Id is null || item.ImageFileHolder is null || item.ResizedFileHolder is null)
|
||||
continue;
|
||||
minimumDateTime = Property.Models.Stateless.A_Property.GetMinimumDateTime(item.Property);
|
||||
if (minimumDateTime is null)
|
||||
continue;
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
@ -560,19 +570,19 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
{
|
||||
if (!Directory.Exists(copyDirectory))
|
||||
_ = Directory.CreateDirectory(copyDirectory);
|
||||
fileName = Path.Combine(copyDirectory, $"{propertyHolder.Property.Id.Value}{propertyHolder.ResizedFileHolder.Extension}");
|
||||
fileName = Path.Combine(copyDirectory, $"{item.Property.Id.Value}{item.ResizedFileHolder.ExtensionLowered}");
|
||||
if (!File.Exists(fileName))
|
||||
File.Copy(propertyHolder.ResizedFileHolder.FullName, fileName);
|
||||
File.Copy(item.ResizedFileHolder.FullName, fileName);
|
||||
}
|
||||
fileName = Path.Combine(directory, $"{propertyHolder.Property.Id.Value}.lnk");
|
||||
fileName = Path.Combine(directory, $"{item.Property.Id.Value}.lnk");
|
||||
if (File.Exists(fileName))
|
||||
continue;
|
||||
windowsShortcut = new() { Path = propertyHolder.ImageFileHolder.FullName };
|
||||
windowsShortcut = new() { Path = item.ImageFileHolder.FullName };
|
||||
windowsShortcut.Save(fileName);
|
||||
windowsShortcut.Dispose();
|
||||
if (!File.Exists(fileName))
|
||||
continue;
|
||||
File.SetLastWriteTime(fileName, propertyHolder.MinimumDateTime.Value);
|
||||
File.SetLastWriteTime(fileName, minimumDateTime.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ internal class E2_Navigate
|
||||
private void DisplayTags(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string outputResolution, string[] directories, Dictionary<ConsoleKey, int> directoryKeyValuePairs, string[] files, Dictionary<ConsoleKey, int> fileKeyValuePairs)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new ArgumentNullException(nameof(_Log));
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
bool all = false;
|
||||
FileSystem fileSystem;
|
||||
string requestPath = "/RootResultsDirectory";
|
||||
@ -71,7 +71,7 @@ internal class E2_Navigate
|
||||
private void DisplayFaces(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string outputResolution, string selectedFileFullName)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new ArgumentNullException(nameof(_Log));
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
string requestPath = "/RootResultsDirectory";
|
||||
string? rootResultsDirectory = Path.GetDirectoryName(Property.Models.Stateless.IResult.GetResultsGroupDirectory(configuration, nameof(B_Metadata)));
|
||||
if (string.IsNullOrEmpty(rootResultsDirectory))
|
||||
@ -95,9 +95,9 @@ internal class E2_Navigate
|
||||
{
|
||||
string result;
|
||||
if (_Log is null)
|
||||
throw new ArgumentNullException(nameof(_Log));
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new ArgumentNullException(nameof(_Configuration.PropertyConfiguration));
|
||||
throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration));
|
||||
_Log.Warn(string.Concat("What is the new name for [", Path.GetFileName(subSourceDirectory), "]<", subSourceDirectory, ">?"));
|
||||
string? newDirectoryName = _Console.ReadLine();
|
||||
_Log.Warn("Are you sure y[es] || n[o]?");
|
||||
@ -135,7 +135,7 @@ internal class E2_Navigate
|
||||
internal void Navigate(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string outputResolution)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new ArgumentNullException(nameof(_Log));
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
string[] subFiles;
|
||||
ConsoleKey consoleKey;
|
||||
string[] subDirectories;
|
||||
|
@ -115,7 +115,7 @@ internal class E3_Rename
|
||||
{
|
||||
List<string[]> results = new();
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new ArgumentNullException(nameof(_Configuration.PropertyConfiguration));
|
||||
throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration));
|
||||
bool add;
|
||||
string to;
|
||||
bool exists;
|
||||
@ -230,7 +230,7 @@ internal class E3_Rename
|
||||
internal void DirectoryRename(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string relativePath, string newDirectoryName)
|
||||
{
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new ArgumentNullException(nameof(_Configuration.PropertyConfiguration));
|
||||
throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration));
|
||||
string json;
|
||||
FileInfo current;
|
||||
FileInfo fileInfo;
|
||||
|
@ -33,11 +33,11 @@ internal class E_Distance
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void LoadFaceEncodingCollections(PropertyHolder[] filteredPropertyHolderCollection, List<List<D_Face>> faceCollections, List<int[]> locationIndicesCollection, List<FaceEncoding> faceEncodingCollection, List<List<FaceEncoding>> faceEncodingCollections)
|
||||
private static void LoadFaceEncodingCollections(Item[] filteredItems, List<List<D_Face>> faceCollections, List<int[]> locationIndicesCollection, List<FaceEncoding> faceEncodingCollection, List<List<FaceEncoding>> faceEncodingCollections)
|
||||
{
|
||||
List<D_Face> faceCollection;
|
||||
FaceEncoding faceEncoding;
|
||||
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
|
||||
for (int i = 0; i < filteredItems.Length; i++)
|
||||
{
|
||||
faceCollection = faceCollections[i];
|
||||
if (!faceCollection.Any())
|
||||
@ -171,28 +171,28 @@ internal class E_Distance
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadOrCreateThenSaveDistanceResultsForOutputResolutions(Property.Models.Configuration configuration, PropertyHolder[] filteredPropertyHolderCollection, List<List<D_Face>> faceCollections, List<string[]> directories, bool updateDateWhenMatches, DateTime? updateToWhenMatches)
|
||||
private void LoadOrCreateThenSaveDistanceResultsForOutputResolutions(Property.Models.Configuration configuration, Item[] filteredItems, List<List<D_Face>> faceCollections, List<string[]> directories, bool updateDateWhenMatches, DateTime? updateToWhenMatches)
|
||||
{
|
||||
FileHolder? fileHolder;
|
||||
List<int[]> locationIndicesCollection = new();
|
||||
List<Tuple<string, DateTime>> subFileTuples = new();
|
||||
List<FaceEncoding> faceEncodingCollection = new();
|
||||
List<List<FaceEncoding>> faceEncodingCollections = new();
|
||||
LoadFaceEncodingCollections(filteredPropertyHolderCollection, faceCollections, locationIndicesCollection, faceEncodingCollection, faceEncodingCollections);
|
||||
LoadFaceEncodingCollections(filteredItems, faceCollections, locationIndicesCollection, faceEncodingCollection, faceEncodingCollections);
|
||||
if (faceEncodingCollections.Count != faceCollections.Count)
|
||||
throw new Exception();
|
||||
if (locationIndicesCollection.Count != faceEncodingCollection.Count)
|
||||
throw new Exception();
|
||||
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
|
||||
for (int i = 0; i < filteredItems.Length; i++)
|
||||
{
|
||||
fileHolder = filteredPropertyHolderCollection[i].ImageFileHolder;
|
||||
fileHolder = filteredItems[i].ImageFileHolder;
|
||||
if (fileHolder is null)
|
||||
continue;
|
||||
LoadOrCreateThenSaveDistanceResultsForOutputResolutionsLoop(configuration, faceCollections, filteredPropertyHolderCollection.Length, i, faceCollections[i], locationIndicesCollection, subFileTuples, faceEncodingCollection, faceEncodingCollections[i], fileHolder.NameWithoutExtension, directories[i][0], directories[i][1], updateDateWhenMatches, updateToWhenMatches);
|
||||
LoadOrCreateThenSaveDistanceResultsForOutputResolutionsLoop(configuration, faceCollections, filteredItems.Length, i, faceCollections[i], locationIndicesCollection, subFileTuples, faceEncodingCollection, faceEncodingCollections[i], fileHolder.NameWithoutExtension, directories[i][0], directories[i][1], updateDateWhenMatches, updateToWhenMatches);
|
||||
}
|
||||
}
|
||||
|
||||
internal void LoadOrCreateThenSaveDistanceResultsForOutputResolutions(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string sourceDirectory, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, PropertyHolder[] filteredPropertyHolderCollection, List<List<D_Face>> faceCollections)
|
||||
internal void LoadOrCreateThenSaveDistanceResultsForOutputResolutions(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string sourceDirectory, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, Item[] filteredItems, List<List<D_Face>> faceCollections)
|
||||
{
|
||||
if (_Configuration.CheckJsonForDistanceResults is null)
|
||||
throw new Exception();
|
||||
@ -222,9 +222,9 @@ internal class E_Distance
|
||||
contentDescription: ".tvs File",
|
||||
singletonDescription: string.Empty,
|
||||
collectionDescription: "n json file(s) for each face found (one to many)");
|
||||
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
|
||||
for (int i = 0; i < filteredItems.Length; i++)
|
||||
{
|
||||
fileHolder = filteredPropertyHolderCollection[i].ImageFileHolder;
|
||||
fileHolder = filteredItems[i].ImageFileHolder;
|
||||
if (fileHolder is null)
|
||||
continue;
|
||||
directoryInfo = new System.IO.DirectoryInfo(Path.Combine(directoryInfoCollection[0].Replace("<>", "[]"), fileHolder.NameWithoutExtension));
|
||||
@ -269,7 +269,7 @@ internal class E_Distance
|
||||
}
|
||||
}
|
||||
if (check)
|
||||
LoadOrCreateThenSaveDistanceResultsForOutputResolutions(configuration, filteredPropertyHolderCollection, faceCollections, directories, updateDateWhenMatches, updateToWhenMatches: dateTime);
|
||||
LoadOrCreateThenSaveDistanceResultsForOutputResolutions(configuration, filteredItems, faceCollections, directories, updateDateWhenMatches, updateToWhenMatches: dateTime);
|
||||
_ = Property.Models.Stateless.IPath.DeleteEmptyDirectories(directoryInfoCollection[0].Replace("<>", "()"));
|
||||
}
|
||||
|
||||
@ -353,7 +353,7 @@ internal class E_Distance
|
||||
internal void LoadOrCreateThenSaveDirectoryDistanceResultsForOutputResolutions(Property.Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string outputResolution)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new ArgumentNullException(nameof(_Log));
|
||||
throw new NullReferenceException(nameof(_Log));
|
||||
string? relativePath;
|
||||
Shared.Models.Face face;
|
||||
ParallelOptions parallelOptions = new();
|
||||
@ -414,9 +414,9 @@ internal class E_Distance
|
||||
return result;
|
||||
}
|
||||
|
||||
internal static List<(string[], Shared.Models.PersonBirthday, FaceEncoding[])> GetGroupedFaceEncodings(string argZero, List<PropertyHolder[]> propertyHolderCollections)
|
||||
internal static List<(DateTime, bool?, Shared.Models.PersonBirthday, FaceEncoding[])> GetThreeSigmaFaceEncodings(string argZero, List<Container> containers)
|
||||
{
|
||||
List<(string[], Shared.Models.PersonBirthday, FaceEncoding[])> results = new();
|
||||
List<(DateTime, bool?, Shared.Models.PersonBirthday, FaceEncoding[])> results = new();
|
||||
double lcl;
|
||||
double ucl;
|
||||
double sum;
|
||||
@ -428,13 +428,13 @@ internal class E_Distance
|
||||
FaceEncoding faceEncoding;
|
||||
List<double> faceDistances;
|
||||
List<FaceEncoding> faceEncodings;
|
||||
Dictionary<string, List<(string[], Shared.Models.PersonBirthday, Shared.Models.Properties.IFace)>> keyValuePairs = PropertyHolder.GetKeyValuePairs(argZero, propertyHolderCollections);
|
||||
foreach (KeyValuePair<string, List<(string[] Directories, Shared.Models.PersonBirthday PersonBirthday, Shared.Models.Properties.IFace _)>> keyValuePair in keyValuePairs)
|
||||
Dictionary<string, List<(DateTime, bool?, Shared.Models.PersonBirthday, Shared.Models.Properties.IFace)>> keyValuePairs = Item.GetKeyValuePairs(argZero, containers);
|
||||
foreach (KeyValuePair<string, List<(DateTime MinimumDateTime, bool? IsWrongYear, Shared.Models.PersonBirthday PersonBirthday, Shared.Models.Properties.IFace _)>> keyValuePair in keyValuePairs)
|
||||
{
|
||||
lowestIndex = 0;
|
||||
faceEncodings = new();
|
||||
lowestSum = double.MaxValue;
|
||||
foreach ((string[] directories, Shared.Models.PersonBirthday personBirthday, Shared.Models.Properties.IFace face) in keyValuePair.Value)
|
||||
foreach ((DateTime minimumDateTime, bool? isWrongYear, Shared.Models.PersonBirthday personBirthday, Shared.Models.Properties.IFace face) in keyValuePair.Value)
|
||||
{
|
||||
if (!face.Populated)
|
||||
continue;
|
||||
@ -462,17 +462,17 @@ internal class E_Distance
|
||||
standardDeviation = GetStandardDeviation(faceDistances, average);
|
||||
lcl = average - (standardDeviation * 3);
|
||||
ucl = average + (standardDeviation * 3);
|
||||
for (int i = faceEncodings.Count; i > -1; i--)
|
||||
for (int i = faceEncodings.Count - 1; i > -1; i--)
|
||||
{
|
||||
if (faceDistances[i] < lcl || faceDistances[i] > ucl)
|
||||
faceEncodings.RemoveAt(i);
|
||||
}
|
||||
results.Add(new(keyValuePair.Value[zero].Directories, keyValuePair.Value[zero].PersonBirthday, faceEncodings.ToArray()));
|
||||
results.Add(new(keyValuePair.Value[zero].MinimumDateTime, keyValuePair.Value[zero].IsWrongYear, keyValuePair.Value[zero].PersonBirthday, faceEncodings.ToArray()));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static void SaveGroupedFaceEncodings(List<(string[], Shared.Models.PersonBirthday, FaceEncoding[])> collection, Dictionary<string, List<Shared.Models.Person>> peopleCollection, string eDistanceCollectionDirectory)
|
||||
internal static void SaveThreeSigmaFaceEncodings(List<(DateTime, bool?, Shared.Models.PersonBirthday, FaceEncoding[])> collection, Dictionary<string, List<Shared.Models.Person>> peopleCollection, string eDistanceCollectionDirectory)
|
||||
{
|
||||
string json;
|
||||
string checkFile;
|
||||
@ -480,14 +480,14 @@ internal class E_Distance
|
||||
string directory;
|
||||
List<double[]> rawEncodings;
|
||||
Shared.Models.Person person;
|
||||
const string facePopulatedKey = "ThreeSigma";
|
||||
const string pattern = @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]";
|
||||
foreach ((string[] directories, Shared.Models.PersonBirthday personBirthday, FaceEncoding[] faceEncodings) in collection)
|
||||
foreach ((DateTime minimumDateTime, bool? isWrongYear, Shared.Models.PersonBirthday personBirthday, FaceEncoding[] faceEncodings) in collection)
|
||||
{
|
||||
directories[0] = eDistanceCollectionDirectory;
|
||||
rawEncodings = new();
|
||||
checkFile = string.Empty;
|
||||
directory = Path.Combine(directories);
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(personBirthday);
|
||||
directory = Item.GetDirectory(eDistanceCollectionDirectory, facePopulatedKey, minimumDateTime, isWrongYear, personBirthday, personKey);
|
||||
person = peopleCollection[personKey][0];
|
||||
checkFile = string.Concat(directory, " - ", Regex.Replace(Shared.Models.Stateless.Methods.IPersonName.GetFullName(person.Name), pattern, string.Empty), ".json");
|
||||
if (string.IsNullOrEmpty(checkFile))
|
||||
@ -501,81 +501,150 @@ internal class E_Distance
|
||||
}
|
||||
}
|
||||
|
||||
public static void GetKeyValuePairs(string argZero, List<PropertyHolder[]> propertyHolderCollections, List<(string[], Shared.Models.PersonBirthday, FaceEncoding[])> collection)
|
||||
public static void AddClosest(string argZero, List<Container> containers, List<(DateTime, bool?, Shared.Models.PersonBirthday, FaceEncoding[])> collection, bool skipIsWrongYear, int maxPer)
|
||||
{
|
||||
string key;
|
||||
double average;
|
||||
string personKey;
|
||||
bool? isWrongYear;
|
||||
TimeSpan? timeSpan;
|
||||
double lowestAverage;
|
||||
string[] directories;
|
||||
string isWrongYearFlag;
|
||||
bool? itemIsWrongYear;
|
||||
bool? lowestIsWrongYear;
|
||||
FaceEncoding faceEncoding;
|
||||
List<double> faceDistances;
|
||||
const string facePopulatedKey = "MatchImages";
|
||||
DateTime? itemMinimumDateTime;
|
||||
DateTime? lowestMinimumDateTime;
|
||||
Shared.Models.Properties.IFace face;
|
||||
Dictionary<string, int> results = new();
|
||||
Shared.Models.PersonBirthday? lowestPersonBirthday;
|
||||
foreach (PropertyHolder[] propertyHolderCollection in propertyHolderCollections)
|
||||
foreach (Container container in containers)
|
||||
{
|
||||
lowestIsWrongYear = null;
|
||||
lowestPersonBirthday = null;
|
||||
lowestMinimumDateTime = null;
|
||||
lowestAverage = double.MaxValue;
|
||||
if (!propertyHolderCollection.Any())
|
||||
if (!container.Items.Any())
|
||||
continue;
|
||||
if (!propertyHolderCollection[0].SourceDirectory.StartsWith(argZero))
|
||||
if (!container.SourceDirectory.StartsWith(argZero))
|
||||
continue;
|
||||
foreach (PropertyHolder propertyHolder in propertyHolderCollection)
|
||||
foreach (Item item in container.Items)
|
||||
{
|
||||
if (propertyHolder.ImageFileHolder is null || propertyHolder.Property is null || propertyHolder.Named.Any())
|
||||
if (item.ImageFileHolder is null || item.Property is null || item.Named.Any())
|
||||
continue;
|
||||
if (propertyHolder.MinimumDateTime is null)
|
||||
itemMinimumDateTime = Property.Models.Stateless.A_Property.GetMinimumDateTime(item.Property);
|
||||
if (itemMinimumDateTime is null)
|
||||
continue;
|
||||
(isWrongYear, _) = propertyHolder.IsWrongYear();
|
||||
foreach (Shared.Models.Properties.IFace face in propertyHolder.Faces)
|
||||
(itemIsWrongYear, _) = item.IsWrongYear();
|
||||
if (skipIsWrongYear && itemIsWrongYear.HasValue && itemIsWrongYear.Value)
|
||||
continue;
|
||||
item.Closest.Clear();
|
||||
for (int i = 0; i < item.Faces.Count; i++)
|
||||
{
|
||||
face = item.Faces[i];
|
||||
item.Closest.Add(new(face.LocationIndex, itemMinimumDateTime.Value, itemIsWrongYear, null, null));
|
||||
if (!face.Populated)
|
||||
continue;
|
||||
faceEncoding = FaceRecognition.LoadFaceEncoding(face.FaceEncoding.RawEncoding);
|
||||
foreach ((string[] _, Shared.Models.PersonBirthday personBirthday, FaceEncoding[] faceEncodings) in collection)
|
||||
foreach ((DateTime minimumDateTime, bool? isWrongYear, Shared.Models.PersonBirthday personBirthday, FaceEncoding[] faceEncodings) in collection)
|
||||
{
|
||||
if (itemIsWrongYear.HasValue && !itemIsWrongYear.Value && itemMinimumDateTime.Value < personBirthday.Value)
|
||||
continue;
|
||||
faceDistances = FaceRecognition.FaceDistances(faceEncodings, faceEncoding);
|
||||
average = faceDistances.Average();
|
||||
if (average < lowestAverage)
|
||||
if (average > lowestAverage)
|
||||
continue;
|
||||
lowestAverage = average;
|
||||
lowestIsWrongYear = isWrongYear;
|
||||
lowestPersonBirthday = personBirthday;
|
||||
lowestMinimumDateTime = minimumDateTime;
|
||||
}
|
||||
if (lowestPersonBirthday is null)
|
||||
if (lowestPersonBirthday is null || lowestMinimumDateTime is null)
|
||||
continue;
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(lowestPersonBirthday);
|
||||
timeSpan = Shared.Models.Stateless.Methods.IPersonBirthday.GetTimeSpan(propertyHolder.MinimumDateTime.Value, isWrongYear, lowestPersonBirthday);
|
||||
if (timeSpan.HasValue && timeSpan.Value.Ticks < 0)
|
||||
directories = new string[] { string.Empty, facePopulatedKey, personKey, "!---" };
|
||||
else if (timeSpan.HasValue)
|
||||
directories = new string[] { string.Empty, facePopulatedKey, personKey, $"^{Math.Floor(timeSpan.Value.TotalDays / 365):000}" };
|
||||
else
|
||||
{
|
||||
isWrongYearFlag = PropertyHolder.GetWrongYearFlag(isWrongYear);
|
||||
directories = new string[] { string.Empty, facePopulatedKey, personKey, $"{isWrongYearFlag}{propertyHolder.MinimumDateTime.Value:yyyy}" };
|
||||
}
|
||||
key = Item.GetKey(lowestMinimumDateTime.Value, lowestIsWrongYear, lowestPersonBirthday);
|
||||
if (!results.ContainsKey(key))
|
||||
results.Add(key, 0);
|
||||
else if (results[key] > maxPer)
|
||||
continue;
|
||||
results[key] += 1;
|
||||
item.Closest[0] = new(face.LocationIndex, lowestMinimumDateTime.Value, lowestIsWrongYear, lowestPersonBirthday, lowestAverage);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void GetClosest(string argZero, List<PropertyHolder[]> propertyHolderCollections, List<(string[], Shared.Models.PersonBirthday, FaceEncoding[])> collection, Dictionary<string, List<Shared.Models.Person>> peopleCollection, string eDistanceCollectionDirectory)
|
||||
public static void SavePropertyHolders(string argZero, List<Container> containers, string zPropertyHolderSingletonDirectory)
|
||||
{
|
||||
GetKeyValuePairs(argZero, propertyHolderCollections, collection);
|
||||
if (peopleCollection is null)
|
||||
{ }
|
||||
if (string.IsNullOrEmpty(eDistanceCollectionDirectory))
|
||||
{ }
|
||||
// foreach (KeyValuePair<string, List<(string[] Directories, Shared.Models.PersonBirthday PersonBirthday, Shared.Models.Properties.IFace _)>> keyValuePair in keyValuePairs)
|
||||
// {
|
||||
// foreach ((string[] directories, Shared.Models.PersonBirthday personBirthday, Shared.Models.Properties.IFace face) in keyValuePair.Value)
|
||||
// {
|
||||
// if (face.Populated)
|
||||
// continue;
|
||||
// }
|
||||
// }
|
||||
string json;
|
||||
FileInfo fileInfo;
|
||||
bool updateDateWhenMatches = false;
|
||||
JsonSerializerOptions jsonSerializerOptions = new() { WriteIndented = true };
|
||||
foreach (Container container in containers)
|
||||
{
|
||||
if (!container.Items.Any())
|
||||
continue;
|
||||
if (!container.SourceDirectory.StartsWith(argZero))
|
||||
continue;
|
||||
foreach (Item item in container.Items)
|
||||
{
|
||||
if (item.ImageFileHolder is null || item.Property is null || !item.Faces.Any() || !item.Closest.Any())
|
||||
continue;
|
||||
if (!(from l in item.Closest where l.Average.HasValue select true).Any())
|
||||
continue;
|
||||
json = JsonSerializer.Serialize(item, jsonSerializerOptions);
|
||||
fileInfo = new(string.Concat(zPropertyHolderSingletonDirectory, item.RelativePath, ".json"));
|
||||
if (fileInfo.Directory is null)
|
||||
continue;
|
||||
if (!fileInfo.Directory.Exists)
|
||||
fileInfo.Directory.Create();
|
||||
_ = Property.Models.Stateless.IPath.WriteAllText(fileInfo.FullName, json, updateDateWhenMatches, compareBeforeWrite: true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void SaveClosest(string argZero, List<Container> containers, string eDistanceContentDirectory, string dFacesContentDirectory)
|
||||
{
|
||||
string copyFile;
|
||||
string checkFile;
|
||||
string directory;
|
||||
string personKey;
|
||||
string? directoryName;
|
||||
string facesDirectory;
|
||||
string faceFullFileName;
|
||||
const string facePopulatedKey = "Closet";
|
||||
foreach (Container container in containers)
|
||||
{
|
||||
if (!container.Items.Any())
|
||||
continue;
|
||||
if (!container.SourceDirectory.StartsWith(argZero))
|
||||
continue;
|
||||
foreach (Item item in container.Items)
|
||||
{
|
||||
if (item.ImageFileHolder is null || item.Property is null || item.ResizedFileHolder is null || item.Named.Any())
|
||||
continue;
|
||||
if (!item.Closest.Any())
|
||||
continue;
|
||||
directoryName = Path.GetDirectoryName(item.RelativePath);
|
||||
if (directoryName is null)
|
||||
throw new Exception();
|
||||
foreach (Closest closest in item.Closest)
|
||||
{
|
||||
if (closest.Average is null || closest.FaceLocationIndex is null || closest.PersonBirthday is null)
|
||||
continue;
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(closest.PersonBirthday);
|
||||
directory = Item.GetDirectory(eDistanceContentDirectory, facePopulatedKey, closest.MinimumDateTime, closest.IsWrongYear, closest.PersonBirthday, personKey);
|
||||
checkFile = Path.Combine(directory, item.ImageFileHolder.Name);
|
||||
if (!Directory.Exists(directory))
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
facesDirectory = string.Concat(dFacesContentDirectory, Path.Combine(directoryName, item.ImageFileHolder.NameWithoutExtension));
|
||||
faceFullFileName = Path.Combine(facesDirectory, $"{closest.FaceLocationIndex.Value} - {item.ImageFileHolder.NameWithoutExtension}.png");
|
||||
if (Directory.Exists(facesDirectory) && File.Exists(faceFullFileName))
|
||||
copyFile = faceFullFileName;
|
||||
else
|
||||
copyFile = item.ResizedFileHolder.FullName;
|
||||
if (File.Exists(checkFile))
|
||||
continue;
|
||||
File.Copy(copyFile, checkFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -29,7 +29,7 @@ internal class F_Random
|
||||
{
|
||||
bool result = false;
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new ArgumentNullException(nameof(_Configuration.PropertyConfiguration));
|
||||
throw new NullReferenceException(nameof(_Configuration.PropertyConfiguration));
|
||||
string? checkDirectory = Path.GetFullPath(directory);
|
||||
for (int i = 0; i < int.MaxValue; i++)
|
||||
{
|
||||
|
Reference in New Issue
Block a user