Ready to test
This commit is contained in:
@ -8,6 +8,7 @@ using View_by_Distance.Instance.Models;
|
||||
using View_by_Distance.Metadata.Models;
|
||||
using View_by_Distance.Property.Models;
|
||||
using View_by_Distance.Resize.Models;
|
||||
using View_by_Distance.Shared.Models;
|
||||
using View_by_Distance.Shared.Models.Methods;
|
||||
|
||||
namespace View_by_Distance.Instance;
|
||||
@ -36,6 +37,7 @@ public class DlibDotNet
|
||||
public DlibDotNet(List<string> args, IsEnvironment isEnvironment, IConfigurationRoot configurationRoot, AppSettings appSettings, string workingDirectory, bool isSilent, IConsole console)
|
||||
{
|
||||
string argZero;
|
||||
Person[] people;
|
||||
_AppSettings = appSettings;
|
||||
if (appSettings.MaxDegreeOfParallelism is null)
|
||||
throw new Exception($"{nameof(appSettings.MaxDegreeOfParallelism)} is null!");
|
||||
@ -49,8 +51,6 @@ public class DlibDotNet
|
||||
Models.Configuration configuration = Models.Stateless.Configuration.Get(isEnvironment, configurationRoot, workingDirectory, propertyConfiguration);
|
||||
Verify(configuration);
|
||||
(Model model, PredictorModel predictorModel) = GetTuple(args, propertyConfiguration, configuration);
|
||||
if (configuration.SearchForAbandonedFilesFull is null)
|
||||
throw new Exception($"{nameof(configuration.SearchForAbandonedFilesFull)} is null!");
|
||||
_Configuration = configuration;
|
||||
_Index = new G_Index(configuration);
|
||||
_Random = new F_Random(configuration);
|
||||
@ -72,6 +72,8 @@ public class DlibDotNet
|
||||
throw new Exception($"{nameof(configuration.PropertiesChangedForMetadata)} is null!");
|
||||
if (configuration.PropertiesChangedForResize is null)
|
||||
throw new Exception($"{nameof(configuration.PropertiesChangedForResize)} is null!");
|
||||
if (configuration.Reverse is null)
|
||||
throw new Exception($"{nameof(configuration.Reverse)} is null!");
|
||||
_Metadata = new(configuration.ForceMetadataLastWriteTimeToCreationTime.Value, configuration.PropertiesChangedForMetadata.Value);
|
||||
if (args.Count > 0)
|
||||
argZero = Path.GetFullPath(args[0]);
|
||||
@ -90,44 +92,21 @@ public class DlibDotNet
|
||||
_Faces = new D_Face(configuration, argZero, model, modelParameter, predictorModel);
|
||||
if (configuration.SkipSearch is null)
|
||||
throw new Exception($"{nameof(configuration.SkipSearch)} is null!");
|
||||
if (_ArgZeroIsConfigurationRootDirectory)
|
||||
_ = _People.GetPeople(propertyConfiguration);
|
||||
if (!_ArgZeroIsConfigurationRootDirectory)
|
||||
people = Array.Empty<Person>();
|
||||
else
|
||||
people = _People.GetPeople(propertyConfiguration);
|
||||
if (!isSilent && configuration.TestDistanceResults.HasValue && configuration.TestDistanceResults.Value)
|
||||
{
|
||||
E2_Navigate e2Navigate = new(console, configuration, argZero);
|
||||
e2Navigate.Navigate(propertyConfiguration, configuration.OutputResolutions[0]);
|
||||
}
|
||||
if (_ArgZeroIsConfigurationRootDirectory)
|
||||
{
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
string[] directories = Property.Models.Stateless.A_Property.GetDirectoryRenameCollection(propertyConfiguration, configuration.OutputResolutions[0], nameof(B_Metadata), nameof(C_Resize));
|
||||
foreach (string directory in directories)
|
||||
{
|
||||
if (!Directory.Exists(directory))
|
||||
continue;
|
||||
Property.Models.Stateless.A_Property.SearchForAbandonedFilesFull(argZero, directory, onlyJson: false);
|
||||
}
|
||||
if (appSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.A_Property.SearchForAbandonedFilesFull));
|
||||
e2Navigate.Navigate(propertyConfiguration, model, predictorModel, configuration.OutputResolutions[0]);
|
||||
}
|
||||
if (!configuration.SkipSearch.Value)
|
||||
Search(argZero);
|
||||
Search(propertyConfiguration, configuration.JuliePhares, configuration.Reverse.Value, model, predictorModel, argZero, people);
|
||||
if (_Exceptions.Count == 0 && _ArgZeroIsConfigurationRootDirectory)
|
||||
{
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
if (configuration.SearchForAbandonedFilesFull.Value)
|
||||
{
|
||||
string[] directories = _Rename.GetDirectoryRenameCollection(propertyConfiguration, relativePath: string.Empty, newDirectoryName: string.Empty, jsonFiles4InfoAny: false);
|
||||
foreach (string directory in directories)
|
||||
{
|
||||
if (!Directory.Exists(directory))
|
||||
continue;
|
||||
Property.Models.Stateless.A_Property.SearchForAbandonedFilesFull(argZero, directory, onlyJson: true);
|
||||
}
|
||||
if (appSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.A_Property.SearchForAbandonedFilesFull));
|
||||
}
|
||||
List<string[]> directoryCollections = _Rename.GetDirectoryRenameCollections(propertyConfiguration, relativePath: string.Empty, newDirectoryName: string.Empty, jsonFiles4InfoAny: false);
|
||||
List<string[]> directoryCollections = _Rename.GetDirectoryRenameCollections(propertyConfiguration, model, predictorModel, relativePath: string.Empty, newDirectoryName: string.Empty, jsonFiles4InfoAny: false);
|
||||
foreach (string[] directoryCollection in directoryCollections)
|
||||
{
|
||||
_Log.Information(string.Concat("Cleaning <", directoryCollection[0], ">"));
|
||||
@ -149,7 +128,7 @@ public class DlibDotNet
|
||||
{
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
foreach (string outputResolution in configuration.OutputResolutions)
|
||||
_Distance.LoadOrCreateThenSaveDirectoryDistanceResults(propertyConfiguration, outputResolution);
|
||||
_Distance.LoadOrCreateThenSaveDirectoryDistanceResults(propertyConfiguration, model, predictorModel, outputResolution);
|
||||
if (appSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(E_Distance.LoadOrCreateThenSaveDirectoryDistanceResults));
|
||||
}
|
||||
@ -300,8 +279,6 @@ public class DlibDotNet
|
||||
throw new Exception($"{nameof(configuration.SaveFullYearOfRandomFiles)} must be set!");
|
||||
if (configuration.SaveResizedSubfiles is null)
|
||||
throw new Exception($"{nameof(configuration.SaveResizedSubfiles)} must be set!");
|
||||
if (configuration.SearchForAbandonedFilesFull is null)
|
||||
throw new Exception($"{nameof(configuration.SearchForAbandonedFilesFull)} must be set!");
|
||||
if (configuration.SkipSearch is null)
|
||||
throw new Exception($"{nameof(configuration.SkipSearch)} must be set!");
|
||||
if (configuration.TestDistanceResults is null)
|
||||
@ -320,51 +297,10 @@ public class DlibDotNet
|
||||
throw new Exception($"{nameof(configuration.DistanceFactor)} and {nameof(configuration.LocationConfidenceFactor)} must add up to 10!");
|
||||
}
|
||||
|
||||
private int FullParallelWork(object @lock, long ticks, PropertyLogic propertyLogic, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, List<FileInfo?> propertyFileInfoCollection, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollection, List<Dictionary<string, int[]>> resizeKeyValuePairs, List<List<D_Face>> faceCollections, int g, string sourceDirectory, int r, string[] filteredSourceDirectoryFiles, int count)
|
||||
{
|
||||
int result = 0;
|
||||
if (_Log is null)
|
||||
throw new Exception($"{nameof(_Log)} is null!");
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new Exception($"{nameof(AppSettings.MaxDegreeOfParallelism)} is null!");
|
||||
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = _AppSettings.MaxDegreeOfParallelism.Value };
|
||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||
if (faceCollections.Count != filteredSourceDirectoryFiles.Length || metadataCollection.Count != filteredSourceDirectoryFiles.Length || resizeKeyValuePairs.Count != filteredSourceDirectoryFiles.Length || propertyCollection.Count != filteredSourceDirectoryFiles.Length)
|
||||
{
|
||||
for (int i = 0; i < filteredSourceDirectoryFiles.Length; i++)
|
||||
{
|
||||
faceCollections.Add(new());
|
||||
metadataCollection.Add(new());
|
||||
resizeKeyValuePairs.Add(new());
|
||||
propertyCollection.Add(new());
|
||||
propertyFileInfoCollection.Add(null);
|
||||
}
|
||||
}
|
||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
using (ProgressBar progressBar = new(filteredSourceDirectoryFiles.Length, $"{g}) {r + 1:000} / {count:000} - {outputResolution} - {sourceDirectory} - {filteredSourceDirectoryFiles.Length} file(s) - {totalSeconds} total second(s)", options))
|
||||
{
|
||||
_ = Parallel.For(0, filteredSourceDirectoryFiles.Length, parallelOptions, i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
FullParallelForWork(propertyLogic, @lock, outputResolution, sourceDirectoryChanges, propertyFileInfoCollection, propertyCollection, metadataCollection, resizeKeyValuePairs, faceCollections, sourceDirectory, index: i, filteredSourceDirectoryFiles[i]);
|
||||
if (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 == filteredSourceDirectoryFiles.Length)
|
||||
throw new Exception(string.Concat("All in [", sourceDirectory, "]failed!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void FullParallelForWork(PropertyLogic propertyLogic, object @lock, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, List<FileInfo?> propertyFileInfoCollection, List<A_Property> propertyCollection, List<List<KeyValuePair<string, string>>> metadataCollections, List<Dictionary<string, int[]>> resizeKeyValuePairs, List<List<D_Face>> imageFaceCollections, string sourceDirectory, int index, string filteredSourceDirectoryFile)
|
||||
private void FullParallelForWork(PropertyLogic propertyLogic, object @lock, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, List<FileInfo?> propertyFileInfoCollection, 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)
|
||||
{
|
||||
if (propertyHolder.FileInfo is null)
|
||||
throw new Exception($"{nameof(propertyHolder.FileInfo)} is null!");
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new Exception($"{nameof(_AppSettings.MaxDegreeOfParallelism)} is null!");
|
||||
if (_Configuration.SaveResizedSubfiles is null)
|
||||
@ -373,6 +309,7 @@ public class DlibDotNet
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration)} must be set!");
|
||||
if (_Configuration.PropertyConfiguration.WriteBitmapDataBytes is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.WriteBitmapDataBytes)} is null!");
|
||||
A_Property property;
|
||||
List<D_Face> faceCollection;
|
||||
string original = "Original";
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
@ -381,29 +318,36 @@ public class DlibDotNet
|
||||
Dictionary<string, int[]> imageResizeKeyValuePairs;
|
||||
List<Tuple<string, DateTime>> subFileTuples = new();
|
||||
List<KeyValuePair<string, string>> metadataCollection;
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(filteredSourceDirectoryFile);
|
||||
string relativePath = Property.Models.Stateless.IPath.GetRelativePath(filteredSourceDirectoryFile, _Configuration.PropertyConfiguration.RootDirectory.Length);
|
||||
FileInfo propertyFileInfo = new(Path.Combine(propertyLogic.AngleBracketCollection[0].Replace("<>", "{}"), string.Concat(fileNameWithoutExtension, ".json")));
|
||||
A_Property property = propertyLogic.GetProperty(propertyLogic.AngleBracketCollection[0], sourceDirectory, filteredSourceDirectoryFile, subFileTuples, parseExceptions, propertyFileInfo);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(PropertyLogic.GetProperty));
|
||||
(int metadataGroups, metadataCollection) = _Metadata.GetMetadataCollection(subFileTuples, parseExceptions, filteredSourceDirectoryFile, relativePath, fileNameWithoutExtension);
|
||||
if (propertyHolder.Property is null)
|
||||
{
|
||||
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), propertyHolder.FileInfo.LastWriteTime));
|
||||
property = propertyLogic.GetProperty(propertyLogic.AngleBracketCollection[0], sourceDirectory, propertyHolder.FileInfo.FullName, subFileTuples, parseExceptions, propertyHolder.FileInfo);
|
||||
}
|
||||
else
|
||||
{
|
||||
property = propertyHolder.Property;
|
||||
if (propertyHolder.Changed.HasValue && propertyHolder.Changed.Value)
|
||||
sourceDirectoryChanges.Add(new Tuple<string, DateTime>(nameof(A_Property), propertyHolder.FileInfo.LastWriteTime));
|
||||
}
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(propertyHolder.FileInfo.FullName);
|
||||
(int metadataGroups, metadataCollection) = _Metadata.GetMetadataCollection(subFileTuples, parseExceptions, propertyHolder.FileInfo.FullName, propertyHolder.RelativePath, fileNameWithoutExtension);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(B_Metadata.GetMetadataCollection));
|
||||
FileInfo resizedFileInfo = new(Path.Combine(_Resize.AngleBracketCollection[0].Replace("<>", "()"), Path.GetFileName(filteredSourceDirectoryFile)));
|
||||
imageResizeKeyValuePairs = _Resize.GetResizeKeyValuePairs(subFileTuples, parseExceptions, original, metadataCollection, property, filteredSourceDirectoryFile, relativePath, fileNameWithoutExtension);
|
||||
FileInfo resizedFileInfo = new(Path.Combine(_Resize.AngleBracketCollection[0].Replace("<>", "()"), Path.GetFileName(propertyHolder.FileInfo.FullName)));
|
||||
propertyHolder.SetResizedFileInfo(resizedFileInfo);
|
||||
imageResizeKeyValuePairs = _Resize.GetResizeKeyValuePairs(subFileTuples, parseExceptions, original, metadataCollection, property, propertyHolder.FileInfo.FullName, propertyHolder.RelativePath, fileNameWithoutExtension);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(C_Resize.GetResizeKeyValuePairs));
|
||||
if (_Configuration.SaveResizedSubfiles.Value)
|
||||
{
|
||||
_Resize.SaveResizedSubfile(outputResolution, subFileTuples, filteredSourceDirectoryFile, original, property, imageResizeKeyValuePairs, resizedFileInfo);
|
||||
_Resize.SaveResizedSubfile(outputResolution, subFileTuples, propertyHolder.FileInfo.FullName, original, property, imageResizeKeyValuePairs, resizedFileInfo);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(C_Resize.SaveResizedSubfile));
|
||||
resizedFileInfo.Refresh();
|
||||
}
|
||||
else if (outputResolution == _Configuration.OutputResolutions[0] && false)
|
||||
{
|
||||
byte[] bytes = _Resize.GetResizedBytes(outputResolution, subFileTuples, filteredSourceDirectoryFile, property, imageResizeKeyValuePairs);
|
||||
byte[] bytes = _Resize.GetResizedBytes(outputResolution, subFileTuples, propertyHolder.FileInfo.FullName, property, imageResizeKeyValuePairs);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(C_Resize.GetResizedBytes));
|
||||
string path = Path.Combine(resizedFileInfo.DirectoryName, Path.GetFileNameWithoutExtension(resizedFileInfo.Name));
|
||||
@ -417,15 +361,15 @@ public class DlibDotNet
|
||||
int outputResolutionWidth = outputResolutionCollection[0];
|
||||
int outputResolutionHeight = outputResolutionCollection[1];
|
||||
int outputResolutionOrientation = outputResolutionCollection[2];
|
||||
faceCollection = _Faces.GetFaces(_Configuration.PropertyConfiguration, outputResolution, subFileTuples, parseExceptions, relativePath, fileNameWithoutExtension, property, resizedFileInfo, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation);
|
||||
faceCollection = _Faces.GetFaces(_Configuration.PropertyConfiguration, outputResolution, subFileTuples, parseExceptions, propertyHolder.RelativePath, fileNameWithoutExtension, property, resizedFileInfo, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(D_Face.GetFaces));
|
||||
_Faces.SaveFaces(_Configuration.PropertyConfiguration, subFileTuples, parseExceptions, relativePath, fileNameWithoutExtension, resizedFileInfo, faceCollection);
|
||||
_Faces.SaveFaces(_Configuration.PropertyConfiguration, subFileTuples, parseExceptions, propertyHolder.RelativePath, fileNameWithoutExtension, resizedFileInfo, faceCollection);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(D_Face.SaveFaces));
|
||||
if (_Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution))
|
||||
{
|
||||
_FaceLandmarks.SaveFaceLandmarkImages(subFileTuples, parseExceptions, relativePath, fileNameWithoutExtension, resizedFileInfo, faceCollection);
|
||||
_FaceLandmarks.SaveFaceLandmarkImages(subFileTuples, parseExceptions, propertyHolder.RelativePath, fileNameWithoutExtension, resizedFileInfo, faceCollection);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(D2_FaceLandmarks.SaveFaceLandmarkImages));
|
||||
}
|
||||
@ -435,12 +379,55 @@ public class DlibDotNet
|
||||
propertyCollection[index] = property;
|
||||
imageFaceCollections[index] = faceCollection;
|
||||
metadataCollections[index] = metadataCollection;
|
||||
propertyFileInfoCollection[index] = propertyFileInfo;
|
||||
resizeKeyValuePairs[index] = imageResizeKeyValuePairs;
|
||||
propertyFileInfoCollection[index] = propertyHolder.FileInfo;
|
||||
sourceDirectoryChanges.AddRange(from l in subFileTuples where l.Item2 > dateTime select l);
|
||||
}
|
||||
}
|
||||
|
||||
private int FullParallelWork(object @lock, long ticks, PropertyLogic propertyLogic, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, List<FileInfo?> propertyFileInfoCollection, 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)
|
||||
{
|
||||
int result = 0;
|
||||
if (_Log is null)
|
||||
throw new Exception($"{nameof(_Log)} is null!");
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new Exception($"{nameof(AppSettings.MaxDegreeOfParallelism)} is null!");
|
||||
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)
|
||||
{
|
||||
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
|
||||
{
|
||||
faceCollections.Add(new());
|
||||
metadataCollection.Add(new());
|
||||
resizeKeyValuePairs.Add(new());
|
||||
propertyCollection.Add(new());
|
||||
propertyFileInfoCollection.Add(null);
|
||||
}
|
||||
}
|
||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||
using (ProgressBar progressBar = new(filteredPropertyHolderCollection.Length, $"{r + 1:000}.{g} / {propertyHolderCollectionsCount:000}) {filteredPropertyHolderCollection.Length:000} file(s) - {totalSeconds} total second(s) - {outputResolution} - {sourceDirectory}", options))
|
||||
{
|
||||
_ = Parallel.For(0, filteredPropertyHolderCollection.Length, parallelOptions, i =>
|
||||
{
|
||||
try
|
||||
{
|
||||
FullParallelForWork(propertyLogic, @lock, outputResolution, sourceDirectoryChanges, propertyFileInfoCollection, propertyCollection, metadataCollection, resizeKeyValuePairs, faceCollections, sourceDirectory, index: i, filteredPropertyHolderCollection[i]);
|
||||
if (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!"));
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void WriteTab(string checkDirectory, List<(string Id, string Line)> metadataIdLines, string fileName)
|
||||
{
|
||||
string text;
|
||||
@ -476,14 +463,12 @@ public class DlibDotNet
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteGroup(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[] filteredSourceDirectoryFiles)
|
||||
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, PropertyHolder[] filteredPropertyHolderCollection)
|
||||
{
|
||||
if (_Configuration.PropertiesChangedForMetadata is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertiesChangedForMetadata)} is null!");
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration)} must be set!");
|
||||
if (_Configuration.PropertyConfiguration.PropertiesChangedForProperty is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.PropertiesChangedForProperty)} is null!");
|
||||
if (configuration.PropertiesChangedForProperty is null)
|
||||
throw new Exception($"{nameof(configuration.PropertiesChangedForProperty)} is null!");
|
||||
if (_Configuration.PropertiesChangedForResize is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertiesChangedForResize)} is null!");
|
||||
if (_Configuration.PropertiesChangedForFaces is null)
|
||||
@ -491,8 +476,10 @@ public class DlibDotNet
|
||||
string key;
|
||||
string json;
|
||||
string checkFile;
|
||||
PropertyHolder propertyHolder;
|
||||
int sourceDirectoryLength = sourceDirectory.Length;
|
||||
int rootDirectoryLength = _Configuration.PropertyConfiguration.RootDirectory.Length;
|
||||
int rootDirectoryLength = configuration.RootDirectory.Length;
|
||||
_FilePropertiesKeyValuePairs.Add(sourceDirectory, new List<Tuple<string, A_Property>>());
|
||||
JsonSerializerOptions writeIndentedJsonSerializerOptions = new() { WriteIndented = false };
|
||||
if (!(from l in propertyCollection where l?.Width is null select true).Any())
|
||||
{
|
||||
@ -501,11 +488,18 @@ public class DlibDotNet
|
||||
List<KeyValuePair<string, A_Property>> propertyCollectionKeyValuePairs = new();
|
||||
List<KeyValuePair<string, Dictionary<string, int[]>>> resizeKeyValuePairsCollections = new();
|
||||
List<KeyValuePair<string, List<KeyValuePair<string, string>>>> metadataCollectionKeyValuePairs = new();
|
||||
(int level, List<string> directories) = Property.Models.Stateless.IPath.Get(_Configuration.PropertyConfiguration.RootDirectory, sourceDirectory);
|
||||
string fileName = string.Concat(string.Join(_Configuration.PropertyConfiguration.FileNameDirectorySeparator, directories), ".json");
|
||||
for (int i = 0; i < filteredSourceDirectoryFiles.Length; i++)
|
||||
(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++)
|
||||
{
|
||||
key = Property.Models.Stateless.IPath.GetRelativePath(filteredSourceDirectoryFiles[i], sourceDirectoryLength);
|
||||
propertyHolder = filteredPropertyHolderCollection[i];
|
||||
if (propertyHolder.Property is null)
|
||||
continue;
|
||||
if (propertyHolder.FileInfo is null)
|
||||
continue;
|
||||
key = Property.Models.Stateless.IPath.GetRelativePath(propertyHolder.FileInfo.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]));
|
||||
propertyCollectionKeyValuePairs.Add(new KeyValuePair<string, A_Property>(key, propertyCollection[i]));
|
||||
resizeKeyValuePairsCollections.Add(new KeyValuePair<string, Dictionary<string, int[]>>(key, resizeKeyValuePairs[i]));
|
||||
@ -554,131 +548,135 @@ public class DlibDotNet
|
||||
}
|
||||
}
|
||||
|
||||
private void FullDoWork(List<string> topDirectories, List<(int g, string sourceDirectory, string[] sourceDirectoryFiles, int r)> groupCollection)
|
||||
private void FullDoWork(Property.Models.Configuration configuration, string[] juliePhares, Model model, PredictorModel predictorModel, string argZero, Person[] people, PropertyLogic propertyLogic, List<PropertyHolder[]> propertyHolderCollections)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new Exception($"{nameof(_Log)} is null!");
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new Exception($"{nameof(_AppSettings.MaxDegreeOfParallelism)} is null!");
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration)} must be set!");
|
||||
if (_Configuration.PropertyConfiguration.ForcePropertyLastWriteTimeToCreationTime is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.ForcePropertyLastWriteTimeToCreationTime)} is null!");
|
||||
if (_Configuration.LoadOrCreateThenSaveImageFacesResults is null)
|
||||
throw new Exception($"{nameof(_Configuration.LoadOrCreateThenSaveImageFacesResults)} is null!");
|
||||
if (_Configuration.LoadOrCreateThenSaveDirectoryDistanceResults is null)
|
||||
throw new Exception($"{nameof(_Configuration.LoadOrCreateThenSaveDirectoryDistanceResults)} is null!");
|
||||
if (_Configuration.LoadOrCreateThenSaveDistanceResults is null)
|
||||
throw new Exception($"{nameof(_Configuration.LoadOrCreateThenSaveDistanceResults)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.MaxImagesInDirectoryForTopLevelFirstPass is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.MaxImagesInDirectoryForTopLevelFirstPass)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.PopulatePropertyId is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.PopulatePropertyId)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.PropertiesChangedForProperty is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.PropertiesChangedForProperty)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.WriteBitmapDataBytes is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.WriteBitmapDataBytes)} is null!");
|
||||
int g;
|
||||
int r;
|
||||
int exceptionCount;
|
||||
object @lock = new();
|
||||
string sourceDirectory;
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
string[] filteredSourceDirectoryFiles;
|
||||
string modelName = model.ToString();
|
||||
List<List<D_Face>> faceCollections = new();
|
||||
List<A_Property> propertyCollection = new();
|
||||
PropertyLogic propertyLogic = GetPropertyLogic();
|
||||
PropertyHolder[] filteredPropertyHolderCollection;
|
||||
List<FileInfo?> propertyFileInfoCollection = new();
|
||||
string predictorModelName = predictorModel.ToString();
|
||||
List<Dictionary<string, int[]>> resizeKeyValuePairs = new();
|
||||
List<Tuple<string, DateTime>> sourceDirectoryChanges = new();
|
||||
string propertyRoot = Property.Models.Stateless.IResult.GetResultsGroupDirectory(_Configuration.PropertyConfiguration, nameof(A_Property));
|
||||
List<List<KeyValuePair<string, string>>> metadataCollection = new();
|
||||
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();
|
||||
foreach ((int g, string sourceDirectory, string[] sourceDirectoryFiles, int r) in groupCollection)
|
||||
foreach (PropertyHolder[] propertyHolderCollection in propertyHolderCollections)
|
||||
{
|
||||
if (!topDirectories.Any())
|
||||
if (!propertyHolderCollection.Any())
|
||||
continue;
|
||||
if (!_ArgZeroIsConfigurationRootDirectory && !propertyHolderCollection[0].SourceDirectory.StartsWith(argZero))
|
||||
continue;
|
||||
filteredPropertyHolderCollection = (from l in propertyHolderCollection where l.FileInfo is not null && l.Property is not null && l.ValidImageFormatExtension.HasValue && l.ValidImageFormatExtension.Value && !_Configuration.IgnoreExtensions.Contains(l.FileInfo.Extension) select l).ToArray();
|
||||
if (!filteredPropertyHolderCollection.Any())
|
||||
continue;
|
||||
faceCollections.Clear();
|
||||
metadataCollection.Clear();
|
||||
propertyCollection.Clear();
|
||||
resizeKeyValuePairs.Clear();
|
||||
sourceDirectoryChanges.Clear();
|
||||
propertyFileInfoCollection.Clear();
|
||||
_Faces.AngleBracketCollection.Clear();
|
||||
_Resize.AngleBracketCollection.Clear();
|
||||
_Metadata.AngleBracketCollection.Clear();
|
||||
g = filteredPropertyHolderCollection[0].G;
|
||||
r = filteredPropertyHolderCollection[0].R;
|
||||
propertyLogic.AngleBracketCollection.Clear();
|
||||
_FaceLandmarks.AngleBracketCollection.Clear();
|
||||
filteredSourceDirectoryFiles = (from l in sourceDirectoryFiles where !_Configuration.IgnoreExtensions.Contains(Path.GetExtension(l)) select l).ToArray();
|
||||
if (!filteredSourceDirectoryFiles.Any())
|
||||
continue;
|
||||
propertyLogic.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(_Configuration.PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
nameof(A_Property),
|
||||
outputResolution,
|
||||
includeResizeGroup: false,
|
||||
includeModel: false,
|
||||
includePredictorModel: false,
|
||||
contentDescription: string.Empty,
|
||||
singletonDescription: "Properties for each image",
|
||||
collectionDescription: string.Empty));
|
||||
_Metadata.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(_Configuration.PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
nameof(B_Metadata),
|
||||
outputResolution,
|
||||
includeResizeGroup: false,
|
||||
includeModel: false,
|
||||
includePredictorModel: false,
|
||||
contentDescription: string.Empty,
|
||||
singletonDescription: "Metadata as key value pairs",
|
||||
collectionDescription: string.Empty));
|
||||
_Resize.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(_Configuration.PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
nameof(C_Resize),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: false,
|
||||
includePredictorModel: false,
|
||||
contentDescription: "Resized image",
|
||||
singletonDescription: "Resize deminsions for each resolution",
|
||||
collectionDescription: string.Empty));
|
||||
if (_Configuration.LoadOrCreateThenSaveImageFacesResults.HasValue && _Configuration.LoadOrCreateThenSaveImageFacesResults.Value)
|
||||
_Faces.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(_Configuration.PropertyConfiguration,
|
||||
sourceDirectory,
|
||||
nameof(D_Face),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: true,
|
||||
includePredictorModel: true,
|
||||
contentDescription: "n png file(s) for each face found",
|
||||
singletonDescription: string.Empty,
|
||||
collectionDescription: "For each image a json file with all faces found"));
|
||||
if (_Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution))
|
||||
_FaceLandmarks.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(_Configuration.PropertyConfiguration,
|
||||
sourceDirectory = filteredPropertyHolderCollection[0].SourceDirectory;
|
||||
propertyLogic.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
modelName,
|
||||
predictorModelName,
|
||||
sourceDirectory,
|
||||
nameof(D2_FaceLandmarks),
|
||||
nameof(A_Property),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: true,
|
||||
includePredictorModel: true,
|
||||
contentDescription: "n x 2 png file(s) for each face found",
|
||||
singletonDescription: string.Empty,
|
||||
includeResizeGroup: false,
|
||||
includeModel: false,
|
||||
includePredictorModel: false,
|
||||
contentDescription: string.Empty,
|
||||
singletonDescription: "Properties for each image",
|
||||
collectionDescription: string.Empty));
|
||||
exceptionCount = FullParallelWork(@lock, ticks, propertyLogic, outputResolution, sourceDirectoryChanges, propertyFileInfoCollection, propertyCollection, metadataCollection, resizeKeyValuePairs, faceCollections, g, sourceDirectory, r, filteredSourceDirectoryFiles, groupCollection.Count);
|
||||
if (metadataCollection.Count != filteredSourceDirectoryFiles.Length || propertyCollection.Count != filteredSourceDirectoryFiles.Length || resizeKeyValuePairs.Count != filteredSourceDirectoryFiles.Length || faceCollections.Count != filteredSourceDirectoryFiles.Length)
|
||||
_Metadata.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
modelName,
|
||||
predictorModelName,
|
||||
sourceDirectory,
|
||||
nameof(B_Metadata),
|
||||
outputResolution,
|
||||
includeResizeGroup: false,
|
||||
includeModel: false,
|
||||
includePredictorModel: false,
|
||||
contentDescription: string.Empty,
|
||||
singletonDescription: "Metadata as key value pairs",
|
||||
collectionDescription: string.Empty));
|
||||
_Resize.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
modelName,
|
||||
predictorModelName,
|
||||
sourceDirectory,
|
||||
nameof(C_Resize),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: false,
|
||||
includePredictorModel: false,
|
||||
contentDescription: "Resized image",
|
||||
singletonDescription: "Resize dimensions for each resolution",
|
||||
collectionDescription: string.Empty));
|
||||
if (_Configuration.LoadOrCreateThenSaveImageFacesResults.HasValue && _Configuration.LoadOrCreateThenSaveImageFacesResults.Value)
|
||||
_Faces.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
modelName,
|
||||
predictorModelName,
|
||||
sourceDirectory,
|
||||
nameof(D_Face),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: true,
|
||||
includePredictorModel: true,
|
||||
contentDescription: "n png file(s) for each face found",
|
||||
singletonDescription: string.Empty,
|
||||
collectionDescription: "For each image a json file with all faces found"));
|
||||
if (_Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution))
|
||||
_FaceLandmarks.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
modelName,
|
||||
predictorModelName,
|
||||
sourceDirectory,
|
||||
nameof(D2_FaceLandmarks),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: true,
|
||||
includePredictorModel: true,
|
||||
contentDescription: "n x 2 png file(s) for each face found",
|
||||
singletonDescription: string.Empty,
|
||||
collectionDescription: string.Empty));
|
||||
exceptionCount = FullParallelWork(@lock, ticks, propertyLogic, outputResolution, sourceDirectoryChanges, propertyFileInfoCollection, 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)
|
||||
throw new Exception("Counts don't match!");
|
||||
if (exceptionCount != 0)
|
||||
_Exceptions.Add(sourceDirectory);
|
||||
else
|
||||
{
|
||||
string key;
|
||||
int rootDirectoryLength = _Configuration.PropertyConfiguration.RootDirectory.Length;
|
||||
_FilePropertiesKeyValuePairs.Add(sourceDirectory, new List<Tuple<string, A_Property>>());
|
||||
for (int i = 0; i < filteredSourceDirectoryFiles.Length; i++)
|
||||
{
|
||||
key = Property.Models.Stateless.IPath.GetRelativePath(filteredSourceDirectoryFiles[i], rootDirectoryLength);
|
||||
_FileKeyValuePairs.Add(new KeyValuePair<string, string>(sourceDirectory, key));
|
||||
_FilePropertiesKeyValuePairs[sourceDirectory].Add(new Tuple<string, A_Property>(key, propertyCollection[i]));
|
||||
}
|
||||
}
|
||||
if (exceptionCount == 0 && _ArgZeroIsConfigurationRootDirectory)
|
||||
WriteGroup(propertyLogic, propertyCollection, metadataCollection, faceCollections, resizeKeyValuePairs, sourceDirectory, filteredSourceDirectoryFiles);
|
||||
WriteGroup(configuration, propertyLogic, propertyCollection, metadataCollection, faceCollections, resizeKeyValuePairs, sourceDirectory, filteredPropertyHolderCollection);
|
||||
if (exceptionCount == 0 && _Configuration.LoadOrCreateThenSaveImageFacesResults.Value && _Configuration.SaveShortcuts.HasValue && _Configuration.SaveShortcuts.Value)
|
||||
_Faces.SaveShortcuts(configuration, juliePhares, model, predictorModel, people, propertyLogic, outputResolution, filteredPropertyHolderCollection, propertyCollection, faceCollections);
|
||||
if (exceptionCount == 0 && _Configuration.LoadOrCreateThenSaveDistanceResults.HasValue && _Configuration.LoadOrCreateThenSaveDistanceResults.Value)
|
||||
_Distance.LoadOrCreateThenSaveDistanceResults(_Configuration.PropertyConfiguration, sourceDirectory, outputResolution, sourceDirectoryChanges, filteredSourceDirectoryFiles, faceCollections);
|
||||
_Distance.LoadOrCreateThenSaveDistanceResults(configuration, model, predictorModel, sourceDirectory, outputResolution, sourceDirectoryChanges, filteredPropertyHolderCollection, faceCollections);
|
||||
if (_Resize.AngleBracketCollection.Any())
|
||||
_ = Property.Models.Stateless.IPath.DeleteEmptyDirectories(_Resize.AngleBracketCollection[0].Replace("<>", "()"));
|
||||
if (_Faces.AngleBracketCollection.Any())
|
||||
@ -690,7 +688,7 @@ public class DlibDotNet
|
||||
for (int y = 0; y < int.MaxValue; y++)
|
||||
{
|
||||
_Log.Information("Press \"Y\" key when ready to continue or close console");
|
||||
if (Console.ReadKey().Key == ConsoleKey.Y)
|
||||
if (System.Console.ReadKey().Key == ConsoleKey.Y)
|
||||
break;
|
||||
}
|
||||
_Log.Information(". . .");
|
||||
@ -698,31 +696,20 @@ public class DlibDotNet
|
||||
}
|
||||
if (_ArgZeroIsConfigurationRootDirectory && outputResolution == _Configuration.OutputResolutions[0])
|
||||
{
|
||||
int loadLessThan = 7;
|
||||
string aPropertySingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(A_Property), "{}");
|
||||
PropertyCompare.Models.PropertyCompareLogic propertyCompareLogic = new(_AppSettings.MaxDegreeOfParallelism.Value, _Configuration.PropertyConfiguration);
|
||||
PropertyCompare.Models.PropertyCompare[] propertyCompares = propertyCompareLogic.Get(aPropertySingletonDirectory, loadLessThan);
|
||||
{
|
||||
string[] lines = (from l in propertyCompares select l.GetSelect()).ToArray();
|
||||
string aPropertyCollectionDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(_Configuration.PropertyConfiguration, nameof(A_Property), "[{}]");
|
||||
File.WriteAllLines(Path.Join(aPropertyCollectionDirectory, $". . . Ids - {ticks}.txt"), lines);
|
||||
string json = JsonSerializer.Serialize(propertyCompares, new JsonSerializerOptions { WriteIndented = true });
|
||||
File.WriteAllText(Path.Join(aPropertyCollectionDirectory, $". . . Ids - {ticks}.nosj"), json);
|
||||
}
|
||||
if (!_Configuration.LoadOrCreateThenSaveImageFacesResults.Value && !_Configuration.LoadOrCreateThenSaveDirectoryDistanceResults.Value && !_Configuration.LoadOrCreateThenSaveDistanceResults.Value)
|
||||
break;
|
||||
if (_Exceptions.Count == 0)
|
||||
{
|
||||
if (_FileKeyValuePairs.Any())
|
||||
_Random.Random(_Configuration.PropertyConfiguration, _Configuration.OutputResolutions[0], _FileKeyValuePairs);
|
||||
_Random.Random(configuration, _Configuration.OutputResolutions[0], _FileKeyValuePairs);
|
||||
if (_IsEnvironment.Development)
|
||||
continue;
|
||||
G2_Identify identify = new(_Configuration);
|
||||
List<G2_Identify> identifiedCollection = identify.GetIdentifiedCollection(_Configuration.PropertyConfiguration, _IsEnvironment, _People);
|
||||
_People.WriteAllText(_Configuration.PropertyConfiguration, _Configuration.OutputResolutions[0], identifiedCollection);
|
||||
identify.WriteAllText(_Configuration.PropertyConfiguration, _Configuration.OutputResolutions[0], identifiedCollection);
|
||||
List<G2_Identify> identifiedCollection = identify.GetIdentifiedCollection(configuration, _IsEnvironment, _People);
|
||||
_People.WriteAllText(configuration, _Configuration.OutputResolutions[0], identifiedCollection);
|
||||
identify.WriteAllText(configuration, _Configuration.OutputResolutions[0], identifiedCollection);
|
||||
if (_Configuration.LoadOrCreateThenSaveIndex.HasValue && _Configuration.LoadOrCreateThenSaveIndex.Value && _FilePropertiesKeyValuePairs.Any())
|
||||
_Index.SetIndex(_Configuration.PropertyConfiguration, _Configuration.OutputResolutions[0], _FilePropertiesKeyValuePairs);
|
||||
_Index.SetIndex(configuration, model, predictorModel, _Configuration.OutputResolutions[0], _FilePropertiesKeyValuePairs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -731,66 +718,21 @@ public class DlibDotNet
|
||||
private PropertyLogic GetPropertyLogic()
|
||||
{
|
||||
PropertyLogic result;
|
||||
|
||||
|
||||
string[] verifyToSeason = Array.Empty<string>();
|
||||
|
||||
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new Exception($"{nameof(_AppSettings.MaxDegreeOfParallelism)} is null!");
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration)} must be set!");
|
||||
result = new(_AppSettings.MaxDegreeOfParallelism.Value, _Configuration.PropertyConfiguration, verifyToSeason);
|
||||
result = new(_AppSettings.MaxDegreeOfParallelism.Value, _Configuration.PropertyConfiguration);
|
||||
return result;
|
||||
}
|
||||
|
||||
private void Search(string argZero)
|
||||
private void Search(Property.Models.Configuration configuration, string[] juliePhares, bool reverse, Model model, PredictorModel predictorModel, string argZero, Person[] people)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new Exception($"{nameof(_Log)} is null!");
|
||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||
throw new Exception($"{nameof(_AppSettings.MaxDegreeOfParallelism)} is null!");
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration)} must be set!");
|
||||
if (_Configuration.PropertyConfiguration.ForcePropertyLastWriteTimeToCreationTime is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.ForcePropertyLastWriteTimeToCreationTime)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.IgnoreExtensions is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.IgnoreExtensions)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.MaxImagesInDirectoryForTopLevelFirstPass is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.MaxImagesInDirectoryForTopLevelFirstPass)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.PopulatePropertyId is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.PopulatePropertyId)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.PropertiesChangedForProperty is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.PropertiesChangedForProperty)} is null!");
|
||||
if (_Configuration.Reverse is null)
|
||||
throw new Exception($"{nameof(_Configuration.Reverse)} is null!");
|
||||
if (_Configuration.PropertyConfiguration.WriteBitmapDataBytes is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration.WriteBitmapDataBytes)} is null!");
|
||||
string searchPattern = "*";
|
||||
long ticks = DateTime.Now.Ticks;
|
||||
List<string> topDirectories = new();
|
||||
PropertyLogic propertyLogic = GetPropertyLogic();
|
||||
List<(int g, string sourceDirectory, string[] sourceDirectoryFiles, int r)> groupCollection = Property.Models.Stateless.A_Property.GetGroupCollection(argZero, searchPattern, topDirectories, _Configuration.PropertyConfiguration.MaxImagesInDirectoryForTopLevelFirstPass.Value, _Configuration.Reverse.Value);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.A_Property.GetGroupCollection));
|
||||
_Exceptions.AddRange(propertyLogic.DoWork(_Configuration.PropertyConfiguration, topDirectories, groupCollection, firstPass: true));
|
||||
string message = $"There were {_Exceptions.Count} exception(s) thrown! {Environment.NewLine}{string.Join(Environment.NewLine, _Exceptions)}";
|
||||
_Log.Information(message);
|
||||
if (_Exceptions.Count != 0)
|
||||
throw new Exception(message);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.A_Property.GetGroupCollection));
|
||||
groupCollection = Property.Models.Stateless.A_Property.GetGroupCollection(argZero, searchPattern, topDirectories, _Configuration.PropertyConfiguration.MaxImagesInDirectoryForTopLevelFirstPass.Value, _Configuration.Reverse.Value);
|
||||
if (_AppSettings.MaxDegreeOfParallelism.Value < 2)
|
||||
ticks = LogDelta(ticks, nameof(Property.Models.Stateless.A_Property.GetGroupCollection));
|
||||
FullDoWork(topDirectories, groupCollection);
|
||||
List<PropertyHolder[]> propertyHolderCollections = Property.Models.Stateless.A_Property.Get(configuration, reverse, model.ToString(), predictorModel.ToString(), propertyLogic);
|
||||
FullDoWork(configuration, juliePhares, model, predictorModel, argZero, people, propertyLogic, propertyHolderCollections);
|
||||
}
|
||||
|
||||
internal void RenameQueue()
|
||||
{
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration)} must be set!");
|
||||
_Rename.RenameQueue(_Configuration.PropertyConfiguration);
|
||||
}
|
||||
internal void RenameQueue(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel) => _Rename.RenameQueue(configuration, model, predictorModel);
|
||||
|
||||
}
|
@ -50,6 +50,7 @@
|
||||
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
|
||||
<PackageReference Include="Serilog" Version="2.10.0" />
|
||||
<PackageReference Include="ShellProgressBar" Version="5.1.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DlibDotNet" Version="19.21.0.20210302" />
|
||||
|
@ -13,7 +13,8 @@ public class Configuration
|
||||
[Display(Name = "Force Resize Last Write Time to Creation Time"), Required] public bool? ForceResizeLastWriteTimeToCreationTime { get; set; }
|
||||
[Display(Name = "Ignore Extensions"), Required] public string[] IgnoreExtensions { get; set; }
|
||||
[Display(Name = "Ignore Relative Paths"), Required] public string[] IgnoreRelativePaths { get; set; }
|
||||
[Display(Name = "Load Or Create Then Save Directroy Distance Results"), Required] public bool? LoadOrCreateThenSaveDirectoryDistanceResults { get; set; }
|
||||
[Display(Name = "Julie Phares Copy Birthdays"), Required] public string[] JuliePhares { get; set; }
|
||||
[Display(Name = "Load Or Create Then Save Directory Distance Results"), Required] public bool? LoadOrCreateThenSaveDirectoryDistanceResults { get; set; }
|
||||
[Display(Name = "Load Or Create Then Save Distance Results"), Required] public bool? LoadOrCreateThenSaveDistanceResults { get; set; }
|
||||
[Display(Name = "Load Or Create Then Save Image Faces Results"), Required] public bool? LoadOrCreateThenSaveImageFacesResults { get; set; }
|
||||
[Display(Name = "Load Or Create Then Save Index"), Required] public bool? LoadOrCreateThenSaveIndex { get; set; }
|
||||
@ -42,7 +43,7 @@ public class Configuration
|
||||
[Display(Name = "Save Face Landmark For Output Resolutions"), Required] public string[] SaveFaceLandmarkForOutputResolutions { get; set; }
|
||||
[Display(Name = "Save Full Year Of Random Files"), Required] public bool? SaveFullYearOfRandomFiles { get; set; }
|
||||
[Display(Name = "Save Resized Subfiles"), Required] public bool? SaveResizedSubfiles { get; set; }
|
||||
[Display(Name = "Search for Abandoned Files"), Required] public bool? SearchForAbandonedFilesFull { get; set; }
|
||||
[Display(Name = "Save Shortcuts"), Required] public bool? SaveShortcuts { get; set; }
|
||||
[Display(Name = "Skip Search"), Required] public bool? SkipSearch { get; set; }
|
||||
[Display(Name = "Test Distance Results"), Required] public bool? TestDistanceResults { get; set; }
|
||||
[Display(Name = "Valid Resolutions"), Required] public string[] ValidResolutions { get; set; }
|
||||
@ -56,6 +57,7 @@ public class Configuration
|
||||
ForceResizeLastWriteTimeToCreationTime = null;
|
||||
IgnoreExtensions = Array.Empty<string>();
|
||||
IgnoreRelativePaths = Array.Empty<string>();
|
||||
JuliePhares = Array.Empty<string>();
|
||||
LoadOrCreateThenSaveDirectoryDistanceResults = null;
|
||||
LoadOrCreateThenSaveDistanceResults = null;
|
||||
LoadOrCreateThenSaveImageFacesResults = null;
|
||||
@ -84,7 +86,7 @@ public class Configuration
|
||||
SaveFaceLandmarkForOutputResolutions = Array.Empty<string>();
|
||||
SaveFullYearOfRandomFiles = null;
|
||||
SaveResizedSubfiles = null;
|
||||
SearchForAbandonedFilesFull = null;
|
||||
SaveShortcuts = null;
|
||||
SkipSearch = null;
|
||||
TestDistanceResults = null;
|
||||
ValidResolutions = Array.Empty<string>();
|
||||
|
@ -13,6 +13,7 @@ public class Configuration
|
||||
protected readonly bool? _ForceResizeLastWriteTimeToCreationTime;
|
||||
protected readonly string[] _IgnoreExtensions;
|
||||
protected readonly string[] _IgnoreRelativePaths;
|
||||
protected readonly string[] _JuliePhares;
|
||||
protected readonly bool? _LoadOrCreateThenSaveDirectoryDistanceResults;
|
||||
protected readonly bool? _LoadOrCreateThenSaveDistanceResults;
|
||||
protected readonly bool? _LoadOrCreateThenSaveImageFacesResults;
|
||||
@ -42,7 +43,7 @@ public class Configuration
|
||||
protected readonly string[] _SaveFaceLandmarkForOutputResolutions;
|
||||
protected readonly bool? _SaveFullYearOfRandomFiles;
|
||||
protected readonly bool? _SaveResizedSubfiles;
|
||||
protected readonly bool? _SearchForAbandonedFiles;
|
||||
protected readonly bool? _SaveShortcuts;
|
||||
protected readonly bool? _SkipSearch;
|
||||
protected readonly bool? _TestDistanceResults;
|
||||
protected readonly string[] _ValidResolutions;
|
||||
@ -53,6 +54,7 @@ public class Configuration
|
||||
public bool? ForceResizeLastWriteTimeToCreationTime => _ForceResizeLastWriteTimeToCreationTime;
|
||||
public string[] IgnoreExtensions => _IgnoreExtensions;
|
||||
public string[] IgnoreRelativePaths => _IgnoreRelativePaths;
|
||||
public string[] JuliePhares => _JuliePhares;
|
||||
public bool? LoadOrCreateThenSaveDirectoryDistanceResults => _LoadOrCreateThenSaveDirectoryDistanceResults;
|
||||
public bool? LoadOrCreateThenSaveDistanceResults => _LoadOrCreateThenSaveDistanceResults;
|
||||
public bool? LoadOrCreateThenSaveImageFacesResults => _LoadOrCreateThenSaveImageFacesResults;
|
||||
@ -82,13 +84,13 @@ public class Configuration
|
||||
public string[] SaveFaceLandmarkForOutputResolutions => _SaveFaceLandmarkForOutputResolutions;
|
||||
public bool? SaveFullYearOfRandomFiles => _SaveFullYearOfRandomFiles;
|
||||
public bool? SaveResizedSubfiles => _SaveResizedSubfiles;
|
||||
public bool? SearchForAbandonedFilesFull => _SearchForAbandonedFiles;
|
||||
public bool? SaveShortcuts => _SaveShortcuts;
|
||||
public bool? SkipSearch => _SkipSearch;
|
||||
public bool? TestDistanceResults => _TestDistanceResults;
|
||||
public string[] ValidResolutions => _ValidResolutions;
|
||||
|
||||
[JsonConstructor]
|
||||
public Configuration(bool? checkJsonForDistanceResults, int? crossDirectoryMaxItemsInDistanceCollection, int? distanceFactor, bool? forceMetadataLastWriteTimeToCreationTime, bool? forceResizeLastWriteTimeToCreationTime, string[] ignoreExtensions, string[] ignoreRelativePaths, bool? loadOrCreateThenSaveDirectoryDistanceResults, bool? loadOrCreateThenSaveDistanceResults, bool? loadOrCreateThenSaveImageFacesResults, bool? loadOrCreateThenSaveIndex, int? locationConfidenceFactor, int? mappedMaxIndex, int? maxItemsInDistanceCollection, string[] mixedYearRelativePaths, string modelDirectory, string modelName, int? numJitters, string outputExtension, int? outputQuality, string[] outputResolutions, bool? overrideForFaceImages, bool? overrideForFaceLandmarkImages, bool? overrideForResizeImages, int? paddingLoops, string predictorModelName, bool? propertiesChangedForDistance, bool? propertiesChangedForFaces, bool? propertiesChangedForIndex, bool? propertiesChangedForMetadata, bool? propertiesChangedForResize, Property.Models.Configuration? propertyConfiguration, bool? reverse, string[] saveFaceLandmarkForOutputResolutions, bool? saveFullYearOfRandomFiles, bool? saveResizedSubfiles, bool? searchForAbandonedFilesFull, bool? skipSearch, bool? testDistanceResults, string[] validResolutions)
|
||||
public Configuration(bool? checkJsonForDistanceResults, int? crossDirectoryMaxItemsInDistanceCollection, int? distanceFactor, bool? forceMetadataLastWriteTimeToCreationTime, bool? forceResizeLastWriteTimeToCreationTime, string[] ignoreExtensions, string[] ignoreRelativePaths, string[] juliePhares, bool? loadOrCreateThenSaveDirectoryDistanceResults, bool? loadOrCreateThenSaveDistanceResults, bool? loadOrCreateThenSaveImageFacesResults, bool? loadOrCreateThenSaveIndex, int? locationConfidenceFactor, int? mappedMaxIndex, int? maxItemsInDistanceCollection, string[] mixedYearRelativePaths, string modelDirectory, string modelName, int? numJitters, string outputExtension, int? outputQuality, string[] outputResolutions, bool? overrideForFaceImages, bool? overrideForFaceLandmarkImages, bool? overrideForResizeImages, int? paddingLoops, string predictorModelName, bool? propertiesChangedForDistance, bool? propertiesChangedForFaces, bool? propertiesChangedForIndex, bool? propertiesChangedForMetadata, bool? propertiesChangedForResize, Property.Models.Configuration? propertyConfiguration, bool? reverse, string[] saveFaceLandmarkForOutputResolutions, bool? saveFullYearOfRandomFiles, bool? saveResizedSubfiles, bool? saveShortcuts, bool? skipSearch, bool? testDistanceResults, string[] validResolutions)
|
||||
{
|
||||
_CheckJsonForDistanceResults = checkJsonForDistanceResults;
|
||||
_CrossDirectoryMaxItemsInDistanceCollection = crossDirectoryMaxItemsInDistanceCollection;
|
||||
@ -97,6 +99,7 @@ public class Configuration
|
||||
_ForceResizeLastWriteTimeToCreationTime = forceResizeLastWriteTimeToCreationTime;
|
||||
_IgnoreExtensions = ignoreExtensions;
|
||||
_IgnoreRelativePaths = ignoreRelativePaths;
|
||||
_JuliePhares = juliePhares;
|
||||
_LoadOrCreateThenSaveDirectoryDistanceResults = loadOrCreateThenSaveDirectoryDistanceResults;
|
||||
_LoadOrCreateThenSaveDistanceResults = loadOrCreateThenSaveDistanceResults;
|
||||
_LoadOrCreateThenSaveImageFacesResults = loadOrCreateThenSaveImageFacesResults;
|
||||
@ -126,7 +129,7 @@ public class Configuration
|
||||
_SaveFaceLandmarkForOutputResolutions = saveFaceLandmarkForOutputResolutions;
|
||||
_SaveFullYearOfRandomFiles = saveFullYearOfRandomFiles;
|
||||
_SaveResizedSubfiles = saveResizedSubfiles;
|
||||
_SearchForAbandonedFiles = searchForAbandonedFilesFull;
|
||||
_SaveShortcuts = saveShortcuts;
|
||||
_SkipSearch = skipSearch;
|
||||
_TestDistanceResults = testDistanceResults;
|
||||
_ValidResolutions = validResolutions;
|
||||
@ -138,7 +141,7 @@ public class Configuration
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Set(Property.Models.Configuration propertyConfiguration) => _PropertyConfiguration = propertyConfiguration;
|
||||
public void Set(Property.Models.Configuration configuration) => _PropertyConfiguration = configuration;
|
||||
|
||||
public void Update() => _PropertyConfiguration?.Update();
|
||||
|
||||
|
@ -3,11 +3,13 @@ using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
using View_by_Distance.Metadata.Models;
|
||||
using View_by_Distance.Property.Models;
|
||||
using View_by_Distance.Resize.Models;
|
||||
using View_by_Distance.Shared.Models;
|
||||
using View_by_Distance.Shared.Models.Methods;
|
||||
using WindowsShortcutFactory;
|
||||
|
||||
namespace View_by_Distance.Instance.Models;
|
||||
|
||||
@ -47,6 +49,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
public string RelativePath => _RelativePath;
|
||||
|
||||
#nullable disable
|
||||
|
||||
[JsonConstructor]
|
||||
public D_Face(double? α, DateTime dateTime, Shared.Models.FaceEncoding faceEncoding, Dictionary<string, Shared.Models.FacePoint[]> faceLandmarks, Shared.Models.Location location, int? locationIndex, OutputResolution outputResolution, bool populated, string relativePath)
|
||||
{
|
||||
@ -125,22 +128,24 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
_RelativePath = face.RelativePath;
|
||||
}
|
||||
|
||||
private static void GetPointBounds(PointF[] points, out float xmin, out float xmax, out float ymin, out float ymax)
|
||||
#nullable restore
|
||||
|
||||
private static void GetPointBounds(PointF[] points, out float xMinimum, out float xMaximum, out float yMinimum, out float yMaximum)
|
||||
{
|
||||
xmin = points[0].X;
|
||||
xmax = xmin;
|
||||
ymin = points[0].Y;
|
||||
ymax = ymin;
|
||||
xMinimum = points[0].X;
|
||||
xMaximum = xMinimum;
|
||||
yMinimum = points[0].Y;
|
||||
yMaximum = yMinimum;
|
||||
foreach (PointF point in points)
|
||||
{
|
||||
if (xmin > point.X)
|
||||
xmin = point.X;
|
||||
if (xmax < point.X)
|
||||
xmax = point.X;
|
||||
if (ymin > point.Y)
|
||||
ymin = point.Y;
|
||||
if (ymax < point.Y)
|
||||
ymax = point.Y;
|
||||
if (xMinimum > point.X)
|
||||
xMinimum = point.X;
|
||||
if (xMaximum < point.X)
|
||||
xMaximum = point.X;
|
||||
if (yMinimum > point.Y)
|
||||
yMinimum = point.Y;
|
||||
if (yMaximum < point.Y)
|
||||
yMaximum = point.Y;
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,12 +180,12 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
new PointF(0, bitmap.Height),
|
||||
};
|
||||
rotate_at_origin.TransformPoints(points);
|
||||
float xmin, xmax, ymin, ymax;
|
||||
GetPointBounds(points, out xmin, out xmax, out ymin, out ymax);
|
||||
float xMinimum, xMaximum, yMinimum, yMaximum;
|
||||
GetPointBounds(points, out xMinimum, out xMaximum, out yMinimum, out yMaximum);
|
||||
|
||||
// Make a bitmap to hold the rotated result.
|
||||
int wid = (int)Math.Round(xmax - xmin);
|
||||
int hgt = (int)Math.Round(ymax - ymin);
|
||||
int wid = (int)Math.Round(xMaximum - xMinimum);
|
||||
int hgt = (int)Math.Round(yMaximum - yMinimum);
|
||||
result = new Bitmap(wid, hgt);
|
||||
|
||||
// Create the real rotation transformation.
|
||||
@ -251,7 +256,8 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
if (_Configuration.NumJitters is null)
|
||||
throw new Exception();
|
||||
FaceRecognitionDotNet.Location[] locations;
|
||||
FaceRecognitionDotNet.Image unknownImage = null;
|
||||
const int numberOfTimesToUpSample = 1;
|
||||
FaceRecognitionDotNet.Image? unknownImage = null;
|
||||
if (resizedFileInfo.Exists)
|
||||
{
|
||||
try
|
||||
@ -263,7 +269,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
else
|
||||
{
|
||||
FaceRecognition faceRecognition = FaceRecognition.Create(_ModelParameter);
|
||||
locations = faceRecognition.FaceLocations(unknownImage, numberOfTimesToUpsample: 1, _Model).ToArray();
|
||||
locations = faceRecognition.FaceLocations(unknownImage, numberOfTimesToUpSample, _Model).ToArray();
|
||||
if (!locations.Any())
|
||||
results.Add(new D_Face(property, outputResolutionWidth, outputResolutionHeight, outputResolutionOrientation, relativePath, i: null, location: null));
|
||||
else
|
||||
@ -276,19 +282,19 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
int leftEyeY;
|
||||
int rightEyeX;
|
||||
int rightEyeY;
|
||||
Bitmap rotated;
|
||||
string faceFile;
|
||||
Bitmap preRotated;
|
||||
Graphics graphics;
|
||||
D_Face face = null;
|
||||
D_Face? face = null;
|
||||
Rectangle rectangle;
|
||||
double[] rawEncoding;
|
||||
Bitmap rotated;
|
||||
Bitmap preRotated;
|
||||
FaceRecognitionDotNet.Image knownImage;
|
||||
FaceRecognitionDotNet.Image rotatedImage;
|
||||
Shared.Models.Location location;
|
||||
FaceRecognitionDotNet.Image knownImage;
|
||||
Shared.Models.FaceEncoding faceEncoding;
|
||||
FaceRecognitionDotNet.Image rotatedImage;
|
||||
FaceRecognitionDotNet.FaceEncoding[] faceEncodings;
|
||||
IEnumerable<FaceRecognitionDotNet.FacePoint> facePoints;
|
||||
Shared.Models.FaceEncoding faceEncoding;
|
||||
IDictionary<FacePart, IEnumerable<FaceRecognitionDotNet.FacePoint>>[] faceLandmarks;
|
||||
using Bitmap source = unknownImage.ToBitmap();
|
||||
padding = (int)((source.Width + source.Height) / 2 * .01);
|
||||
@ -380,7 +386,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
|
||||
internal List<D_Face> GetFaces(Property.Models.Configuration configuration, string outputResolution, List<Tuple<string, DateTime>> subFileTuples, List<string> parseExceptions, string relativePath, string fileNameWithoutExtension, A_Property property, FileInfo resizedFileInfo, int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation)
|
||||
{
|
||||
List<D_Face> results;
|
||||
List<D_Face>? results;
|
||||
if (_Configuration.PropertiesChangedForFaces is null)
|
||||
throw new Exception();
|
||||
string json;
|
||||
@ -412,6 +418,8 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
try
|
||||
{
|
||||
results = JsonSerializer.Deserialize<List<D_Face>>(json);
|
||||
if (results is null)
|
||||
throw new Exception($"{nameof(results)} is null");
|
||||
for (int i = 0; i < results.Count; i++)
|
||||
{
|
||||
face = results[i];
|
||||
@ -487,6 +495,106 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
SaveFaces(faceCollection, resizedFileInfo, imageFiles);
|
||||
}
|
||||
|
||||
internal void SaveShortcuts(Property.Models.Configuration configuration, string[] juliePhares, Model model, PredictorModel predictorModel, Person[] people, PropertyLogic propertyLogic, string outputResolution, PropertyHolder[] filteredPropertyHolderCollection, List<A_Property> propertyCollection, List<List<D_Face>> faceCollections)
|
||||
{
|
||||
int oldIndex;
|
||||
string[] keys;
|
||||
string fileName;
|
||||
string fullName;
|
||||
string personKey;
|
||||
string directory;
|
||||
FileInfo fileInfo;
|
||||
string copyDirectory;
|
||||
string? relativePath;
|
||||
List<D_Face> faceCollection;
|
||||
PropertyHolder propertyHolder;
|
||||
WindowsShortcut windowsShortcut;
|
||||
const string pattern = @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]";
|
||||
Dictionary<string, List<Person>> peopleCollection = new();
|
||||
foreach (Person person in people)
|
||||
{
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(person.Birthday);
|
||||
if (!peopleCollection.ContainsKey(personKey))
|
||||
peopleCollection.Add(personKey, new List<Person>());
|
||||
peopleCollection[personKey].Add(person);
|
||||
}
|
||||
string dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model.ToString(), predictorModel.ToString(), nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "(_)");
|
||||
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
|
||||
{
|
||||
personKey = string.Empty;
|
||||
copyDirectory = string.Empty;
|
||||
propertyHolder = filteredPropertyHolderCollection[i];
|
||||
if (propertyHolder.FileInfo is null)
|
||||
continue;
|
||||
fileInfo = propertyHolder.FileInfo;
|
||||
relativePath = Path.GetDirectoryName($"C:{propertyHolder.RelativePath}");
|
||||
if (string.IsNullOrEmpty(relativePath) || relativePath.Length < 3)
|
||||
continue;
|
||||
if (propertyHolder.Property?.Id is null || propertyHolder.MinimumDateTime is null || propertyHolder.ResizedFileInfo is null)
|
||||
continue;
|
||||
if (propertyHolder.Property.Indices.Length < 2)
|
||||
directory = Path.Combine(dFacesContentDirectory, $"New{relativePath[2..]}");
|
||||
else
|
||||
{
|
||||
oldIndex = propertyHolder.Property.Indices[1];
|
||||
if (!propertyLogic.NamedFaceInfo.ContainsKey(oldIndex))
|
||||
directory = Path.Combine(dFacesContentDirectory, $"Unnamed{relativePath[2..]}");
|
||||
else
|
||||
{
|
||||
faceCollection = faceCollections[i];
|
||||
keys = propertyLogic.NamedFaceInfo[oldIndex];
|
||||
if (!faceCollection.Any())
|
||||
directory = Path.Combine(dFacesContentDirectory, $"None{relativePath[2..]}");
|
||||
else if (keys.Length != 1)
|
||||
directory = Path.Combine(dFacesContentDirectory, $"Not Supported{relativePath[2..]}");
|
||||
else if (faceCollection.Count == 1)
|
||||
{
|
||||
personKey = keys[0];
|
||||
if (juliePhares.Contains(personKey))
|
||||
copyDirectory = Path.Combine(dFacesContentDirectory, "Named Images");
|
||||
directory = Path.Combine(dFacesContentDirectory, "Named Shortcuts", personKey);
|
||||
}
|
||||
else if ((from l in faceCollection where HasLeftAndRight(l.FaceLandmarks) select true).Count() == 1)
|
||||
{
|
||||
personKey = keys[0];
|
||||
if (juliePhares.Contains(personKey))
|
||||
copyDirectory = Path.Combine(dFacesContentDirectory, "Named Images^");
|
||||
directory = Path.Combine(dFacesContentDirectory, "Named Shortcuts", $"{personKey}^");
|
||||
}
|
||||
else
|
||||
directory = Path.Combine(dFacesContentDirectory, $"Many{relativePath[2..]}");
|
||||
}
|
||||
}
|
||||
if (!Directory.Exists(directory))
|
||||
{
|
||||
_ = Directory.CreateDirectory(directory);
|
||||
if (!string.IsNullOrEmpty(personKey) && peopleCollection.ContainsKey(personKey))
|
||||
{
|
||||
Person person = peopleCollection[personKey][0];
|
||||
fullName = Regex.Replace($"{Shared.Models.Stateless.Methods.IPersonName.GetFullName(person.Name)}.txt", pattern, string.Empty);
|
||||
File.WriteAllText(Path.Combine(directory, fullName), string.Empty);
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(copyDirectory))
|
||||
{
|
||||
if (!Directory.Exists(copyDirectory))
|
||||
_ = Directory.CreateDirectory(copyDirectory);
|
||||
fileName = Path.Combine(copyDirectory, $"{propertyHolder.Property.Id.Value}{propertyHolder.ResizedFileInfo.Extension}");
|
||||
if (!File.Exists(fileName))
|
||||
File.Copy(propertyHolder.ResizedFileInfo.FullName, fileName);
|
||||
}
|
||||
fileName = Path.Combine(directory, $"{propertyHolder.Property.Id.Value}.lnk");
|
||||
if (File.Exists(fileName))
|
||||
continue;
|
||||
windowsShortcut = new() { Path = fileInfo.FullName };
|
||||
windowsShortcut.Save(fileName);
|
||||
windowsShortcut.Dispose();
|
||||
if (!File.Exists(fileName))
|
||||
continue;
|
||||
File.SetLastWriteTime(fileName, propertyHolder.MinimumDateTime.Value);
|
||||
}
|
||||
}
|
||||
|
||||
double Shared.Models.Stateless.Methods.IFace.TestStatic_Getα(int x1, int x2, int y1, int y2) => throw new NotImplementedException();
|
||||
|
||||
string Shared.Models.Stateless.Methods.IFace.TestStatic_GetJson(string jsonFileFullName) => throw new NotImplementedException();
|
||||
@ -495,4 +603,18 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
|
||||
Face[] Shared.Models.Stateless.Methods.IFace.TestStatic_GetFaces(string jsonFileFullName) => throw new NotImplementedException();
|
||||
|
||||
private static bool HasLeftAndRight(Dictionary<string, Shared.Models.FacePoint[]> faceLandmarks)
|
||||
{
|
||||
bool result = true;
|
||||
if (!faceLandmarks.ContainsKey(FacePart.LeftEye.ToString()))
|
||||
result = false;
|
||||
else if (!faceLandmarks.ContainsKey(FacePart.RightEye.ToString()))
|
||||
result = false;
|
||||
else if (!faceLandmarks.ContainsKey(FacePart.LeftEyebrow.ToString()))
|
||||
result = false;
|
||||
else if (!faceLandmarks.ContainsKey(FacePart.RightEyebrow.ToString()))
|
||||
result = false;
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
@ -1,3 +1,4 @@
|
||||
using FaceRecognitionDotNet;
|
||||
using System.Text.Json;
|
||||
using View_by_Distance.Instance.Models.Stateless;
|
||||
using View_by_Distance.Metadata.Models;
|
||||
@ -34,7 +35,7 @@ internal class E2_Navigate
|
||||
return result;
|
||||
}
|
||||
|
||||
private void DisplayTags(Property.Models.Configuration configuration, string outputResolution, string[] directories, Dictionary<ConsoleKey, int> directoryKeyValuePairs, string[] files, Dictionary<ConsoleKey, int> fileKeyValuePairs)
|
||||
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 Exception($"{nameof(_Log)} is null!");
|
||||
@ -44,10 +45,12 @@ internal class E2_Navigate
|
||||
string? rootResultsDirectory = Path.GetDirectoryName(Property.Models.Stateless.IResult.GetResultsGroupDirectory(configuration, nameof(B_Metadata)));
|
||||
if (string.IsNullOrEmpty(rootResultsDirectory))
|
||||
throw new Exception();
|
||||
string modelName = model.ToString();
|
||||
string predictorModelName = predictorModel.ToString();
|
||||
string rootResultsDirectoryAbsoluteUri = new Uri(rootResultsDirectory).AbsoluteUri;
|
||||
string dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
string cResizeContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()");
|
||||
string eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
string dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
string cResizeContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()");
|
||||
string eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
(string RootResultsDirectoryAbsoluteUri, string C_ResizeContentDirectory, string D_FacesContentDirectory, string E_DistanceCollectionDirectory) tuple = new(rootResultsDirectoryAbsoluteUri, cResizeContentDirectory, dFacesContentDirectory, eDistanceCollectionDirectory);
|
||||
List<FileSystem> fileSystemCollection = Shared.Models.Stateless.Methods.IFileSystem.GetFileSystemCollection(requestPath, tuple, directories, files, all);
|
||||
Queue<FileSystem> queue = new(fileSystemCollection);
|
||||
@ -67,7 +70,7 @@ internal class E2_Navigate
|
||||
}
|
||||
}
|
||||
|
||||
private void DisplayFaces(Property.Models.Configuration configuration, string outputResolution, string selectedFileFullName)
|
||||
private void DisplayFaces(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel, string outputResolution, string selectedFileFullName)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new Exception($"{nameof(_Log)} is null!");
|
||||
@ -75,10 +78,12 @@ internal class E2_Navigate
|
||||
string? rootResultsDirectory = Path.GetDirectoryName(Property.Models.Stateless.IResult.GetResultsGroupDirectory(configuration, nameof(B_Metadata)));
|
||||
if (string.IsNullOrEmpty(rootResultsDirectory))
|
||||
throw new Exception();
|
||||
string modelName = model.ToString();
|
||||
string predictorModelName = predictorModel.ToString();
|
||||
string rootResultsDirectoryAbsoluteUri = new Uri(rootResultsDirectory).AbsoluteUri;
|
||||
string dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
string cResizeContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()");
|
||||
string eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
string dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
string cResizeContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()");
|
||||
string eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
(string RootResultsDirectoryAbsoluteUri, string C_ResizeContentDirectory, string D_FacesContentDirectory, string E_DistanceCollectionDirectory) tuple = new(rootResultsDirectoryAbsoluteUri, cResizeContentDirectory, dFacesContentDirectory, eDistanceCollectionDirectory);
|
||||
FaceFileSystem[] faceFileSystemCollection = Shared.Models.Stateless.Methods.IFaceFileSystem.GetFaceFileSystemCollection(requestPath, tuple, selectedFileFullName);
|
||||
for (int i = 0; i < faceFileSystemCollection.Length; i++)
|
||||
@ -90,7 +95,7 @@ internal class E2_Navigate
|
||||
// }
|
||||
}
|
||||
|
||||
private string Rename(Property.Models.Configuration configuration, string subSourceDirectory)
|
||||
private string Rename(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel, string subSourceDirectory)
|
||||
{
|
||||
string result;
|
||||
if (_Log is null)
|
||||
@ -109,7 +114,7 @@ internal class E2_Navigate
|
||||
else
|
||||
{
|
||||
_Log.Warn(string.Empty);
|
||||
string eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), _Configuration.ValidResolutions[0], includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
string eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model.ToString(), predictorModel.ToString(), nameof(E_Distance), _Configuration.ValidResolutions[0], includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
string relativePath = Property.Models.Stateless.IPath.GetRelativePath(subSourceDirectory, eDistanceCollectionDirectory.Length);
|
||||
if (relativePath.Length == 1)
|
||||
throw new Exception();
|
||||
@ -120,7 +125,7 @@ internal class E2_Navigate
|
||||
}
|
||||
else
|
||||
{
|
||||
_Rename.DirectoryRename(configuration, relativePath, newDirectoryName);
|
||||
_Rename.DirectoryRename(configuration, model, predictorModel, relativePath, newDirectoryName);
|
||||
_Log.Warn("Renamed...");
|
||||
string? directoryName = Path.GetDirectoryName(subSourceDirectory);
|
||||
if (string.IsNullOrEmpty(directoryName))
|
||||
@ -131,7 +136,7 @@ internal class E2_Navigate
|
||||
return result;
|
||||
}
|
||||
|
||||
internal void Navigate(Property.Models.Configuration configuration, string outputResolution)
|
||||
internal void Navigate(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel, string outputResolution)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new Exception($"{nameof(_Log)} is null!");
|
||||
@ -143,7 +148,7 @@ internal class E2_Navigate
|
||||
string? subSourceDirectory = string.Empty;
|
||||
Dictionary<ConsoleKey, int> fileKeyValuePairs = new();
|
||||
Dictionary<ConsoleKey, int> directoryKeyValuePairs = new();
|
||||
string eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), _Configuration.OutputResolutions[0], includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
string eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model.ToString(), predictorModel.ToString(), nameof(E_Distance), _Configuration.OutputResolutions[0], includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
if (!Directory.Exists(eDistanceCollectionDirectory))
|
||||
_ = Directory.CreateDirectory(eDistanceCollectionDirectory);
|
||||
for (int z = 0; z < int.MaxValue; z++)
|
||||
@ -161,8 +166,10 @@ internal class E2_Navigate
|
||||
fileKeyValuePairs.Clear();
|
||||
for (int i = (int)ConsoleKey.A + subDirectories.Length; i < (subFiles.Length + (int)ConsoleKey.A + subDirectories.Length) && i <= (int)ConsoleKey.RightWindows; i++)
|
||||
fileKeyValuePairs.Add((ConsoleKey)i, i - (int)ConsoleKey.A);
|
||||
if (!directoryKeyValuePairs.Any() && !fileKeyValuePairs.Any())
|
||||
break;
|
||||
_Log.Warn("");
|
||||
DisplayTags(configuration, outputResolution, subDirectories, directoryKeyValuePairs, subFiles, fileKeyValuePairs);
|
||||
DisplayTags(configuration, model, predictorModel, outputResolution, subDirectories, directoryKeyValuePairs, subFiles, fileKeyValuePairs);
|
||||
_Log.Warn(string.Empty);
|
||||
_Log.Warn(string.Empty);
|
||||
_Log.Warn(string.Empty);
|
||||
@ -180,7 +187,7 @@ internal class E2_Navigate
|
||||
}
|
||||
else
|
||||
{
|
||||
subSourceDirectory = Rename(configuration, subSourceDirectory);
|
||||
subSourceDirectory = Rename(configuration, model, predictorModel, subSourceDirectory);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -212,7 +219,7 @@ internal class E2_Navigate
|
||||
{
|
||||
selectedFileFullName = subFiles[fileKeyValuePairs[consoleKey]];
|
||||
_Log.Warn(string.Concat(">>> [", Path.GetFileName(selectedFileFullName), "]<", selectedFileFullName, ">?"));
|
||||
DisplayFaces(configuration, outputResolution, selectedFileFullName);
|
||||
DisplayFaces(configuration, model, predictorModel, outputResolution, selectedFileFullName);
|
||||
_Log.Warn(string.Empty);
|
||||
_Log.Warn(string.Empty);
|
||||
_Log.Warn(string.Empty);
|
||||
|
@ -1,3 +1,4 @@
|
||||
using FaceRecognitionDotNet;
|
||||
using System.Text.Json;
|
||||
using View_by_Distance.Metadata.Models;
|
||||
using View_by_Distance.Property.Models;
|
||||
@ -28,7 +29,7 @@ internal class E3_Rename
|
||||
return result;
|
||||
}
|
||||
|
||||
internal string[] GetDirectoryRenameCollection(Property.Models.Configuration configuration, string relativePath, string newDirectoryName, bool jsonFiles4InfoAny)
|
||||
internal string[] GetDirectoryRenameCollection(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel, string relativePath, string newDirectoryName, bool jsonFiles4InfoAny)
|
||||
{
|
||||
List<string> results = new();
|
||||
bool add;
|
||||
@ -41,9 +42,11 @@ internal class E3_Rename
|
||||
string aPropertySingletonDirectory;
|
||||
string bMetadataSingletonDirectory;
|
||||
string eDistanceCollectionDirectory;
|
||||
string modelName = model.ToString();
|
||||
string g2IdentifyCollectionDirectory;
|
||||
string d2FaceLandmarksContentDirectory;
|
||||
add = Directory.Exists(string.Concat(Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), _Configuration.ValidResolutions[0], includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()"), relativePath));
|
||||
string predictorModelName = predictorModel.ToString();
|
||||
add = Directory.Exists(string.Concat(Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(C_Resize), _Configuration.ValidResolutions[0], includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()"), relativePath));
|
||||
bMetadataSingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(B_Metadata), "{}");
|
||||
if (Directory.Exists(bMetadataSingletonDirectory))
|
||||
{
|
||||
@ -56,7 +59,7 @@ internal class E3_Rename
|
||||
to = Path.Combine(string.Concat(aPropertySingletonDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
results.Add(to);
|
||||
}
|
||||
cResizeContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), _Configuration.ValidResolutions[0], includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()");
|
||||
cResizeContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(C_Resize), _Configuration.ValidResolutions[0], includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()");
|
||||
if (Directory.Exists(cResizeContentDirectory))
|
||||
{
|
||||
to = Path.Combine(string.Concat(cResizeContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
@ -64,37 +67,37 @@ internal class E3_Rename
|
||||
}
|
||||
foreach (string outputResolution in _Configuration.ValidResolutions)
|
||||
{
|
||||
cResizeSingletonDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "{}");
|
||||
cResizeSingletonDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "{}");
|
||||
if (Directory.Exists(cResizeSingletonDirectory))
|
||||
{
|
||||
to = Path.Combine(string.Concat(cResizeSingletonDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
results.Add(to);
|
||||
}
|
||||
dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
if (Directory.Exists(dFacesContentDirectory))
|
||||
{
|
||||
to = Path.Combine(string.Concat(dFacesContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
results.Add(to);
|
||||
}
|
||||
dFacesCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
dFacesCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
if (Directory.Exists(dFacesCollectionDirectory))
|
||||
{
|
||||
to = Path.Combine(string.Concat(dFacesCollectionDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
results.Add(to);
|
||||
}
|
||||
d2FaceLandmarksContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D2_FaceLandmarks), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
d2FaceLandmarksContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(D2_FaceLandmarks), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
if (add && _Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution) && Directory.Exists(d2FaceLandmarksContentDirectory))
|
||||
{
|
||||
to = Path.Combine(string.Concat(d2FaceLandmarksContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
results.Add(to);
|
||||
}
|
||||
eDistanceContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
eDistanceContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
if (Directory.Exists(eDistanceContentDirectory))
|
||||
{
|
||||
to = Path.Combine(string.Concat(eDistanceContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
results.Add(to);
|
||||
}
|
||||
eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
if (Directory.Exists(eDistanceCollectionDirectory))
|
||||
{
|
||||
to = Path.Combine(string.Concat(eDistanceCollectionDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
@ -110,7 +113,7 @@ internal class E3_Rename
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
internal List<string[]> GetDirectoryRenameCollections(Property.Models.Configuration configuration, string relativePath, string newDirectoryName, bool jsonFiles4InfoAny)
|
||||
internal List<string[]> GetDirectoryRenameCollections(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel, string relativePath, string newDirectoryName, bool jsonFiles4InfoAny)
|
||||
{
|
||||
List<string[]> results = new();
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
@ -126,9 +129,11 @@ internal class E3_Rename
|
||||
string eDistanceContentDirectory;
|
||||
string bMetadataSingletonDirectory;
|
||||
string aPropertySingletonDirectory;
|
||||
string modelName = model.ToString();
|
||||
string eDistanceCollectionDirectory;
|
||||
string g2IdentifyCollectionDirectory;
|
||||
string d2FaceLandmarksContentDirectory;
|
||||
string predictorModelName = predictorModel.ToString();
|
||||
if (!string.IsNullOrEmpty(relativePath))
|
||||
{
|
||||
from = string.Concat(_Configuration.PropertyConfiguration.RootDirectory, relativePath);
|
||||
@ -137,7 +142,7 @@ internal class E3_Rename
|
||||
}
|
||||
foreach (string outputResolution in _Configuration.ValidResolutions)
|
||||
{
|
||||
add = Directory.Exists(string.Concat(Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()"), relativePath));
|
||||
add = Directory.Exists(string.Concat(Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()"), relativePath));
|
||||
bMetadataSingletonDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(B_Metadata), "{}");
|
||||
from = string.Concat(bMetadataSingletonDirectory, relativePath);
|
||||
exists = Directory.Exists(bMetadataSingletonDirectory);
|
||||
@ -154,7 +159,7 @@ internal class E3_Rename
|
||||
to = Path.Combine(string.Concat(aPropertySingletonDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
results.Add(new string[] { from, to });
|
||||
}
|
||||
cResizeContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()");
|
||||
cResizeContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "()");
|
||||
from = string.Concat(cResizeContentDirectory, relativePath);
|
||||
exists = Directory.Exists(cResizeContentDirectory);
|
||||
if (exists)
|
||||
@ -162,7 +167,7 @@ internal class E3_Rename
|
||||
to = Path.Combine(string.Concat(cResizeContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
results.Add(new string[] { from, to });
|
||||
}
|
||||
cResizeSingletonDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "{}");
|
||||
cResizeSingletonDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(C_Resize), outputResolution, includeResizeGroup: true, includeModel: false, includePredictorModel: false), "{}");
|
||||
from = string.Concat(cResizeSingletonDirectory, relativePath);
|
||||
exists = Directory.Exists(cResizeSingletonDirectory);
|
||||
if (exists)
|
||||
@ -170,7 +175,7 @@ internal class E3_Rename
|
||||
to = Path.Combine(string.Concat(cResizeSingletonDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
results.Add(new string[] { from, to });
|
||||
}
|
||||
dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
dFacesContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
from = string.Concat(dFacesContentDirectory, relativePath);
|
||||
exists = Directory.Exists(dFacesContentDirectory);
|
||||
if (exists)
|
||||
@ -178,7 +183,7 @@ internal class E3_Rename
|
||||
to = Path.Combine(string.Concat(dFacesContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
results.Add(new string[] { from, to });
|
||||
}
|
||||
dFacesCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
dFacesCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
from = string.Concat(dFacesCollectionDirectory, relativePath);
|
||||
exists = Directory.Exists(dFacesCollectionDirectory);
|
||||
if (exists)
|
||||
@ -186,7 +191,7 @@ internal class E3_Rename
|
||||
to = Path.Combine(string.Concat(dFacesCollectionDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
results.Add(new string[] { from, to });
|
||||
}
|
||||
d2FaceLandmarksContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D2_FaceLandmarks), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
d2FaceLandmarksContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(D2_FaceLandmarks), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
from = string.Concat(d2FaceLandmarksContentDirectory, relativePath);
|
||||
exists = Directory.Exists(d2FaceLandmarksContentDirectory);
|
||||
if (!exists && add && _Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution))
|
||||
@ -196,7 +201,7 @@ internal class E3_Rename
|
||||
to = Path.Combine(string.Concat(d2FaceLandmarksContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
results.Add(new string[] { from, to });
|
||||
}
|
||||
eDistanceContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
eDistanceContentDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "()");
|
||||
from = string.Concat(eDistanceContentDirectory, relativePath);
|
||||
exists = Directory.Exists(eDistanceContentDirectory);
|
||||
if (exists)
|
||||
@ -204,7 +209,7 @@ internal class E3_Rename
|
||||
to = Path.Combine(string.Concat(eDistanceContentDirectory, Path.GetDirectoryName(relativePath)), newDirectoryName);
|
||||
results.Add(new string[] { from, to });
|
||||
}
|
||||
eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, modelName, predictorModelName, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
from = string.Concat(eDistanceCollectionDirectory, relativePath);
|
||||
exists = Directory.Exists(eDistanceCollectionDirectory);
|
||||
if (exists)
|
||||
@ -226,7 +231,7 @@ internal class E3_Rename
|
||||
return results;
|
||||
}
|
||||
|
||||
internal void DirectoryRename(Property.Models.Configuration configuration, string relativePath, string newDirectoryName)
|
||||
internal void DirectoryRename(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel, string relativePath, string newDirectoryName)
|
||||
{
|
||||
if (_Configuration?.PropertyConfiguration is null)
|
||||
throw new Exception($"{nameof(_Configuration.PropertyConfiguration)} must be set!");
|
||||
@ -236,7 +241,7 @@ internal class E3_Rename
|
||||
string error = "Error";
|
||||
string target = "Target";
|
||||
string pending = "Pending";
|
||||
DirectoryInfo directoryInfo;
|
||||
System.IO.DirectoryInfo directoryInfo;
|
||||
IEnumerator<FileInfo> fileInfoCollection;
|
||||
string oldValue = string.Concat("\"", relativePath);
|
||||
string oldDirectoryName = Path.GetFileName(relativePath);
|
||||
@ -248,7 +253,7 @@ internal class E3_Rename
|
||||
string newValue = string.Concat("\"", Path.Combine(relativePathParent, newDirectoryName));
|
||||
string e3RenameContentDirectory = Property.Models.Stateless.IResult.GetResultsDateGroupDirectory(configuration, nameof(E3_Rename), "()");
|
||||
string jsonRootDirectory = Path.Combine(string.Concat(_Configuration.PropertyConfiguration.RootDirectory, " - Copied"), string.Concat(directoryName, " - 4) Info"), _Configuration.PropertyConfiguration.DateGroup, "[]");
|
||||
directoryInfo = new DirectoryInfo(jsonRootDirectory);
|
||||
directoryInfo = new System.IO.DirectoryInfo(jsonRootDirectory);
|
||||
if (!directoryInfo.Exists)
|
||||
directoryInfo.Create();
|
||||
IEnumerator<FileInfo> fileInfoCollection4 = directoryInfo.EnumerateFiles("*.json", SearchOption.AllDirectories).GetEnumerator();
|
||||
@ -257,7 +262,7 @@ internal class E3_Rename
|
||||
current = new(string.Empty);
|
||||
else
|
||||
current = fileInfoCollection4.Current;
|
||||
List<string[]> directoryCollections = GetDirectoryRenameCollections(configuration, relativePath, newDirectoryName, fileInfoCollection4MoveNext);
|
||||
List<string[]> directoryCollections = GetDirectoryRenameCollections(configuration, model, predictorModel, relativePath, newDirectoryName, fileInfoCollection4MoveNext);
|
||||
if ((from l in directoryCollections where l.Length != 2 select true).Any())
|
||||
throw new Exception();
|
||||
if (!Directory.Exists(e3RenameContentDirectory))
|
||||
@ -277,7 +282,7 @@ internal class E3_Rename
|
||||
{
|
||||
foreach (string[] directoryCollection in directoryCollections)
|
||||
{
|
||||
directoryInfo = new DirectoryInfo(directoryCollection[0]);
|
||||
directoryInfo = new System.IO.DirectoryInfo(directoryCollection[0]);
|
||||
if (!directoryInfo.Exists)
|
||||
continue;
|
||||
fileInfoCollection = directoryInfo.EnumerateFiles("*.json", SearchOption.AllDirectories).GetEnumerator();
|
||||
@ -314,7 +319,7 @@ internal class E3_Rename
|
||||
}
|
||||
}
|
||||
|
||||
internal void RenameQueue(Property.Models.Configuration configuration)
|
||||
internal void RenameQueue(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel)
|
||||
{
|
||||
string[] lines;
|
||||
string[] segments;
|
||||
@ -330,7 +335,7 @@ internal class E3_Rename
|
||||
segments = line.Split('\t');
|
||||
if (segments.Length != 2)
|
||||
throw new Exception();
|
||||
DirectoryRename(configuration, segments[0], segments[1]);
|
||||
DirectoryRename(configuration, model, predictorModel, segments[0], segments[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,11 +31,11 @@ internal class E_Distance
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void LoadFaceEncodingCollections(string[] subFiles, List<List<D_Face>> faceCollections, List<int[]> locationIndicesCollection, List<FaceEncoding> faceEncodingCollection, List<List<FaceEncoding>> faceEncodingCollections)
|
||||
private static void LoadFaceEncodingCollections(PropertyHolder[] filteredPropertyHolderCollection, 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 < subFiles.Length; i++)
|
||||
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
|
||||
{
|
||||
faceCollection = faceCollections[i];
|
||||
if (!faceCollection.Any())
|
||||
@ -169,54 +169,65 @@ internal class E_Distance
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadOrCreateThenSaveDistanceResults(Property.Models.Configuration configuration, string[] subFiles, List<List<D_Face>> faceCollections, List<string[]> directories)
|
||||
private void LoadOrCreateThenSaveDistanceResults(Property.Models.Configuration configuration, PropertyHolder[] filteredPropertyHolderCollection, List<List<D_Face>> faceCollections, List<string[]> directories)
|
||||
{
|
||||
FileInfo? fileInfo;
|
||||
string fileNameWithoutExtension;
|
||||
List<int[]> locationIndicesCollection = new();
|
||||
List<Tuple<string, DateTime>> subFileTuples = new();
|
||||
List<FaceEncoding> faceEncodingCollection = new();
|
||||
List<List<FaceEncoding>> faceEncodingCollections = new();
|
||||
LoadFaceEncodingCollections(subFiles, faceCollections, locationIndicesCollection, faceEncodingCollection, faceEncodingCollections);
|
||||
LoadFaceEncodingCollections(filteredPropertyHolderCollection, 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 < subFiles.Length; i++)
|
||||
for (int i = 0; i < filteredPropertyHolderCollection.Length; i++)
|
||||
{
|
||||
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(subFiles[i]);
|
||||
LoadOrCreateThenSaveDistanceResultsLoop(configuration, faceCollections, subFiles.Length, i, faceCollections[i], locationIndicesCollection, subFileTuples, faceEncodingCollection, faceEncodingCollections[i], fileNameWithoutExtension, directories[i][0], directories[i][1]);
|
||||
fileInfo = filteredPropertyHolderCollection[i].FileInfo;
|
||||
if (fileInfo is null)
|
||||
continue;
|
||||
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName);
|
||||
LoadOrCreateThenSaveDistanceResultsLoop(configuration, faceCollections, filteredPropertyHolderCollection.Length, i, faceCollections[i], locationIndicesCollection, subFileTuples, faceEncodingCollection, faceEncodingCollections[i], fileNameWithoutExtension, directories[i][0], directories[i][1]);
|
||||
}
|
||||
}
|
||||
|
||||
internal void LoadOrCreateThenSaveDistanceResults(Property.Models.Configuration configuration, string sourceDirectory, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, string[] subFiles, List<List<D_Face>> faceCollections)
|
||||
internal void LoadOrCreateThenSaveDistanceResults(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel, string sourceDirectory, string outputResolution, List<Tuple<string, DateTime>> sourceDirectoryChanges, PropertyHolder[] filteredPropertyHolderCollection, List<List<D_Face>> faceCollections)
|
||||
{
|
||||
if (_Configuration.CheckJsonForDistanceResults is null)
|
||||
throw new Exception();
|
||||
if (_Configuration.PropertiesChangedForDistance is null)
|
||||
throw new Exception();
|
||||
string json;
|
||||
FileInfo? fileInfo;
|
||||
bool check = false;
|
||||
string parentCheck;
|
||||
DirectoryInfo directoryInfo;
|
||||
DirectoryInfo tvsDirectoryInfo;
|
||||
FileInfo[] fileInfoCollection;
|
||||
System.IO.DirectoryInfo directoryInfo;
|
||||
System.IO.DirectoryInfo tvsDirectoryInfo;
|
||||
string fileNameWithoutExtension;
|
||||
List<string[]> directories = new();
|
||||
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata), nameof(C_Resize), nameof(D_Face) };
|
||||
List<DateTime> dateTimes = (from l in sourceDirectoryChanges where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||
List<string> directoryInfoCollection = Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||
sourceDirectory,
|
||||
nameof(E_Distance),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: true,
|
||||
includePredictorModel: true,
|
||||
contentDescription: ".tvs File",
|
||||
singletonDescription: string.Empty,
|
||||
collectionDescription: "n json file(s) for each face found (one to many)");
|
||||
for (int i = 0; i < subFiles.Length; i++)
|
||||
model.ToString(),
|
||||
predictorModel.ToString(),
|
||||
sourceDirectory,
|
||||
nameof(E_Distance),
|
||||
outputResolution,
|
||||
includeResizeGroup: true,
|
||||
includeModel: true,
|
||||
includePredictorModel: true,
|
||||
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++)
|
||||
{
|
||||
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(subFiles[i]);
|
||||
directoryInfo = new DirectoryInfo(Path.Combine(directoryInfoCollection[0].Replace("<>", "[]"), fileNameWithoutExtension));
|
||||
fileInfo = filteredPropertyHolderCollection[i].FileInfo;
|
||||
if (fileInfo is null)
|
||||
continue;
|
||||
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.FullName);
|
||||
directoryInfo = new System.IO.DirectoryInfo(Path.Combine(directoryInfoCollection[0].Replace("<>", "[]"), fileNameWithoutExtension));
|
||||
if (!directoryInfo.Exists)
|
||||
{
|
||||
if (directoryInfo.Parent?.Parent is null)
|
||||
@ -229,14 +240,15 @@ internal class E_Distance
|
||||
Directory.Delete(parentCheck);
|
||||
}
|
||||
}
|
||||
tvsDirectoryInfo = new DirectoryInfo(Path.Combine(directoryInfoCollection[0].Replace("<>", "()"), fileNameWithoutExtension));
|
||||
tvsDirectoryInfo = new System.IO.DirectoryInfo(Path.Combine(directoryInfoCollection[0].Replace("<>", "()"), fileNameWithoutExtension));
|
||||
directories.Add(new string[] { directoryInfo.FullName, tvsDirectoryInfo.FullName });
|
||||
if (_Configuration.CheckJsonForDistanceResults.Value && directoryInfo.Exists)
|
||||
{
|
||||
foreach (FileInfo fileInfo in directoryInfo.GetFiles("*.json", SearchOption.AllDirectories))
|
||||
fileInfoCollection = directoryInfo.GetFiles("*.json", SearchOption.AllDirectories);
|
||||
for (int j = 0; j < fileInfoCollection.Length; j++)
|
||||
{
|
||||
json = Shared.Models.Stateless.Methods.IIndex.GetJson(fileInfo.FullName, fileInfo);
|
||||
if (!_Configuration.PropertiesChangedForDistance.Value && Shared.Models.Stateless.Methods.IFace.GetFace(fileInfo.FullName) is null)
|
||||
json = Shared.Models.Stateless.Methods.IIndex.GetJson(fileInfoCollection[j].FullName, fileInfoCollection[j]);
|
||||
if (!_Configuration.PropertiesChangedForDistance.Value && Shared.Models.Stateless.Methods.IFace.GetFace(fileInfoCollection[j].FullName) is null)
|
||||
check = true;
|
||||
}
|
||||
}
|
||||
@ -252,16 +264,16 @@ internal class E_Distance
|
||||
check = true;
|
||||
}
|
||||
if (check)
|
||||
LoadOrCreateThenSaveDistanceResults(configuration, subFiles, faceCollections, directories);
|
||||
LoadOrCreateThenSaveDistanceResults(configuration, filteredPropertyHolderCollection, faceCollections, directories);
|
||||
_ = Property.Models.Stateless.IPath.DeleteEmptyDirectories(directoryInfoCollection[0].Replace("<>", "()"));
|
||||
}
|
||||
|
||||
private List<(string, List<KeyValuePair<string, Shared.Models.Face[]>>)> GetFiles(Property.Models.Configuration configuration, string outputResolution)
|
||||
private List<(string, List<KeyValuePair<string, Shared.Models.Face[]>>)> GetFiles(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel, string outputResolution)
|
||||
{
|
||||
string json;
|
||||
List<KeyValuePair<string, Shared.Models.Face[]>>? facesKeyValuePairCollection;
|
||||
List<(string, List<KeyValuePair<string, Shared.Models.Face[]>>)> results = new();
|
||||
string dFacesCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[[]]");
|
||||
string dFacesCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model.ToString(), predictorModel.ToString(), nameof(D_Face), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[[]]");
|
||||
string[] dFacesCollectionFiles = Directory.GetFiles(dFacesCollectionDirectory, "*.json", SearchOption.TopDirectoryOnly);
|
||||
foreach (string dFacesCollectionFile in dFacesCollectionFiles)
|
||||
{
|
||||
@ -311,10 +323,10 @@ internal class E_Distance
|
||||
return result;
|
||||
}
|
||||
|
||||
private void Save(Property.Models.Configuration configuration, string outputResolution, string eDistanceCollectionDirectory, int k, string relativePath, Shared.Models.Face face, List<Tuple<Shared.Models.Face, string>> faceAndFaceDistanceCollection)
|
||||
private void Save(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel, string outputResolution, string eDistanceCollectionDirectory, int k, string relativePath, Shared.Models.Face face, List<Tuple<Shared.Models.Face, string>> faceAndFaceDistanceCollection)
|
||||
{
|
||||
if (string.IsNullOrEmpty(eDistanceCollectionDirectory))
|
||||
eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
eDistanceCollectionDirectory = Path.Combine(Property.Models.Stateless.IResult.GetResultsFullGroupDirectory(configuration, model.ToString(), predictorModel.ToString(), nameof(E_Distance), outputResolution, includeResizeGroup: true, includeModel: true, includePredictorModel: true), "[]");
|
||||
string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(face.RelativePath);
|
||||
string jsonDirectory = string.Concat(eDistanceCollectionDirectory, Path.Combine(relativePath, fileNameWithoutExtension));
|
||||
if (!Directory.Exists(jsonDirectory))
|
||||
@ -333,7 +345,7 @@ internal class E_Distance
|
||||
return result;
|
||||
}
|
||||
|
||||
internal void LoadOrCreateThenSaveDirectoryDistanceResults(Property.Models.Configuration configuration, string outputResolution)
|
||||
internal void LoadOrCreateThenSaveDirectoryDistanceResults(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel, string outputResolution)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new Exception($"{nameof(_Log)} is null!");
|
||||
@ -344,7 +356,7 @@ internal class E_Distance
|
||||
string eDistanceCollectionDirectory = string.Empty;
|
||||
Tuple<Shared.Models.Face, double> faceAndFaceDistance;
|
||||
List<Tuple<Shared.Models.Face, string>> faceAndFaceDistanceCollection;
|
||||
List<(string, List<KeyValuePair<string, Shared.Models.Face[]>>)> files = GetFiles(configuration, outputResolution);
|
||||
List<(string, List<KeyValuePair<string, Shared.Models.Face[]>>)> files = GetFiles(configuration, model, predictorModel, outputResolution);
|
||||
List<(string, List<Shared.Models.Face>, List<FaceEncoding>)> matches = GetMatches(files);
|
||||
if (files.Count != matches.Count)
|
||||
throw new Exception();
|
||||
@ -380,7 +392,7 @@ internal class E_Distance
|
||||
if (faceAndFaceDistanceCollection.Any())
|
||||
{
|
||||
faceAndFaceDistanceCollection = (from l in faceAndFaceDistanceCollection orderby l.Item2 select l).Take(_Configuration.CrossDirectoryMaxItemsInDistanceCollection.Value).ToList();
|
||||
Save(configuration, outputResolution, eDistanceCollectionDirectory, k, relativePath, face, faceAndFaceDistanceCollection);
|
||||
Save(configuration, model, predictorModel, outputResolution, eDistanceCollectionDirectory, k, relativePath, face, faceAndFaceDistanceCollection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -90,11 +90,11 @@ public class G2_Identify : Shared.Models.Properties.IIdentify, IIdentify
|
||||
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.GetFormated(l.Birthday)).ToArray();
|
||||
string[] peopleBirthDates = (from l in people select Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(l.Birthday)).ToArray();
|
||||
Dictionary<string, string[]> sourceKeyValuePairs = JsonSerializer.Deserialize<Dictionary<string, string[]>>(json);
|
||||
foreach (KeyValuePair<string, string[]> keyValuePair in sourceKeyValuePairs)
|
||||
{
|
||||
if (!(from l in keyValuePair.Value where peopleBirthdates.Contains(l) select false).Any())
|
||||
if (!(from l in keyValuePair.Value where peopleBirthDates.Contains(l) select false).Any())
|
||||
continue;
|
||||
resultKeyValuePairs.Add(keyValuePair.Key, keyValuePair.Value);
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
using FaceRecognitionDotNet;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using View_by_Distance.Property.Models;
|
||||
@ -103,7 +104,7 @@ public class G_Index : Shared.Models.Properties.IIndex, IIndex
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteGroup(Property.Models.Configuration configuration, string outputResolution, List<Tuple<string, Dictionary<int, G_Index>>> indexInfoTuples)
|
||||
private void WriteGroup(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel, string outputResolution, List<Tuple<string, Dictionary<int, G_Index>>> indexInfoTuples)
|
||||
{
|
||||
string json;
|
||||
G_Index[] indices;
|
||||
@ -111,14 +112,14 @@ public class G_Index : Shared.Models.Properties.IIndex, IIndex
|
||||
foreach (Tuple<string, Dictionary<int, G_Index>> tuple in indexInfoTuples)
|
||||
{
|
||||
indices = (from l in tuple.Item2 select l.Value).ToArray();
|
||||
directoryInfoCollection = Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration, tuple.Item1, nameof(G_Index), outputResolution, includeResizeGroup: false, includeModel: false, includePredictorModel: false, contentDescription: string.Empty, singletonDescription: string.Empty, collectionDescription: "Unknown A");
|
||||
directoryInfoCollection = Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration, model.ToString(), predictorModel.ToString(), tuple.Item1, nameof(G_Index), outputResolution, includeResizeGroup: false, includeModel: false, includePredictorModel: false, contentDescription: string.Empty, singletonDescription: string.Empty, collectionDescription: "Unknown A");
|
||||
json = JsonSerializer.Serialize(indices, _WriteIndentedJsonSerializerOptions);
|
||||
if (!Property.Models.Stateless.IPath.WriteAllText(string.Concat(directoryInfoCollection[0].Replace("<>", "[]"), ".json"), json, compareBeforeWrite: true))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
private void AppendTSV(Property.Models.Configuration configuration, string outputResolution, Dictionary<string, List<Tuple<string, A_Property>>> filePropertiesKeyValuePairs)
|
||||
private void AppendTSV(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel, string outputResolution, Dictionary<string, List<Tuple<string, A_Property>>> filePropertiesKeyValuePairs)
|
||||
{
|
||||
A_Property property;
|
||||
DateTime?[] dateTimes;
|
||||
@ -137,11 +138,11 @@ public class G_Index : Shared.Models.Properties.IIndex, IIndex
|
||||
maximumDateTime = (from l in dateTimes where l.HasValue select l.Value).Max();
|
||||
minimumDateTime = (from l in dateTimes where l.HasValue select l.Value).Min();
|
||||
}
|
||||
directoryInfoCollection = Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration, tuples.Key, nameof(G_Index), outputResolution, includeResizeGroup: false, includeModel: false, includePredictorModel: false, contentDescription: string.Empty, singletonDescription: "Unkown B", collectionDescription: string.Empty);
|
||||
directoryInfoCollection = Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration, model.ToString(), predictorModel.ToString(), tuples.Key, nameof(G_Index), outputResolution, includeResizeGroup: false, includeModel: false, includePredictorModel: false, contentDescription: string.Empty, singletonDescription: "Unkown B", collectionDescription: string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetIndex(Property.Models.Configuration configuration, string outputResolution, Dictionary<string, List<Tuple<string, A_Property>>> filePropertiesKeyValuePairs)
|
||||
internal void SetIndex(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel, string outputResolution, Dictionary<string, List<Tuple<string, A_Property>>> filePropertiesKeyValuePairs)
|
||||
{
|
||||
if (_Configuration.PropertiesChangedForIndex is null)
|
||||
throw new Exception();
|
||||
@ -168,7 +169,7 @@ public class G_Index : Shared.Models.Properties.IIndex, IIndex
|
||||
foreach (KeyValuePair<string, List<Tuple<string, A_Property>>> tuples in filePropertiesKeyValuePairs)
|
||||
{
|
||||
valuePairs = new Dictionary<int, G_Index>();
|
||||
directoryInfoCollection = Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration, tuples.Key, nameof(G_Index), outputResolution, includeResizeGroup: false, includeModel: false, includePredictorModel: false, contentDescription: string.Empty, singletonDescription: "Unknown C", collectionDescription: string.Empty);
|
||||
directoryInfoCollection = Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration, model.ToString(), predictorModel.ToString(), tuples.Key, nameof(G_Index), outputResolution, includeResizeGroup: false, includeModel: false, includePredictorModel: false, contentDescription: string.Empty, singletonDescription: "Unknown C", collectionDescription: string.Empty);
|
||||
foreach (Tuple<string, A_Property> tuple in tuples.Value)
|
||||
{
|
||||
fileInfo = new FileInfo(Path.Combine(directoryInfoCollection[0].Replace("<>", "{}"), string.Concat(Path.GetFileNameWithoutExtension(tuple.Item1), ".json")));
|
||||
@ -204,8 +205,8 @@ public class G_Index : Shared.Models.Properties.IIndex, IIndex
|
||||
throw new Exception(string.Join(Environment.NewLine, parseExceptions));
|
||||
if (neededTuples.Any())
|
||||
throw new Exception();
|
||||
WriteGroup(configuration, outputResolution, indexInfoTuples);
|
||||
AppendTSV(configuration, outputResolution, filePropertiesKeyValuePairs);
|
||||
WriteGroup(configuration, model, predictorModel, outputResolution, indexInfoTuples);
|
||||
AppendTSV(configuration, model, predictorModel, outputResolution, filePropertiesKeyValuePairs);
|
||||
}
|
||||
|
||||
string Shared.Models.Stateless.Methods.IIndex.TestStatic_GetJson(string jsonFileFullName, FileInfo fileInfo) => throw new NotImplementedException();
|
||||
|
@ -9,7 +9,7 @@
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
},
|
||||
"MaxDegreeOfParallelism": 6,
|
||||
"MaxDegreeOfParallelism": 1,
|
||||
"Serilog": {
|
||||
"Using": [
|
||||
"Serilog.Sinks.Console",
|
||||
@ -52,14 +52,14 @@
|
||||
"Configuration": {
|
||||
"CheckJsonForDistanceResults": true,
|
||||
"CrossDirectoryMaxItemsInDistanceCollection": 7,
|
||||
"DateGroup": "2022-04-07",
|
||||
"DateGroup": "2022-07-24",
|
||||
"DistanceFactor": 8,
|
||||
"FileNameDirectorySeparator": ".Z.",
|
||||
"ForceMetadataLastWriteTimeToCreationTime": false,
|
||||
"ForcePropertyLastWriteTimeToCreationTime": false,
|
||||
"ForceResizeLastWriteTimeToCreationTime": false,
|
||||
"LoadOrCreateThenSaveDirectoryDistanceResults": true,
|
||||
"LoadOrCreateThenSaveDistanceResults": true,
|
||||
"LoadOrCreateThenSaveDirectoryDistanceResults": false,
|
||||
"LoadOrCreateThenSaveDistanceResults": false,
|
||||
"LoadOrCreateThenSaveImageFacesResults": true,
|
||||
"LoadOrCreateThenSaveIndex": false,
|
||||
"LocationConfidenceFactor": 2,
|
||||
@ -85,10 +85,11 @@
|
||||
"PropertiesChangedForProperty": false,
|
||||
"PropertiesChangedForResize": false,
|
||||
"Reverse": false,
|
||||
"RootDirectory": "C:/Tmp/phares/Pictures",
|
||||
"xRootDirectory": "C:/Tmp/phares/Pictures",
|
||||
"RootDirectory": "F:/Tmp/Phares/Compare/Images 2022-07-24 - 1539b2f974f07b6b5cbda8450faf0eec85d02eda - III",
|
||||
"SaveFullYearOfRandomFiles": true,
|
||||
"SaveResizedSubFiles": true,
|
||||
"SearchForAbandonedFilesFull": true,
|
||||
"SaveShortcuts": true,
|
||||
"SkipSearch": false,
|
||||
"TestDistanceResults": true,
|
||||
"WriteBitmapDataBytes": false,
|
||||
@ -96,12 +97,73 @@
|
||||
".gif",
|
||||
".GIF"
|
||||
],
|
||||
"OutputResolutions": [
|
||||
"JuliePhares": [
|
||||
"1500-01-16_00",
|
||||
"1500-01-19_00",
|
||||
"1500-01-20_00",
|
||||
"1500-01-21_00",
|
||||
"1500-01-25_00",
|
||||
"1500-01-26_00",
|
||||
"1500-01-27_00",
|
||||
"1500-02-13_00",
|
||||
"1500-02-17_00",
|
||||
"1500-02-24_00",
|
||||
"1500-02-25_00",
|
||||
"1500-04-03_00",
|
||||
"1500-04-06_00",
|
||||
"1500-04-19_00",
|
||||
"1500-05-03_00",
|
||||
"1500-05-18_00",
|
||||
"1500-05-28_00",
|
||||
"1500-06-16_00",
|
||||
"1500-06-26_00",
|
||||
"1500-06-27_00",
|
||||
"1500-07-07_00",
|
||||
"1500-07-16_00",
|
||||
"1720-09-30_05",
|
||||
"1500-07-26_00",
|
||||
"1500-08-03_00",
|
||||
"1500-08-23_00",
|
||||
"1500-08-24_00",
|
||||
"1500-09-16_00",
|
||||
"1500-09-21_00",
|
||||
"1500-09-28_00",
|
||||
"1500-10-14_00",
|
||||
"1500-11-07_00",
|
||||
"1500-11-09_00",
|
||||
"1720-09-28_20",
|
||||
"1501-01-08_00",
|
||||
"1501-01-12_00",
|
||||
"1501-01-13_00",
|
||||
"1501-01-30_00",
|
||||
"1501-03-09_00",
|
||||
"1501-03-14_00",
|
||||
"1501-03-22_00",
|
||||
"1501-04-07_00",
|
||||
"1501-04-10_00",
|
||||
"1501-04-19_00",
|
||||
"1501-05-06_00",
|
||||
"1956-09-19_00",
|
||||
"2012-09-17_00",
|
||||
"1998-05-21_00",
|
||||
"1960-03-01_00",
|
||||
"1976-03-08_00",
|
||||
"2007-09-07_00",
|
||||
"2000-04-07_00",
|
||||
"1980-01-17_00",
|
||||
"1958-01-30_00",
|
||||
"1976-01-05_00",
|
||||
"1982-05-02_00"
|
||||
],
|
||||
"xOutputResolutions": [
|
||||
"176 x 176",
|
||||
"256 x 256",
|
||||
"353 x 353",
|
||||
"1024 x 768"
|
||||
],
|
||||
"OutputResolutions": [
|
||||
"1376 x 768"
|
||||
],
|
||||
"PropertyContentCollectionFiles": [],
|
||||
"SaveFaceLandmarkForOutputResolutions": [
|
||||
"176 x 176",
|
||||
|
@ -52,7 +52,7 @@
|
||||
"Configuration": {
|
||||
"CheckJsonForDistanceResults": true,
|
||||
"CrossDirectoryMaxItemsInDistanceCollection": 7,
|
||||
"DateGroup": "2022-04-07",
|
||||
"DateGroup": "2022-07-24",
|
||||
"DistanceFactor": 8,
|
||||
"FileNameDirectorySeparator": ".Z.",
|
||||
"ForceMetadataLastWriteTimeToCreationTime": false,
|
||||
@ -88,7 +88,7 @@
|
||||
"RootDirectory": "E:/Images",
|
||||
"SaveFullYearOfRandomFiles": true,
|
||||
"SaveResizedSubFiles": true,
|
||||
"SearchForAbandonedFilesFull": false,
|
||||
"SaveShortcuts": true,
|
||||
"SkipSearch": false,
|
||||
"TestDistanceResults": true,
|
||||
"WriteBitmapDataBytes": false,
|
||||
|
@ -52,7 +52,7 @@
|
||||
"Configuration": {
|
||||
"CheckJsonForDistanceResults": true,
|
||||
"CrossDirectoryMaxItemsInDistanceCollection": 7,
|
||||
"DateGroup": "2022-04-07",
|
||||
"DateGroup": "2022-07-24",
|
||||
"DistanceFactor": 8,
|
||||
"FileNameDirectorySeparator": ".Z.",
|
||||
"ForceMetadataLastWriteTimeToCreationTime": false,
|
||||
@ -88,7 +88,7 @@
|
||||
"RootDirectory": "D:/Images",
|
||||
"SaveFullYearOfRandomFiles": true,
|
||||
"SaveResizedSubFiles": true,
|
||||
"SearchForAbandonedFilesFull": false,
|
||||
"SaveShortcuts": true,
|
||||
"SkipSearch": false,
|
||||
"TestDistanceResults": true,
|
||||
"WriteBitmapDataBytes": false,
|
||||
|
Reference in New Issue
Block a user