Closest is usable with
NamedDeterministicHashCodeIdAndFaceLocationIndex
This commit is contained in:
parent
e4f422cf7e
commit
004017b9dd
@ -418,7 +418,7 @@ public class DlibDotNet
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
int totalSeconds = (int)Math.Floor(new TimeSpan(DateTime.Now.Ticks - ticks).TotalSeconds);
|
||||||
string message = $"{container.R + 1:000}.{container.G} / {containersCount:000}) {filteredItems.Length:000} file(s) - {totalSeconds} total second(s) - {outputResolution} - {container.SourceDirectory}";
|
string message = $"{container.R:000}.{container.G} / {containersCount:000}) {filteredItems.Length:000} file(s) - {totalSeconds} total second(s) - {outputResolution} - {container.SourceDirectory}";
|
||||||
using (ProgressBar progressBar = new(filteredItems.Length, message, options))
|
using (ProgressBar progressBar = new(filteredItems.Length, message, options))
|
||||||
{
|
{
|
||||||
_ = Parallel.For(0, filteredItems.Length, parallelOptions, i =>
|
_ = Parallel.For(0, filteredItems.Length, parallelOptions, i =>
|
||||||
@ -438,15 +438,6 @@ public class DlibDotNet
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
#pragma warning disable
|
|
||||||
int[] ids = (from l in filteredItems where l.Property?.Id is not null select l.Property.Id.Value).ToArray();
|
|
||||||
#pragma warning restore
|
|
||||||
bool hasDuplicateId = ids.Length != ids.Distinct().Count();
|
|
||||||
if (hasDuplicateId)
|
|
||||||
{
|
|
||||||
if (hasDuplicateId)
|
|
||||||
{ }
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -575,6 +566,10 @@ public class DlibDotNet
|
|||||||
throw new NullReferenceException(nameof(_Log));
|
throw new NullReferenceException(nameof(_Log));
|
||||||
if (_AppSettings.MaxDegreeOfParallelism is null)
|
if (_AppSettings.MaxDegreeOfParallelism is null)
|
||||||
throw new NullReferenceException(nameof(_AppSettings.MaxDegreeOfParallelism));
|
throw new NullReferenceException(nameof(_AppSettings.MaxDegreeOfParallelism));
|
||||||
|
if (_Configuration.SaveResizedSubfiles is null)
|
||||||
|
throw new NullReferenceException(nameof(_Configuration.SaveResizedSubfiles));
|
||||||
|
int[] ids;
|
||||||
|
int distinctCount;
|
||||||
int exceptionCount;
|
int exceptionCount;
|
||||||
Item[] filteredItems;
|
Item[] filteredItems;
|
||||||
long ticks = DateTime.Now.Ticks;
|
long ticks = DateTime.Now.Ticks;
|
||||||
@ -617,7 +612,7 @@ public class DlibDotNet
|
|||||||
continue;
|
continue;
|
||||||
if (!_ArgZeroIsConfigurationRootDirectory && !container.SourceDirectory.StartsWith(argZero))
|
if (!_ArgZeroIsConfigurationRootDirectory && !container.SourceDirectory.StartsWith(argZero))
|
||||||
continue;
|
continue;
|
||||||
filteredItems = (from l in container.Items where l.ImageFileHolder is not null && l.ValidImageFormatExtension && !_Configuration.IgnoreExtensions.Contains(l.ImageFileHolder.ExtensionLowered) select l).ToArray();
|
filteredItems = (from l in container.Items where l.ImageFileHolder is not null && (l.Abandoned is null || !l.Abandoned.Value) && l.ValidImageFormatExtension && !_Configuration.IgnoreExtensions.Contains(l.ImageFileHolder.ExtensionLowered) select l).ToArray();
|
||||||
if (!filteredItems.Any())
|
if (!filteredItems.Any())
|
||||||
continue;
|
continue;
|
||||||
faceCollections.Clear();
|
faceCollections.Clear();
|
||||||
@ -635,27 +630,37 @@ public class DlibDotNet
|
|||||||
aResultsFullGroupDirectory,
|
aResultsFullGroupDirectory,
|
||||||
contentDescription: string.Empty,
|
contentDescription: string.Empty,
|
||||||
singletonDescription: "Properties for each image",
|
singletonDescription: "Properties for each image",
|
||||||
collectionDescription: string.Empty));
|
collectionDescription: string.Empty,
|
||||||
|
converted: false));
|
||||||
_Metadata.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
_Metadata.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||||
container.SourceDirectory,
|
container.SourceDirectory,
|
||||||
bResultsFullGroupDirectory,
|
bResultsFullGroupDirectory,
|
||||||
contentDescription: string.Empty,
|
contentDescription: string.Empty,
|
||||||
singletonDescription: "Metadata as key value pairs",
|
singletonDescription: "Metadata as key value pairs",
|
||||||
collectionDescription: string.Empty));
|
collectionDescription: string.Empty,
|
||||||
|
converted: true));
|
||||||
_Resize.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
_Resize.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||||
container.SourceDirectory,
|
container.SourceDirectory,
|
||||||
cResultsFullGroupDirectory,
|
cResultsFullGroupDirectory,
|
||||||
contentDescription: "Resized image",
|
contentDescription: "Resized image",
|
||||||
singletonDescription: "Resize dimensions for each resolution",
|
singletonDescription: "Resize dimensions for each resolution",
|
||||||
collectionDescription: string.Empty));
|
collectionDescription: string.Empty,
|
||||||
|
converted: true));
|
||||||
if (_Configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions.Contains(outputResolution))
|
if (_Configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions.Contains(outputResolution))
|
||||||
_Faces.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
_Faces.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(configuration,
|
||||||
container.SourceDirectory,
|
container.SourceDirectory,
|
||||||
dResultsFullGroupDirectory,
|
dResultsFullGroupDirectory,
|
||||||
contentDescription: "n png file(s) for each face found",
|
contentDescription: "n png file(s) for each face found",
|
||||||
singletonDescription: string.Empty,
|
singletonDescription: string.Empty,
|
||||||
collectionDescription: "For each image a json file with all faces found"));
|
collectionDescription: "For each image a json file with all faces found",
|
||||||
|
converted: true));
|
||||||
exceptionCount = FullParallelWork(ticks, propertyLogic, outputResolution, bResultsFullGroupDirectory, cResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory, sourceDirectoryChanges, propertyFileHolderCollection, propertyCollection, metadataCollection, resizeKeyValuePairs, faceCollections, containers.Count, container, filteredItems);
|
exceptionCount = FullParallelWork(ticks, propertyLogic, outputResolution, bResultsFullGroupDirectory, cResultsFullGroupDirectory, dResultsFullGroupDirectory, d2ResultsFullGroupDirectory, sourceDirectoryChanges, propertyFileHolderCollection, propertyCollection, metadataCollection, resizeKeyValuePairs, faceCollections, containers.Count, container, filteredItems);
|
||||||
|
#pragma warning disable
|
||||||
|
ids = (from l in filteredItems where l.Property?.Id is not null select l.Property.Id.Value).ToArray();
|
||||||
|
#pragma warning restore
|
||||||
|
distinctCount = ids.Distinct().Count();
|
||||||
|
if (ids.Length != distinctCount)
|
||||||
|
_Log.Information($"{ids.Length} != {distinctCount} <{container.SourceDirectory}>");
|
||||||
if (metadataCollection.Count != filteredItems.Length || propertyCollection.Count != filteredItems.Length || resizeKeyValuePairs.Count != filteredItems.Length || faceCollections.Count != filteredItems.Length)
|
if (metadataCollection.Count != filteredItems.Length || propertyCollection.Count != filteredItems.Length || resizeKeyValuePairs.Count != filteredItems.Length || faceCollections.Count != filteredItems.Length)
|
||||||
throw new Exception("Counts don't match!");
|
throw new Exception("Counts don't match!");
|
||||||
if (exceptionCount != 0)
|
if (exceptionCount != 0)
|
||||||
@ -664,7 +669,7 @@ public class DlibDotNet
|
|||||||
WriteGroup(configuration, propertyLogic, propertyCollection, metadataCollection, faceCollections, resizeKeyValuePairs, container.SourceDirectory, outputResolution, filteredItems);
|
WriteGroup(configuration, propertyLogic, propertyCollection, metadataCollection, faceCollections, resizeKeyValuePairs, container.SourceDirectory, outputResolution, filteredItems);
|
||||||
if (_ArgZeroIsConfigurationRootDirectory && exceptionCount == 0 && outputResolution == _Configuration.OutputResolutions[0])
|
if (_ArgZeroIsConfigurationRootDirectory && exceptionCount == 0 && outputResolution == _Configuration.OutputResolutions[0])
|
||||||
propertyLogic.AddToPropertyLogicAllCollection(filteredItems);
|
propertyLogic.AddToPropertyLogicAllCollection(filteredItems);
|
||||||
if (_ArgZeroIsConfigurationRootDirectory && exceptionCount == 0 && propertyLogic.NamedFaceInfoDeterministicHashCodeIndices.Any())
|
if (_ArgZeroIsConfigurationRootDirectory && exceptionCount == 0 && propertyLogic.NamedFaceInfoDeterministicHashCodeIds.Any())
|
||||||
{
|
{
|
||||||
if (outputResolution == _Configuration.OutputResolutions[0] || _Configuration.SaveShortcutsForOutputResolutions.Contains(outputResolution))
|
if (outputResolution == _Configuration.OutputResolutions[0] || _Configuration.SaveShortcutsForOutputResolutions.Contains(outputResolution))
|
||||||
{
|
{
|
||||||
@ -674,6 +679,10 @@ public class DlibDotNet
|
|||||||
// break;
|
// break;
|
||||||
// if (isSilent && container.SourceDirectory.EndsWith("zzz =2014.4 Winter Tracy Pictures")) // 30#.2
|
// if (isSilent && container.SourceDirectory.EndsWith("zzz =2014.4 Winter Tracy Pictures")) // 30#.2
|
||||||
// break;
|
// break;
|
||||||
|
// if (isSilent && container.SourceDirectory.EndsWith("=2009.0 Winter Logan Michael")) //34#.2
|
||||||
|
// break;
|
||||||
|
// if (isSilent && container.SourceDirectory.EndsWith("Animal Kingdom")) //35#.3
|
||||||
|
// break;
|
||||||
// if (isSilent && container.SourceDirectory.EndsWith("Texas 2015")) //46#.4
|
// if (isSilent && container.SourceDirectory.EndsWith("Texas 2015")) //46#.4
|
||||||
// break;
|
// break;
|
||||||
for (int i = 0; i < faceCollections.Count; i++)
|
for (int i = 0; i < faceCollections.Count; i++)
|
||||||
@ -685,10 +694,6 @@ public class DlibDotNet
|
|||||||
}
|
}
|
||||||
if (exceptionCount == 0 && _Configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions.Contains(outputResolution))
|
if (exceptionCount == 0 && _Configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions.Contains(outputResolution))
|
||||||
_Distance.LoadOrCreateThenSaveDistanceResultsForOutputResolutions(configuration, eResultsFullGroupDirectory, container.SourceDirectory, outputResolution, sourceDirectoryChanges, filteredItems, faceCollections);
|
_Distance.LoadOrCreateThenSaveDistanceResultsForOutputResolutions(configuration, eResultsFullGroupDirectory, container.SourceDirectory, outputResolution, sourceDirectoryChanges, filteredItems, faceCollections);
|
||||||
if (_Resize.AngleBracketCollection.Any())
|
|
||||||
_ = Property.Models.Stateless.IPath.DeleteEmptyDirectories(_Resize.AngleBracketCollection[0].Replace("<>", "()"));
|
|
||||||
if (_Faces.AngleBracketCollection.Any())
|
|
||||||
_ = Property.Models.Stateless.IPath.DeleteEmptyDirectories(_Faces.AngleBracketCollection[0].Replace("<>", "()"));
|
|
||||||
if (Directory.GetFiles(propertyRoot, "*.txt", SearchOption.TopDirectoryOnly).Any())
|
if (Directory.GetFiles(propertyRoot, "*.txt", SearchOption.TopDirectoryOnly).Any())
|
||||||
{
|
{
|
||||||
for (int y = 0; y < int.MaxValue; y++)
|
for (int y = 0; y < int.MaxValue; y++)
|
||||||
@ -700,10 +705,21 @@ public class DlibDotNet
|
|||||||
_Log.Information(". . .");
|
_Log.Information(". . .");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ = Property.Models.Stateless.IPath.DeleteEmptyDirectories(Path.Combine(aResultsFullGroupDirectory, "{}"));
|
||||||
|
_ = Property.Models.Stateless.IPath.DeleteEmptyDirectories(Path.Combine(bResultsFullGroupDirectory, "{}"));
|
||||||
|
_ = Property.Models.Stateless.IPath.DeleteEmptyDirectories(Path.Combine(cResultsFullGroupDirectory, "{}"));
|
||||||
|
if (_Configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions.Contains(outputResolution))
|
||||||
|
_ = Property.Models.Stateless.IPath.DeleteEmptyDirectories(Path.Combine(dResultsFullGroupDirectory, "[]"));
|
||||||
|
if (_Configuration.LoadOrCreateThenSaveDistanceResultsForOutputResolutions.Contains(outputResolution))
|
||||||
|
_ = Property.Models.Stateless.IPath.DeleteEmptyDirectories(Path.Combine(eResultsFullGroupDirectory, "[]"));
|
||||||
|
if (_Configuration.LoadOrCreateThenSaveDirectoryDistanceResultsForOutputResolutions.Contains(outputResolution))
|
||||||
|
_ = Property.Models.Stateless.IPath.DeleteEmptyDirectories(Path.Combine(eResultsFullGroupDirectory, "[]"));
|
||||||
|
if (_Configuration.SaveFaceLandmarkForOutputResolutions.Contains(outputResolution))
|
||||||
|
_ = Property.Models.Stateless.IPath.DeleteEmptyDirectories(Path.Combine(d2ResultsFullGroupDirectory, "[]"));
|
||||||
if (_ArgZeroIsConfigurationRootDirectory && outputResolution == _Configuration.OutputResolutions[0])
|
if (_ArgZeroIsConfigurationRootDirectory && outputResolution == _Configuration.OutputResolutions[0])
|
||||||
{
|
{
|
||||||
propertyLogic.SaveAllCollection();
|
propertyLogic.SaveAllCollection();
|
||||||
if (propertyLogic.NamedFaceInfoDeterministicHashCodeIndices.Any())
|
if (_Configuration.SaveResizedSubfiles.Value && propertyLogic.NamedFaceInfoDeterministicHashCodeIds.Any())
|
||||||
{
|
{
|
||||||
string dFacesContentDirectory;
|
string dFacesContentDirectory;
|
||||||
string eDistanceContentDirectory;
|
string eDistanceContentDirectory;
|
||||||
@ -715,9 +731,13 @@ public class DlibDotNet
|
|||||||
eDistanceCollectionDirectory = Path.Combine(eResultsFullGroupDirectory, $"[{ticks}]");
|
eDistanceCollectionDirectory = Path.Combine(eResultsFullGroupDirectory, $"[{ticks}]");
|
||||||
List<(DateTime, bool?, PersonBirthday, FaceRecognitionDotNet.FaceEncoding[])> collection;
|
List<(DateTime, bool?, PersonBirthday, FaceRecognitionDotNet.FaceEncoding[])> collection;
|
||||||
collection = E_Distance.ParallelWork(_AppSettings.MaxDegreeOfParallelism.Value, argZero, containers);
|
collection = E_Distance.ParallelWork(_AppSettings.MaxDegreeOfParallelism.Value, argZero, containers);
|
||||||
|
_ = LogDelta(ticks, nameof(E_Distance.ParallelWork));
|
||||||
E_Distance.SavePropertyHolders(argZero, containers, zPropertyHolderSingletonDirectory);
|
E_Distance.SavePropertyHolders(argZero, containers, zPropertyHolderSingletonDirectory);
|
||||||
|
_ = LogDelta(ticks, nameof(E_Distance.SavePropertyHolders));
|
||||||
E_Distance.SaveThreeSigmaFaceEncodings(collection, peopleCollection, eDistanceCollectionDirectory);
|
E_Distance.SaveThreeSigmaFaceEncodings(collection, peopleCollection, eDistanceCollectionDirectory);
|
||||||
E_Distance.SaveClosest(argZero, containers, peopleCollection, eDistanceContentDirectory, dFacesContentDirectory);
|
_ = LogDelta(ticks, nameof(E_Distance.SaveThreeSigmaFaceEncodings));
|
||||||
|
E_Distance.SaveClosest(argZero, containers, peopleCollection, propertyLogic, eDistanceContentDirectory, dFacesContentDirectory);
|
||||||
|
_ = LogDelta(ticks, nameof(E_Distance.SaveClosest));
|
||||||
}
|
}
|
||||||
if (!_Configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions.Any())
|
if (!_Configuration.LoadOrCreateThenSaveImageFacesResultsForOutputResolutions.Any())
|
||||||
break;
|
break;
|
||||||
|
@ -128,7 +128,8 @@ internal class D2_FaceLandmarks
|
|||||||
d2ResultsFullGroupDirectory,
|
d2ResultsFullGroupDirectory,
|
||||||
contentDescription: "n x 2 png file(s) for each face found",
|
contentDescription: "n x 2 png file(s) for each face found",
|
||||||
singletonDescription: string.Empty,
|
singletonDescription: string.Empty,
|
||||||
collectionDescription: string.Empty));
|
collectionDescription: string.Empty,
|
||||||
|
converted: false));
|
||||||
string facesDirectory = Path.Combine(angleBracketCollection[0].Replace("<>", "()"), item.ImageFileHolder.NameWithoutExtension);
|
string facesDirectory = Path.Combine(angleBracketCollection[0].Replace("<>", "()"), item.ImageFileHolder.NameWithoutExtension);
|
||||||
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata), nameof(C_Resize), nameof(D_Face) };
|
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata), nameof(C_Resize), nameof(D_Face) };
|
||||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||||
|
@ -429,21 +429,17 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
|||||||
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata), nameof(C_Resize) };
|
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata), nameof(C_Resize) };
|
||||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||||
string facesDirectory = Path.Combine(AngleBracketCollection[0].Replace("<>", "()"), item.ImageFileHolder.NameWithoutExtension);
|
string facesDirectory = Path.Combine(AngleBracketCollection[0].Replace("<>", "()"), item.ImageFileHolder.NameWithoutExtension);
|
||||||
FileInfo fileInfo = new(Path.Combine(AngleBracketCollection[0].Replace("<>", "[]"), $"{item.ImageFileHolder.NameWithoutExtension}.json"));
|
string usingRelativePath = Path.Combine(AngleBracketCollection[0].Replace("<>", "[]"), $"{item.ImageFileHolder.NameWithoutExtension}.json");
|
||||||
string dCollectionFile = Path.Combine(dResultsFullGroupDirectory, "[]", "_ _ _", $"{item.Property.Id.Value}{item.ImageFileHolder.ExtensionLowered}.json");
|
string dCollectionFile = Path.Combine(dResultsFullGroupDirectory, "[]", Property.Models.Stateless.IResult.AllInOne, $"{item.Property.Id.Value}{item.ImageFileHolder.ExtensionLowered}.json");
|
||||||
if (fileInfo.Exists)
|
FileInfo fileInfo = new(dCollectionFile);
|
||||||
|
if (!fileInfo.Exists)
|
||||||
{
|
{
|
||||||
if (!File.Exists(dCollectionFile))
|
if (File.Exists(usingRelativePath))
|
||||||
{
|
{
|
||||||
fileInfo.MoveTo(dCollectionFile);
|
File.Move(usingRelativePath, fileInfo.FullName);
|
||||||
fileInfo = new(dCollectionFile);
|
fileInfo.Refresh();
|
||||||
}
|
}
|
||||||
}
|
if (!fileInfo.Exists)
|
||||||
else
|
|
||||||
{
|
|
||||||
if (File.Exists(dCollectionFile))
|
|
||||||
fileInfo = new(dCollectionFile);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (fileInfo.Directory?.Parent is null)
|
if (fileInfo.Directory?.Parent is null)
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
@ -516,8 +512,6 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
|||||||
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
||||||
if (item.ResizedFileHolder is null)
|
if (item.ResizedFileHolder is null)
|
||||||
throw new NullReferenceException(nameof(item.ResizedFileHolder));
|
throw new NullReferenceException(nameof(item.ResizedFileHolder));
|
||||||
if (string.IsNullOrEmpty(dResultsFullGroupDirectory))
|
|
||||||
throw new NullReferenceException(nameof(dResultsFullGroupDirectory));
|
|
||||||
FileInfo fileInfo;
|
FileInfo fileInfo;
|
||||||
bool check = false;
|
bool check = false;
|
||||||
string parentCheck;
|
string parentCheck;
|
||||||
|
@ -6,6 +6,7 @@ using View_by_Distance.Metadata.Models;
|
|||||||
using View_by_Distance.Property.Models;
|
using View_by_Distance.Property.Models;
|
||||||
using View_by_Distance.Resize.Models;
|
using View_by_Distance.Resize.Models;
|
||||||
using View_by_Distance.Shared.Models.Stateless;
|
using View_by_Distance.Shared.Models.Stateless;
|
||||||
|
using WindowsShortcutFactory;
|
||||||
|
|
||||||
namespace View_by_Distance.Instance.Models;
|
namespace View_by_Distance.Instance.Models;
|
||||||
|
|
||||||
@ -198,11 +199,13 @@ internal class E_Distance
|
|||||||
throw new NullReferenceException(nameof(_Configuration.CheckJsonForDistanceResults));
|
throw new NullReferenceException(nameof(_Configuration.CheckJsonForDistanceResults));
|
||||||
if (_Configuration.PropertiesChangedForDistance is null)
|
if (_Configuration.PropertiesChangedForDistance is null)
|
||||||
throw new NullReferenceException(nameof(_Configuration.PropertiesChangedForDistance));
|
throw new NullReferenceException(nameof(_Configuration.PropertiesChangedForDistance));
|
||||||
|
Item item;
|
||||||
string json;
|
string json;
|
||||||
bool check = false;
|
bool check = false;
|
||||||
string parentCheck;
|
string parentCheck;
|
||||||
FileHolder? fileHolder;
|
string usingRelativePath;
|
||||||
DateTime? dateTime = null;
|
DateTime? dateTime = null;
|
||||||
|
string dCollectionDirectory;
|
||||||
FileInfo[] fileInfoCollection;
|
FileInfo[] fileInfoCollection;
|
||||||
bool updateDateWhenMatches = false;
|
bool updateDateWhenMatches = false;
|
||||||
List<string[]> directories = new();
|
List<string[]> directories = new();
|
||||||
@ -216,14 +219,24 @@ internal class E_Distance
|
|||||||
eResultsFullGroupDirectory,
|
eResultsFullGroupDirectory,
|
||||||
contentDescription: ".tvs File",
|
contentDescription: ".tvs File",
|
||||||
singletonDescription: string.Empty,
|
singletonDescription: string.Empty,
|
||||||
collectionDescription: "n json file(s) for each face found (one to many)");
|
collectionDescription: "n json file(s) for each face found (one to many)",
|
||||||
|
converted: true);
|
||||||
for (int i = 0; i < filteredItems.Length; i++)
|
for (int i = 0; i < filteredItems.Length; i++)
|
||||||
{
|
{
|
||||||
fileHolder = filteredItems[i].ImageFileHolder;
|
item = filteredItems[i];
|
||||||
if (fileHolder is null)
|
if (item.ImageFileHolder is null || item.Property?.Id is null)
|
||||||
continue;
|
continue;
|
||||||
directoryInfo = new System.IO.DirectoryInfo(Path.Combine(directoryInfoCollection[0].Replace("<>", "[]"), fileHolder.NameWithoutExtension));
|
usingRelativePath = Path.Combine(directoryInfoCollection[0].Replace("<>", "[]"), item.ImageFileHolder.NameWithoutExtension);
|
||||||
|
dCollectionDirectory = Path.Combine(eResultsFullGroupDirectory, "[]", Property.Models.Stateless.IResult.AllInOne, $"{item.Property.Id.Value}{item.ImageFileHolder.ExtensionLowered}");
|
||||||
|
directoryInfo = new System.IO.DirectoryInfo(dCollectionDirectory);
|
||||||
if (!directoryInfo.Exists)
|
if (!directoryInfo.Exists)
|
||||||
|
{
|
||||||
|
if (Directory.Exists(usingRelativePath))
|
||||||
|
{
|
||||||
|
Directory.Move(usingRelativePath, directoryInfo.FullName);
|
||||||
|
directoryInfo.Refresh();
|
||||||
|
}
|
||||||
|
if (!Directory.Exists(dCollectionDirectory))
|
||||||
{
|
{
|
||||||
if (directoryInfo.Parent?.Parent is null)
|
if (directoryInfo.Parent?.Parent is null)
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
@ -235,7 +248,8 @@ internal class E_Distance
|
|||||||
Directory.Delete(parentCheck);
|
Directory.Delete(parentCheck);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tvsDirectoryInfo = new System.IO.DirectoryInfo(Path.Combine(directoryInfoCollection[0].Replace("<>", "()"), fileHolder.NameWithoutExtension));
|
}
|
||||||
|
tvsDirectoryInfo = new System.IO.DirectoryInfo(Path.Combine(directoryInfoCollection[0].Replace("<>", "()"), item.ImageFileHolder.NameWithoutExtension));
|
||||||
directories.Add(new string[] { directoryInfo.FullName, tvsDirectoryInfo.FullName });
|
directories.Add(new string[] { directoryInfo.FullName, tvsDirectoryInfo.FullName });
|
||||||
if (_Configuration.CheckJsonForDistanceResults.Value && directoryInfo.Exists)
|
if (_Configuration.CheckJsonForDistanceResults.Value && directoryInfo.Exists)
|
||||||
{
|
{
|
||||||
@ -517,7 +531,7 @@ internal class E_Distance
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Closest? GetClosestParallelFor(float maxMinimum, DateTime minimumDateTime, bool? isWrongYear, Shared.Models.Properties.IFace face, FaceEncoding faceEncoding, (DateTime MinimumDateTime, bool? IsWrongYear, Shared.Models.PersonBirthday PersonBirthday, FaceEncoding[] FaceEncodings) tuple)
|
private static Closest? GetClosestParallelFor(DateTime minimumDateTime, bool? isWrongYear, Shared.Models.Properties.IFace face, FaceEncoding faceEncoding, (DateTime MinimumDateTime, bool? IsWrongYear, Shared.Models.PersonBirthday PersonBirthday, FaceEncoding[] FaceEncodings) tuple)
|
||||||
{
|
{
|
||||||
Closest? result;
|
Closest? result;
|
||||||
if (isWrongYear.HasValue && !isWrongYear.Value && minimumDateTime < tuple.PersonBirthday.Value)
|
if (isWrongYear.HasValue && !isWrongYear.Value && minimumDateTime < tuple.PersonBirthday.Value)
|
||||||
@ -526,19 +540,20 @@ internal class E_Distance
|
|||||||
{
|
{
|
||||||
List<double> faceDistances = FaceRecognition.FaceDistances(tuple.FaceEncodings, faceEncoding);
|
List<double> faceDistances = FaceRecognition.FaceDistances(tuple.FaceEncodings, faceEncoding);
|
||||||
result = new(face.LocationIndex, tuple.MinimumDateTime, tuple.IsWrongYear, tuple.PersonBirthday, faceDistances);
|
result = new(face.LocationIndex, tuple.MinimumDateTime, tuple.IsWrongYear, tuple.PersonBirthday, faceDistances);
|
||||||
if (result.Minimum > maxMinimum)
|
if (result.Minimum > Closest.MaximumMinimum)
|
||||||
result = null;
|
result = null;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Closest> GetClosestCollection(int maxDegreeOfParallelism, List<(DateTime, bool?, Shared.Models.PersonBirthday, FaceEncoding[])> collection, float maxMinimum, DateTime itemMinimumDateTime, bool? itemIsWrongYear, Shared.Models.Properties.IFace face)
|
private static Closest[] GetClosestCollection(int maxDegreeOfParallelism, List<(DateTime, bool?, Shared.Models.PersonBirthday, FaceEncoding[])> collection, DateTime itemMinimumDateTime, bool? itemIsWrongYear, Shared.Models.Properties.IFace face)
|
||||||
{
|
{
|
||||||
List<Closest> results;
|
Closest[] results;
|
||||||
|
List<Closest> closestCollection;
|
||||||
FaceEncoding faceEncoding = FaceRecognition.LoadFaceEncoding(face.FaceEncoding.RawEncoding);
|
FaceEncoding faceEncoding = FaceRecognition.LoadFaceEncoding(face.FaceEncoding.RawEncoding);
|
||||||
if (maxDegreeOfParallelism == 1)
|
if (maxDegreeOfParallelism == 1)
|
||||||
{
|
{
|
||||||
results = new();
|
closestCollection = new();
|
||||||
Closest closest;
|
Closest closest;
|
||||||
List<double> faceDistances;
|
List<double> faceDistances;
|
||||||
foreach ((DateTime minimumDateTime, bool? isWrongYear, Shared.Models.PersonBirthday personBirthday, FaceEncoding[] faceEncodings) in collection)
|
foreach ((DateTime minimumDateTime, bool? isWrongYear, Shared.Models.PersonBirthday personBirthday, FaceEncoding[] faceEncodings) in collection)
|
||||||
@ -547,35 +562,36 @@ internal class E_Distance
|
|||||||
continue;
|
continue;
|
||||||
faceDistances = FaceRecognition.FaceDistances(faceEncodings, faceEncoding);
|
faceDistances = FaceRecognition.FaceDistances(faceEncodings, faceEncoding);
|
||||||
closest = new(face.LocationIndex, minimumDateTime, isWrongYear, personBirthday, faceDistances);
|
closest = new(face.LocationIndex, minimumDateTime, isWrongYear, personBirthday, faceDistances);
|
||||||
if (closest.Minimum > maxMinimum)
|
if (closest.Minimum > Closest.MaximumMinimum)
|
||||||
continue;
|
continue;
|
||||||
results.Add(closest);
|
closestCollection.Add(closest);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
results = new();
|
closestCollection = new();
|
||||||
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = maxDegreeOfParallelism };
|
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = maxDegreeOfParallelism };
|
||||||
_ = Parallel.For(0, collection.Count, parallelOptions, i =>
|
_ = Parallel.For(0, collection.Count, parallelOptions, i =>
|
||||||
{
|
{
|
||||||
Closest? closest = GetClosestParallelFor(maxMinimum, itemMinimumDateTime, itemIsWrongYear, face, faceEncoding, collection[i]);
|
Closest? closest = GetClosestParallelFor(itemMinimumDateTime, itemIsWrongYear, face, faceEncoding, collection[i]);
|
||||||
if (closest is not null)
|
if (closest is not null)
|
||||||
{
|
{
|
||||||
lock (results)
|
lock (closestCollection)
|
||||||
results.Add(closest);
|
closestCollection.Add(closest);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
results = Closest.Get(closestCollection);
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void AddClosest(int maxDegreeOfParallelism, string argZero, List<Container> containers, List<(DateTime, bool?, Shared.Models.PersonBirthday, FaceEncoding[])> collection, bool skipIsWrongYear, int maxPer, float maxMinimum)
|
private static void AddClosest(int maxDegreeOfParallelism, string argZero, List<Container> containers, List<(DateTime, bool?, Shared.Models.PersonBirthday, FaceEncoding[])> collection)
|
||||||
{
|
{
|
||||||
string key;
|
string key;
|
||||||
Closest closest;
|
Closest closest;
|
||||||
bool? itemIsWrongYear;
|
bool? itemIsWrongYear;
|
||||||
|
Closest[] closestCollection;
|
||||||
DateTime? itemMinimumDateTime;
|
DateTime? itemMinimumDateTime;
|
||||||
List<Closest> closestCollection;
|
|
||||||
Shared.Models.Properties.IFace face;
|
Shared.Models.Properties.IFace face;
|
||||||
Dictionary<string, int> results = new();
|
Dictionary<string, int> results = new();
|
||||||
foreach (Container container in containers)
|
foreach (Container container in containers)
|
||||||
@ -592,7 +608,7 @@ internal class E_Distance
|
|||||||
if (itemMinimumDateTime is null)
|
if (itemMinimumDateTime is null)
|
||||||
continue;
|
continue;
|
||||||
(itemIsWrongYear, _) = item.IsWrongYear();
|
(itemIsWrongYear, _) = item.IsWrongYear();
|
||||||
if (skipIsWrongYear && itemIsWrongYear.HasValue && itemIsWrongYear.Value)
|
if (Closest.SkipIsWrongYear && itemIsWrongYear.HasValue && itemIsWrongYear.Value)
|
||||||
continue;
|
continue;
|
||||||
item.Closest.Clear();
|
item.Closest.Clear();
|
||||||
for (int i = 0; i < item.Faces.Count; i++)
|
for (int i = 0; i < item.Faces.Count; i++)
|
||||||
@ -602,19 +618,21 @@ internal class E_Distance
|
|||||||
item.Closest.Add(closest);
|
item.Closest.Add(closest);
|
||||||
if (!face.Populated)
|
if (!face.Populated)
|
||||||
continue;
|
continue;
|
||||||
closestCollection = GetClosestCollection(maxDegreeOfParallelism, collection, maxMinimum, itemMinimumDateTime.Value, itemIsWrongYear, face);
|
closestCollection = GetClosestCollection(maxDegreeOfParallelism, collection, itemMinimumDateTime.Value, itemIsWrongYear, face);
|
||||||
if (!closestCollection.Any())
|
for (int j = 0; j < closestCollection.Length; j++)
|
||||||
continue;
|
{
|
||||||
closest = Closest.Get(closestCollection);
|
closest = closestCollection[j];
|
||||||
if (closest.PersonBirthday is null)
|
if (closest.PersonBirthday is null)
|
||||||
continue;
|
continue;
|
||||||
key = Item.GetKey(closest.MinimumDateTime, closest.IsWrongYear, closest.PersonBirthday);
|
key = Item.GetKey(closest.MinimumDateTime, closest.IsWrongYear, closest.PersonBirthday);
|
||||||
if (!results.ContainsKey(key))
|
if (!results.ContainsKey(key))
|
||||||
results.Add(key, 0);
|
results.Add(key, 0);
|
||||||
else if (results[key] > maxPer)
|
else if (results[key] > Closest.MaximumPer)
|
||||||
continue;
|
continue;
|
||||||
results[key] += 1;
|
results[key] += 1;
|
||||||
item.Closest[0] = closest;
|
item.Closest[0] = closest;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -623,12 +641,9 @@ internal class E_Distance
|
|||||||
internal static List<(DateTime, bool?, Shared.Models.PersonBirthday, FaceEncoding[])> ParallelWork(int maxDegreeOfParallelism, string argZero, List<Container> containers)
|
internal static List<(DateTime, bool?, Shared.Models.PersonBirthday, FaceEncoding[])> ParallelWork(int maxDegreeOfParallelism, string argZero, List<Container> containers)
|
||||||
{
|
{
|
||||||
List<(DateTime, bool?, Shared.Models.PersonBirthday, FaceEncoding[])> results;
|
List<(DateTime, bool?, Shared.Models.PersonBirthday, FaceEncoding[])> results;
|
||||||
const int maxPer = 5;
|
|
||||||
const float maxMinimum = 0.50f;
|
|
||||||
const bool skipIsWrongYear = true;
|
|
||||||
Dictionary<string, List<(DateTime, bool?, Shared.Models.PersonBirthday, Shared.Models.Properties.IFace)>> keyValuePairs = Item.GetKeyValuePairs(argZero, containers);
|
Dictionary<string, List<(DateTime, bool?, Shared.Models.PersonBirthday, Shared.Models.Properties.IFace)>> keyValuePairs = Item.GetKeyValuePairs(argZero, containers);
|
||||||
results = GetThreeSigmaFaceEncodings(maxDegreeOfParallelism, keyValuePairs);
|
results = GetThreeSigmaFaceEncodings(maxDegreeOfParallelism, keyValuePairs);
|
||||||
AddClosest(maxDegreeOfParallelism, argZero, containers, results, skipIsWrongYear, maxPer, maxMinimum);
|
AddClosest(maxDegreeOfParallelism, argZero, containers, results);
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -692,17 +707,21 @@ internal class E_Distance
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void SaveClosest(string argZero, List<Container> containers, Dictionary<string, List<Shared.Models.Person>> peopleCollection, string eDistanceContentDirectory, string dFacesContentDirectory)
|
internal static List<(FileHolder? resizedFileHolder, string directory, FileInfo? faceFileInfo, string checkFile, string shortcutFile)> GetClosest(string argZero, List<Container> containers, Dictionary<string, List<Shared.Models.Person>> peopleCollection, PropertyLogic propertyLogic, string eDistanceContentDirectory, string dFacesContentDirectory)
|
||||||
{
|
{
|
||||||
string copyFile;
|
List<(FileHolder?, string, FileInfo?, string, string)> results = new();
|
||||||
string checkFile;
|
string checkFile;
|
||||||
string directory;
|
string directory;
|
||||||
string personKey;
|
string personKey;
|
||||||
|
string personName;
|
||||||
|
string shortcutFile;
|
||||||
|
FileInfo faceFileInfo;
|
||||||
string? directoryName;
|
string? directoryName;
|
||||||
string facesDirectory;
|
string facesDirectory;
|
||||||
string faceFullFileName;
|
string personDirectory;
|
||||||
Shared.Models.Person person;
|
Shared.Models.Person person;
|
||||||
const string facePopulatedKey = "Closest";
|
const string facePopulatedKey = "Closest";
|
||||||
|
string deterministicHashCodeIdAndFaceLocationIndex;
|
||||||
const string pattern = @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]";
|
const string pattern = @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]";
|
||||||
foreach (Container container in containers)
|
foreach (Container container in containers)
|
||||||
{
|
{
|
||||||
@ -723,30 +742,72 @@ internal class E_Distance
|
|||||||
{
|
{
|
||||||
if (closest.Average is null || closest.FaceLocationIndex is null || closest.PersonBirthday is null)
|
if (closest.Average is null || closest.FaceLocationIndex is null || closest.PersonBirthday is null)
|
||||||
continue;
|
continue;
|
||||||
|
deterministicHashCodeIdAndFaceLocationIndex = $"{closest.FaceLocationIndex.Value} - {item.Property.Id.Value}";
|
||||||
|
if (propertyLogic.NamedDeterministicHashCodeIdAndFaceLocationIndex.Contains(deterministicHashCodeIdAndFaceLocationIndex))
|
||||||
|
continue;
|
||||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(closest.PersonBirthday);
|
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(closest.PersonBirthday);
|
||||||
directory = Item.GetDirectory(eDistanceContentDirectory, facePopulatedKey, closest.MinimumDateTime, closest.IsWrongYear, closest.PersonBirthday, personKey);
|
directory = Item.GetDirectory(eDistanceContentDirectory, facePopulatedKey, closest.MinimumDateTime, closest.IsWrongYear, closest.PersonBirthday, personKey);
|
||||||
if (!Directory.Exists(directory))
|
|
||||||
_ = Directory.CreateDirectory(directory);
|
|
||||||
// checkFile = Path.Combine(directory, item.ImageFileHolder.Name);
|
// checkFile = Path.Combine(directory, item.ImageFileHolder.Name);
|
||||||
checkFile = Path.Combine(directory, $"{closest.FaceLocationIndex.Value} - {item.Property.Id.Value}{item.ImageFileHolder.ExtensionLowered}");
|
if (!peopleCollection.ContainsKey(personKey))
|
||||||
if (peopleCollection.ContainsKey(personKey))
|
personDirectory = string.Empty;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
person = peopleCollection[personKey][0];
|
person = peopleCollection[personKey][0];
|
||||||
directory = Path.Combine(directory, Regex.Replace(Shared.Models.Stateless.Methods.IPersonName.GetFullName(person.Name), pattern, string.Empty));
|
personName = Shared.Models.Stateless.Methods.IPersonName.GetFullName(person.Name);
|
||||||
|
personDirectory = Path.Combine(directory, Regex.Replace(personName, pattern, string.Empty));
|
||||||
|
results.Add(new(null, personDirectory, null, string.Empty, string.Empty));
|
||||||
|
}
|
||||||
|
facesDirectory = string.Concat(dFacesContentDirectory, Path.Combine(directoryName, item.ImageFileHolder.NameWithoutExtension));
|
||||||
|
faceFileInfo = new(Path.Combine(facesDirectory, $"{closest.FaceLocationIndex.Value} - {item.ImageFileHolder.NameWithoutExtension}.png"));
|
||||||
|
checkFile = Path.Combine(directory, $"{deterministicHashCodeIdAndFaceLocationIndex}{item.ImageFileHolder.ExtensionLowered}");
|
||||||
|
if (string.IsNullOrEmpty(personDirectory))
|
||||||
|
shortcutFile = string.Empty;
|
||||||
|
else
|
||||||
|
shortcutFile = Path.Combine(personDirectory, $"{deterministicHashCodeIdAndFaceLocationIndex}{item.ImageFileHolder.ExtensionLowered}.lnk");
|
||||||
|
results.Add(new(item.ResizedFileHolder, directory, faceFileInfo, checkFile, shortcutFile));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal static void SaveClosest(string argZero, List<Container> containers, Dictionary<string, List<Shared.Models.Person>> peopleCollection, PropertyLogic propertyLogic, string eDistanceContentDirectory, string dFacesContentDirectory)
|
||||||
|
{
|
||||||
|
WindowsShortcut windowsShortcut;
|
||||||
|
List<(FileHolder? resizedFileHolder, string directory, FileInfo? faceFileInfo, string checkFile, string shortcutFile)> collection = GetClosest(argZero, containers, peopleCollection, propertyLogic, eDistanceContentDirectory, dFacesContentDirectory);
|
||||||
|
string[] directories = (from l in collection select l.directory).Distinct().ToArray();
|
||||||
|
foreach (string directory in directories)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(directory))
|
||||||
|
continue;
|
||||||
if (!Directory.Exists(directory))
|
if (!Directory.Exists(directory))
|
||||||
_ = Directory.CreateDirectory(directory);
|
_ = Directory.CreateDirectory(directory);
|
||||||
}
|
}
|
||||||
facesDirectory = string.Concat(dFacesContentDirectory, Path.Combine(directoryName, item.ImageFileHolder.NameWithoutExtension));
|
foreach ((FileHolder? resizedFileHolder, string directory, FileInfo? faceFileInfo, string checkFile, string shortcutFile) in collection)
|
||||||
faceFullFileName = Path.Combine(facesDirectory, $"{closest.FaceLocationIndex.Value} - {item.ImageFileHolder.NameWithoutExtension}.png");
|
{
|
||||||
if (Directory.Exists(facesDirectory) && File.Exists(faceFullFileName))
|
if (string.IsNullOrEmpty(directory) || string.IsNullOrEmpty(checkFile) || resizedFileHolder is null || faceFileInfo is null)
|
||||||
copyFile = faceFullFileName;
|
continue;
|
||||||
else
|
|
||||||
copyFile = item.ResizedFileHolder.FullName;
|
|
||||||
if (File.Exists(checkFile))
|
if (File.Exists(checkFile))
|
||||||
continue;
|
continue;
|
||||||
File.Copy(copyFile, checkFile);
|
if (faceFileInfo.Directory is not null && faceFileInfo.Directory.Exists && faceFileInfo.Exists)
|
||||||
|
File.Copy(faceFileInfo.FullName, checkFile);
|
||||||
|
else
|
||||||
|
File.Copy(resizedFileHolder.FullName, checkFile);
|
||||||
}
|
}
|
||||||
|
foreach ((FileHolder? resizedFileHolder, string directory, FileInfo? faceFileInfo, string checkFile, string shortcutFile) in collection)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(directory) || string.IsNullOrEmpty(checkFile) || resizedFileHolder is null || faceFileInfo is null)
|
||||||
|
continue;
|
||||||
|
if (string.IsNullOrEmpty(shortcutFile))
|
||||||
|
continue;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
windowsShortcut = new() { Path = resizedFileHolder.FullName };
|
||||||
|
windowsShortcut.Save(shortcutFile);
|
||||||
|
windowsShortcut.Dispose();
|
||||||
}
|
}
|
||||||
|
catch (Exception)
|
||||||
|
{ }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,27 +85,21 @@ public class B_Metadata
|
|||||||
throw new NullReferenceException(nameof(item.Property.Id));
|
throw new NullReferenceException(nameof(item.Property.Id));
|
||||||
if (item.ImageFileHolder is null)
|
if (item.ImageFileHolder is null)
|
||||||
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
||||||
if (string.IsNullOrEmpty(bResultsFullGroupDirectory))
|
|
||||||
throw new NullReferenceException(nameof(bResultsFullGroupDirectory));
|
|
||||||
Dictionary<string, List<KeyValuePair<string, string>>>? dictionary;
|
|
||||||
string json = string.Empty;
|
string json = string.Empty;
|
||||||
string[] changesFrom = Array.Empty<string>();
|
string[] changesFrom = Array.Empty<string>();
|
||||||
|
Dictionary<string, List<KeyValuePair<string, string>>>? dictionary;
|
||||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||||
FileInfo fileInfo = new(Path.Combine(AngleBracketCollection[0].Replace("<>", "{}"), string.Concat(item.ImageFileHolder.NameWithoutExtension, ".json")));
|
string usingRelativePath = Path.Combine(AngleBracketCollection[0].Replace("<>", "{}"), string.Concat(item.ImageFileHolder.NameWithoutExtension, ".json"));
|
||||||
string bMetadataSingletonFile = Path.Combine(bResultsFullGroupDirectory, "{}", "_ _ _", $"{item.Property.Id.Value}{item.ImageFileHolder.ExtensionLowered}.json");
|
string bMetadataSingletonFile = Path.Combine(bResultsFullGroupDirectory, "{}", Property.Models.Stateless.IResult.AllInOne, $"{item.Property.Id.Value}{item.ImageFileHolder.ExtensionLowered}.json");
|
||||||
if (fileInfo.Exists)
|
FileInfo fileInfo = new(bMetadataSingletonFile);
|
||||||
|
if (!fileInfo.Exists)
|
||||||
{
|
{
|
||||||
if (!File.Exists(bMetadataSingletonFile))
|
if (File.Exists(usingRelativePath))
|
||||||
{
|
{
|
||||||
fileInfo.MoveTo(bMetadataSingletonFile);
|
File.Move(usingRelativePath, fileInfo.FullName);
|
||||||
fileInfo = new(bMetadataSingletonFile);
|
fileInfo.Refresh();
|
||||||
}
|
}
|
||||||
}
|
if (!fileInfo.Exists)
|
||||||
else
|
|
||||||
{
|
|
||||||
if (File.Exists(bMetadataSingletonFile))
|
|
||||||
fileInfo = new(bMetadataSingletonFile);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (fileInfo.Directory?.Parent is null)
|
if (fileInfo.Directory?.Parent is null)
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
|
@ -5,6 +5,10 @@ namespace View_by_Distance.Property.Models;
|
|||||||
|
|
||||||
public class Closest
|
public class Closest
|
||||||
{
|
{
|
||||||
|
public const int MaximumPer = 50;
|
||||||
|
public const float MaximumMinimum = 0.50f;
|
||||||
|
public const bool SkipIsWrongYear = true;
|
||||||
|
public const float MinimumMinimum = 0.05f;
|
||||||
|
|
||||||
protected readonly double? _Average;
|
protected readonly double? _Average;
|
||||||
protected readonly int? _FaceLocationIndex;
|
protected readonly int? _FaceLocationIndex;
|
||||||
@ -40,6 +44,6 @@ public class Closest
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Closest Get(List<Closest> collection) => (from l in collection orderby l.Minimum < 0.05, l.Average select l).First();
|
public static Closest[] Get(List<Closest> collection) => (from l in collection orderby l.Minimum < MinimumMinimum, l.Average select l).ToArray();
|
||||||
|
|
||||||
}
|
}
|
@ -106,10 +106,10 @@ public class Item
|
|||||||
continue;
|
continue;
|
||||||
if (item.Property?.Id is null || item.ResizedFileHolder is null)
|
if (item.Property?.Id is null || item.ResizedFileHolder is null)
|
||||||
continue;
|
continue;
|
||||||
if (!propertyLogic.NamedFaceInfoDeterministicHashCodeIndices.ContainsKey(item.Property.Id.Value))
|
if (!propertyLogic.NamedFaceInfoDeterministicHashCodeIds.ContainsKey(item.Property.Id.Value))
|
||||||
continue;
|
continue;
|
||||||
minimumDateTime = Stateless.A_Property.GetMinimumDateTime(item.Property);
|
minimumDateTime = Stateless.A_Property.GetMinimumDateTime(item.Property);
|
||||||
personKeys = propertyLogic.NamedFaceInfoDeterministicHashCodeIndices[item.Property.Id.Value];
|
personKeys = propertyLogic.NamedFaceInfoDeterministicHashCodeIds[item.Property.Id.Value];
|
||||||
(isWrongYear, _) = item.Property.IsWrongYear(item.ImageFileHolder.FullName, minimumDateTime);
|
(isWrongYear, _) = item.Property.IsWrongYear(item.ImageFileHolder.FullName, minimumDateTime);
|
||||||
for (int j = 0; j < personKeys.Length; j++)
|
for (int j = 0; j < personKeys.Length; j++)
|
||||||
{
|
{
|
||||||
@ -163,7 +163,7 @@ public class Item
|
|||||||
if (item.Property?.Id is null || item.ResizedFileHolder is null)
|
if (item.Property?.Id is null || item.ResizedFileHolder is null)
|
||||||
continue;
|
continue;
|
||||||
collection = new();
|
collection = new();
|
||||||
if (!propertyLogic.NamedFaceInfoDeterministicHashCodeIndices.ContainsKey(item.Property.Id.Value))
|
if (!propertyLogic.NamedFaceInfoDeterministicHashCodeIds.ContainsKey(item.Property.Id.Value))
|
||||||
{
|
{
|
||||||
faceCollection = new();
|
faceCollection = new();
|
||||||
directory = Path.Combine(dFacesContentDirectory, $"Unnamed{relativePath[2..]}");
|
directory = Path.Combine(dFacesContentDirectory, $"Unnamed{relativePath[2..]}");
|
||||||
@ -171,7 +171,7 @@ public class Item
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
faceCollection = item.Faces;
|
faceCollection = item.Faces;
|
||||||
keys = propertyLogic.NamedFaceInfoDeterministicHashCodeIndices[item.Property.Id.Value];
|
keys = propertyLogic.NamedFaceInfoDeterministicHashCodeIds[item.Property.Id.Value];
|
||||||
minimumDateTime = Stateless.A_Property.GetMinimumDateTime(item.Property);
|
minimumDateTime = Stateless.A_Property.GetMinimumDateTime(item.Property);
|
||||||
if (minimumDateTime is null)
|
if (minimumDateTime is null)
|
||||||
continue;
|
continue;
|
||||||
|
@ -19,14 +19,16 @@ public class PropertyLogic
|
|||||||
protected readonly Dictionary<int, int[]> _KeyValuePairs;
|
protected readonly Dictionary<int, int[]> _KeyValuePairs;
|
||||||
protected readonly Dictionary<int, int[]> _IndicesFromNew;
|
protected readonly Dictionary<int, int[]> _IndicesFromNew;
|
||||||
protected readonly Dictionary<int, string[]> _SixCharacterNamedFaceInfo;
|
protected readonly Dictionary<int, string[]> _SixCharacterNamedFaceInfo;
|
||||||
protected readonly Dictionary<int, string[]> _NamedFaceInfoDeterministicHashCodeIndices;
|
protected readonly List<string> _NamedDeterministicHashCodeIdAndFaceLocationIndex;
|
||||||
|
protected readonly Dictionary<int, string[]> _NamedFaceInfoDeterministicHashCodeIds;
|
||||||
|
|
||||||
public bool Reverse { get; }
|
public bool Reverse { get; }
|
||||||
public List<string> AngleBracketCollection { get; }
|
public List<string> AngleBracketCollection { get; }
|
||||||
public Dictionary<int, int[]> KeyValuePairs => _KeyValuePairs;
|
public Dictionary<int, int[]> KeyValuePairs => _KeyValuePairs;
|
||||||
public Dictionary<int, int[]> IndicesFromNew => _IndicesFromNew;
|
public Dictionary<int, int[]> IndicesFromNew => _IndicesFromNew;
|
||||||
public List<string> ExceptionsDirectories => _ExceptionsDirectories;
|
public List<string> ExceptionsDirectories => _ExceptionsDirectories;
|
||||||
public Dictionary<int, string[]> NamedFaceInfoDeterministicHashCodeIndices => _NamedFaceInfoDeterministicHashCodeIndices;
|
public Dictionary<int, string[]> NamedFaceInfoDeterministicHashCodeIds => _NamedFaceInfoDeterministicHashCodeIds;
|
||||||
|
public List<string> NamedDeterministicHashCodeIdAndFaceLocationIndex => _NamedDeterministicHashCodeIdAndFaceLocationIndex;
|
||||||
|
|
||||||
private readonly Model? _Model;
|
private readonly Model? _Model;
|
||||||
private readonly Serilog.ILogger? _Log;
|
private readonly Serilog.ILogger? _Log;
|
||||||
@ -57,6 +59,7 @@ public class PropertyLogic
|
|||||||
string json;
|
string json;
|
||||||
string[] files;
|
string[] files;
|
||||||
string fullPath;
|
string fullPath;
|
||||||
|
List<string> namedDeterministicHashCodeIdAndFaceLocationIndex = new();
|
||||||
Dictionary<int, int[]>? keyValuePairs;
|
Dictionary<int, int[]>? keyValuePairs;
|
||||||
List<KeyValuePair<int, int[]>>? collection;
|
List<KeyValuePair<int, int[]>>? collection;
|
||||||
Dictionary<int, int[]> indicesFromNew = new();
|
Dictionary<int, int[]> indicesFromNew = new();
|
||||||
@ -75,7 +78,20 @@ public class PropertyLogic
|
|||||||
throw new NullReferenceException(nameof(namedFaceInfoDeterministicHashCodeIndices));
|
throw new NullReferenceException(nameof(namedFaceInfoDeterministicHashCodeIndices));
|
||||||
}
|
}
|
||||||
if (namedFaceInfoDeterministicHashCodeIndices.Any())
|
if (namedFaceInfoDeterministicHashCodeIndices.Any())
|
||||||
|
{
|
||||||
sixCharacterNamedFaceInfo = new();
|
sixCharacterNamedFaceInfo = new();
|
||||||
|
string[] directories = Directory.GetDirectories(rootDirectoryParent, "*DeterministicHashCode*", SearchOption.TopDirectoryOnly);
|
||||||
|
if (directories.Any())
|
||||||
|
{
|
||||||
|
Dictionary<int, string[]> ticksKeyValuePairs = GetKeyValuePairs(namedDeterministicHashCodeIdAndFaceLocationIndex, directories[0]);
|
||||||
|
foreach (KeyValuePair<int, string[]> keyValuePair in ticksKeyValuePairs)
|
||||||
|
{
|
||||||
|
if (namedFaceInfoDeterministicHashCodeIndices.ContainsKey(keyValuePair.Key))
|
||||||
|
continue;
|
||||||
|
namedFaceInfoDeterministicHashCodeIndices.Add(keyValuePair.Key, keyValuePair.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
files = Directory.GetFiles(rootDirectoryParent, "*SixCharacter*.json", SearchOption.TopDirectoryOnly);
|
files = Directory.GetFiles(rootDirectoryParent, "*SixCharacter*.json", SearchOption.TopDirectoryOnly);
|
||||||
@ -117,10 +133,63 @@ public class PropertyLogic
|
|||||||
indicesFromNew.Add(keyValuePair.Key, keyValuePair.Value);
|
indicesFromNew.Add(keyValuePair.Key, keyValuePair.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_NamedDeterministicHashCodeIdAndFaceLocationIndex = namedDeterministicHashCodeIdAndFaceLocationIndex;
|
||||||
_KeyValuePairs = keyValuePairs;
|
_KeyValuePairs = keyValuePairs;
|
||||||
_IndicesFromNew = indicesFromNew;
|
_IndicesFromNew = indicesFromNew;
|
||||||
_SixCharacterNamedFaceInfo = sixCharacterNamedFaceInfo;
|
_SixCharacterNamedFaceInfo = sixCharacterNamedFaceInfo;
|
||||||
_NamedFaceInfoDeterministicHashCodeIndices = namedFaceInfoDeterministicHashCodeIndices;
|
_NamedFaceInfoDeterministicHashCodeIds = namedFaceInfoDeterministicHashCodeIndices;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Dictionary<int, string[]> GetKeyValuePairs(List<string> namedDeterministicHashCodeIdAndFaceLocationIndex, string rootDirectory)
|
||||||
|
{
|
||||||
|
Dictionary<int, string[]> results = new();
|
||||||
|
string id;
|
||||||
|
string[] files;
|
||||||
|
string personKey;
|
||||||
|
string[] segments;
|
||||||
|
string faceLocationIndex;
|
||||||
|
string[] yearDirectories;
|
||||||
|
string[] personKeyDirectories;
|
||||||
|
string[] personNameDirectories;
|
||||||
|
string fileNameWithoutExtension;
|
||||||
|
string[] ticksDirectories = Directory.GetDirectories(rootDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
|
foreach (string ticksDirectory in ticksDirectories)
|
||||||
|
{
|
||||||
|
if (!ticksDirectory.EndsWith(')'))
|
||||||
|
continue;
|
||||||
|
personKeyDirectories = Directory.GetDirectories(ticksDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
|
foreach (string personKeyDirectory in personKeyDirectories)
|
||||||
|
{
|
||||||
|
personKey = Path.GetFileName(personKeyDirectory);
|
||||||
|
yearDirectories = Directory.GetDirectories(personKeyDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
|
foreach (string yearDirectory in yearDirectories)
|
||||||
|
{
|
||||||
|
personNameDirectories = Directory.GetDirectories(yearDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
|
foreach (string personNameDirectory in personNameDirectories)
|
||||||
|
{
|
||||||
|
files = Directory.GetFiles(personNameDirectory, "*", SearchOption.TopDirectoryOnly);
|
||||||
|
foreach (string file in files)
|
||||||
|
{
|
||||||
|
if (file.EndsWith(".lnk"))
|
||||||
|
continue;
|
||||||
|
fileNameWithoutExtension = Path.GetFileNameWithoutExtension(file);
|
||||||
|
segments = fileNameWithoutExtension.Split(' ');
|
||||||
|
if (segments.Length < 2)
|
||||||
|
continue;
|
||||||
|
id = segments[2];
|
||||||
|
faceLocationIndex = segments[0];
|
||||||
|
if (!int.TryParse(id, out int idValue))
|
||||||
|
continue;
|
||||||
|
namedDeterministicHashCodeIdAndFaceLocationIndex.Add(fileNameWithoutExtension);
|
||||||
|
if (results.ContainsKey(idValue))
|
||||||
|
continue;
|
||||||
|
results.Add(idValue, new string[] { personKey });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString()
|
public override string ToString()
|
||||||
@ -640,7 +709,7 @@ public class PropertyLogic
|
|||||||
List<Tuple<string, DateTime>> filteredSourceDirectoryFileTuples = new();
|
List<Tuple<string, DateTime>> filteredSourceDirectoryFileTuples = new();
|
||||||
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = _MaxDegreeOfParallelism };
|
ParallelOptions parallelOptions = new() { MaxDegreeOfParallelism = _MaxDegreeOfParallelism };
|
||||||
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
ProgressBarOptions options = new() { ProgressCharacter = '─', ProgressBarOnBottom = true, DisableBottomPercentage = true };
|
||||||
string message = $"{container.R + 1:000}.{container.G} / {containersCount:000}) {filteredItems.Length:000} file(s) - {totalSeconds} total second(s) - {container.SourceDirectory}";
|
string message = $"{container.R:000}.{container.G} / {containersCount:000}) {filteredItems.Length:000} file(s) - {totalSeconds} total second(s) - {container.SourceDirectory}";
|
||||||
using ProgressBar progressBar = new(filteredItems.Length, message, options);
|
using ProgressBar progressBar = new(filteredItems.Length, message, options);
|
||||||
_ = Parallel.For(0, filteredItems.Length, parallelOptions, i =>
|
_ = Parallel.For(0, filteredItems.Length, parallelOptions, i =>
|
||||||
{
|
{
|
||||||
|
@ -5,25 +5,37 @@ namespace View_by_Distance.Property.Models.Stateless;
|
|||||||
public interface IResult
|
public interface IResult
|
||||||
{
|
{
|
||||||
|
|
||||||
|
public const string Content = "()";
|
||||||
|
public const string Singleton = "{}";
|
||||||
|
public const string Collection = "[]";
|
||||||
|
public const string AllInOne = "_ _ _";
|
||||||
|
|
||||||
string TestStatic_GetRelativePath(Models.Configuration configuration, string path);
|
string TestStatic_GetRelativePath(Models.Configuration configuration, string path);
|
||||||
static string GetRelativePath(Models.Configuration configuration, string path) => Result.GetRelativePath(configuration, path);
|
static string GetRelativePath(Models.Configuration configuration, string path)
|
||||||
|
=> Result.GetRelativePath(configuration, path);
|
||||||
|
|
||||||
string TestStatic_GetResultsGroupDirectory(Models.Configuration configuration, string description);
|
string TestStatic_GetResultsGroupDirectory(Models.Configuration configuration, string description);
|
||||||
static string GetResultsGroupDirectory(Models.Configuration configuration, string description) => Result.GetResultsGroupDirectory(configuration, description);
|
static string GetResultsGroupDirectory(Models.Configuration configuration, string description)
|
||||||
|
=> Result.GetResultsGroupDirectory(configuration, description);
|
||||||
|
|
||||||
string TestStatic_GetResultsDateGroupDirectory(Models.Configuration configuration, string description);
|
string TestStatic_GetResultsDateGroupDirectory(Models.Configuration configuration, string description);
|
||||||
static string GetResultsDateGroupDirectory(Models.Configuration configuration, string description) => Result.GetResultsDateGroupDirectory(configuration, description);
|
static string GetResultsDateGroupDirectory(Models.Configuration configuration, string description)
|
||||||
|
=> Result.GetResultsDateGroupDirectory(configuration, description);
|
||||||
|
|
||||||
string TestStatic_GetResultsDateGroupDirectory(Models.Configuration configuration, string description, string jsonGroup);
|
string TestStatic_GetResultsDateGroupDirectory(Models.Configuration configuration, string description, string jsonGroup);
|
||||||
static string GetResultsDateGroupDirectory(Models.Configuration configuration, string description, string jsonGroup) => Result.GetResultsDateGroupDirectory(configuration, description, jsonGroup);
|
static string GetResultsDateGroupDirectory(Models.Configuration configuration, string description, string jsonGroup)
|
||||||
|
=> Result.GetResultsDateGroupDirectory(configuration, description, jsonGroup);
|
||||||
|
|
||||||
List<string> TestStatic_GetDirectoryInfoCollection(Models.Configuration configuration, string sourceDirectory, string dateGroupDirectory, string contentDescription, string singletonDescription, string collectionDescription);
|
List<string> TestStatic_GetDirectoryInfoCollection(Models.Configuration configuration, string sourceDirectory, string dateGroupDirectory, string contentDescription, string singletonDescription, string collectionDescription);
|
||||||
static List<string> GetDirectoryInfoCollection(Models.Configuration configuration, string sourceDirectory, string dateGroupDirectory, string contentDescription, string singletonDescription, string collectionDescription) => Result.GetDirectoryInfoCollection(configuration, sourceDirectory, dateGroupDirectory, contentDescription, singletonDescription, collectionDescription);
|
static List<string> GetDirectoryInfoCollection(Models.Configuration configuration, string sourceDirectory, string dateGroupDirectory, string contentDescription, string singletonDescription, string collectionDescription, bool converted)
|
||||||
|
=> Result.GetDirectoryInfoCollection(configuration, sourceDirectory, dateGroupDirectory, contentDescription, singletonDescription, collectionDescription, converted);
|
||||||
|
|
||||||
string TestStatic_GetResultsFullGroupDirectory(Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string description, string outputResolution, bool includeResizeGroup, bool includeModel, bool includePredictorModel);
|
string TestStatic_GetResultsFullGroupDirectory(Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string description, string outputResolution, bool includeResizeGroup, bool includeModel, bool includePredictorModel);
|
||||||
static string GetResultsFullGroupDirectory(Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string description, string outputResolution, bool includeResizeGroup, bool includeModel, bool includePredictorModel) => Result.GetResultsFullGroupDirectory(configuration, model, predictorModel, description, outputResolution, includeResizeGroup, includeModel, includePredictorModel);
|
static string GetResultsFullGroupDirectory(Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string description, string outputResolution, bool includeResizeGroup, bool includeModel, bool includePredictorModel)
|
||||||
|
=> Result.GetResultsFullGroupDirectory(configuration, model, predictorModel, description, outputResolution, includeResizeGroup, includeModel, includePredictorModel);
|
||||||
|
|
||||||
List<string> TestStatic_GetDirectoryInfoCollection(Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string sourceDirectory, string description, string outputResolution, bool includeResizeGroup, bool includeModel, bool includePredictorModel, string contentDescription, string singletonDescription, string collectionDescription);
|
List<string> TestStatic_GetDirectoryInfoCollection(Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string sourceDirectory, string description, string outputResolution, bool includeResizeGroup, bool includeModel, bool includePredictorModel, string contentDescription, string singletonDescription, string collectionDescription);
|
||||||
static List<string> GetDirectoryInfoCollection(Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string sourceDirectory, string description, string outputResolution, bool includeResizeGroup, bool includeModel, bool includePredictorModel, string contentDescription, string singletonDescription, string collectionDescription) => Result.GetDirectoryInfoCollection(configuration, model, predictorModel, sourceDirectory, description, outputResolution, includeResizeGroup, includeModel, includePredictorModel, contentDescription, singletonDescription, collectionDescription);
|
static List<string> GetDirectoryInfoCollection(Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string sourceDirectory, string description, string outputResolution, bool includeResizeGroup, bool includeModel, bool includePredictorModel, string contentDescription, string singletonDescription, string collectionDescription)
|
||||||
|
=> Result.GetDirectoryInfoCollection(configuration, model, predictorModel, sourceDirectory, description, outputResolution, includeResizeGroup, includeModel, includePredictorModel, contentDescription, singletonDescription, collectionDescription);
|
||||||
|
|
||||||
}
|
}
|
@ -64,20 +64,18 @@ internal class Result
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<string> GetDirectoryInfoCollection(Models.Configuration configuration, string sourceDirectory, string dateGroupDirectory, string contentDescription, string singletonDescription, string collectionDescription)
|
internal static List<string> GetDirectoryInfoCollection(Models.Configuration configuration, string sourceDirectory, string dateGroupDirectory, string contentDescription, string singletonDescription, string collectionDescription, bool converted)
|
||||||
{
|
{
|
||||||
List<string> results = new();
|
List<string> results = new();
|
||||||
string result = string.Empty;
|
|
||||||
string checkDirectory;
|
string checkDirectory;
|
||||||
const string allInOne = "_ _ _";
|
|
||||||
string sourceDirectorySegment = GetRelativePath(configuration, sourceDirectory);
|
string sourceDirectorySegment = GetRelativePath(configuration, sourceDirectory);
|
||||||
|
string result = string.Concat(Path.Combine(dateGroupDirectory, "<>"), sourceDirectorySegment);
|
||||||
if (!string.IsNullOrEmpty(contentDescription))
|
if (!string.IsNullOrEmpty(contentDescription))
|
||||||
{
|
{
|
||||||
checkDirectory = Path.Combine(dateGroupDirectory, "()", allInOne);
|
checkDirectory = Path.Combine(dateGroupDirectory, IResult.Content, IResult.AllInOne);
|
||||||
if (!Directory.Exists(checkDirectory))
|
if (!Directory.Exists(checkDirectory))
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
result = string.Concat(Path.Combine(dateGroupDirectory, "<>"), sourceDirectorySegment);
|
string contentDirectory = new(result.Replace("<>", IResult.Content));
|
||||||
string contentDirectory = new(result.Replace("<>", "()"));
|
|
||||||
if (!Directory.Exists(contentDirectory))
|
if (!Directory.Exists(contentDirectory))
|
||||||
_ = Directory.CreateDirectory(contentDirectory);
|
_ = Directory.CreateDirectory(contentDirectory);
|
||||||
checkDirectory = Path.Combine(dateGroupDirectory, string.Concat("() - ", contentDescription));
|
checkDirectory = Path.Combine(dateGroupDirectory, string.Concat("() - ", contentDescription));
|
||||||
@ -86,76 +84,44 @@ internal class Result
|
|||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(singletonDescription))
|
if (!string.IsNullOrEmpty(singletonDescription))
|
||||||
{
|
{
|
||||||
checkDirectory = Path.Combine(dateGroupDirectory, "{}", allInOne);
|
checkDirectory = Path.Combine(dateGroupDirectory, IResult.Singleton, IResult.AllInOne);
|
||||||
if (!Directory.Exists(checkDirectory))
|
if (!Directory.Exists(checkDirectory))
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
result = string.Concat(Path.Combine(dateGroupDirectory, "<>"), sourceDirectorySegment);
|
if (!converted)
|
||||||
string singletonDirectory = new(result.Replace("<>", "{}"));
|
{
|
||||||
|
string singletonDirectory = new(result.Replace("<>", IResult.Singleton));
|
||||||
if (!Directory.Exists(singletonDirectory))
|
if (!Directory.Exists(singletonDirectory))
|
||||||
_ = Directory.CreateDirectory(singletonDirectory);
|
_ = Directory.CreateDirectory(singletonDirectory);
|
||||||
|
}
|
||||||
checkDirectory = Path.Combine(dateGroupDirectory, string.Concat("{} - ", singletonDescription));
|
checkDirectory = Path.Combine(dateGroupDirectory, string.Concat("{} - ", singletonDescription));
|
||||||
if (!Directory.Exists(checkDirectory))
|
if (!Directory.Exists(checkDirectory))
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
}
|
}
|
||||||
if (!string.IsNullOrEmpty(collectionDescription))
|
if (!string.IsNullOrEmpty(collectionDescription))
|
||||||
{
|
{
|
||||||
checkDirectory = Path.Combine(dateGroupDirectory, "[]", allInOne);
|
checkDirectory = Path.Combine(dateGroupDirectory, IResult.Collection, IResult.AllInOne);
|
||||||
if (!Directory.Exists(checkDirectory))
|
if (!Directory.Exists(checkDirectory))
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
result = string.Concat(Path.Combine(dateGroupDirectory, "<>"), sourceDirectorySegment);
|
if (!converted)
|
||||||
string collectionDirectory = new(result.Replace("<>", "[]"));
|
{
|
||||||
|
string collectionDirectory = new(result.Replace("<>", IResult.Collection));
|
||||||
if (!Directory.Exists(collectionDirectory))
|
if (!Directory.Exists(collectionDirectory))
|
||||||
_ = Directory.CreateDirectory(collectionDirectory);
|
_ = Directory.CreateDirectory(collectionDirectory);
|
||||||
|
}
|
||||||
checkDirectory = Path.Combine(dateGroupDirectory, string.Concat("[] - ", collectionDescription));
|
checkDirectory = Path.Combine(dateGroupDirectory, string.Concat("[] - ", collectionDescription));
|
||||||
if (!Directory.Exists(checkDirectory))
|
if (!Directory.Exists(checkDirectory))
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
_ = Directory.CreateDirectory(checkDirectory);
|
||||||
}
|
}
|
||||||
if (string.IsNullOrEmpty(result))
|
|
||||||
throw new Exception();
|
|
||||||
results.Add(result);
|
results.Add(result);
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<string> GetDirectoryInfoCollection(Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string sourceDirectory, string description, string outputResolution, bool includeResizeGroup, bool includeModel, bool includePredictorModel, string contentDescription, string singletonDescription, string collectionDescription)
|
internal static List<string> GetDirectoryInfoCollection(Models.Configuration configuration, Model? model, PredictorModel? predictorModel, string sourceDirectory, string description, string outputResolution, bool includeResizeGroup, bool includeModel, bool includePredictorModel, string contentDescription, string singletonDescription, string collectionDescription)
|
||||||
{
|
{
|
||||||
List<string> results = new();
|
List<string> results;
|
||||||
string result = string.Empty;
|
bool converted = false;
|
||||||
string checkDirectory;
|
|
||||||
string sourceDirectorySegment = GetRelativePath(configuration, sourceDirectory);
|
|
||||||
string dateGroupDirectory = GetResultsFullGroupDirectory(configuration, model, predictorModel, description, outputResolution, includeResizeGroup, includeModel, includePredictorModel);
|
string dateGroupDirectory = GetResultsFullGroupDirectory(configuration, model, predictorModel, description, outputResolution, includeResizeGroup, includeModel, includePredictorModel);
|
||||||
if (!string.IsNullOrEmpty(contentDescription))
|
results = GetDirectoryInfoCollection(configuration, sourceDirectory, dateGroupDirectory, contentDescription, singletonDescription, collectionDescription, converted);
|
||||||
{
|
|
||||||
result = string.Concat(Path.Combine(dateGroupDirectory, "<>"), sourceDirectorySegment);
|
|
||||||
System.IO.DirectoryInfo contentDirectoryInfo = new(result.Replace("<>", "()"));
|
|
||||||
if (!contentDirectoryInfo.Exists)
|
|
||||||
contentDirectoryInfo.Create();
|
|
||||||
checkDirectory = Path.Combine(dateGroupDirectory, string.Concat("() - ", contentDescription));
|
|
||||||
if (!Directory.Exists(checkDirectory))
|
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(singletonDescription))
|
|
||||||
{
|
|
||||||
result = string.Concat(Path.Combine(dateGroupDirectory, "<>"), sourceDirectorySegment);
|
|
||||||
System.IO.DirectoryInfo singletonDirectoryInfo = new(result.Replace("<>", "{}"));
|
|
||||||
if (!singletonDirectoryInfo.Exists)
|
|
||||||
singletonDirectoryInfo.Create();
|
|
||||||
checkDirectory = Path.Combine(dateGroupDirectory, string.Concat("{} - ", singletonDescription));
|
|
||||||
if (!Directory.Exists(checkDirectory))
|
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(collectionDescription))
|
|
||||||
{
|
|
||||||
result = string.Concat(Path.Combine(dateGroupDirectory, "<>"), sourceDirectorySegment);
|
|
||||||
System.IO.DirectoryInfo collectionDirectoryInfo = new(result.Replace("<>", "[]"));
|
|
||||||
if (!collectionDirectoryInfo.Exists)
|
|
||||||
collectionDirectoryInfo.Create();
|
|
||||||
checkDirectory = Path.Combine(dateGroupDirectory, string.Concat("[] - ", collectionDescription));
|
|
||||||
if (!Directory.Exists(checkDirectory))
|
|
||||||
_ = Directory.CreateDirectory(checkDirectory);
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(result))
|
|
||||||
throw new Exception();
|
|
||||||
results.Add(result);
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,8 +291,6 @@ public class C_Resize
|
|||||||
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
||||||
if (!imageResizes.ContainsKey(outputResolution))
|
if (!imageResizes.ContainsKey(outputResolution))
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
if (string.IsNullOrEmpty(cResultsFullGroupDirectory))
|
|
||||||
throw new NullReferenceException(nameof(cResultsFullGroupDirectory));
|
|
||||||
int[] resize = imageResizes[outputResolution];
|
int[] resize = imageResizes[outputResolution];
|
||||||
int outputResolutionWidth = resize[_OutputResolutionWidthIndex];
|
int outputResolutionWidth = resize[_OutputResolutionWidthIndex];
|
||||||
int outputResolutionHeight = resize[_OutputResolutionHeightIndex];
|
int outputResolutionHeight = resize[_OutputResolutionHeightIndex];
|
||||||
@ -308,8 +306,6 @@ public class C_Resize
|
|||||||
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
||||||
if (item.ResizedFileHolder is null)
|
if (item.ResizedFileHolder is null)
|
||||||
throw new NullReferenceException(nameof(item.ResizedFileHolder));
|
throw new NullReferenceException(nameof(item.ResizedFileHolder));
|
||||||
if (string.IsNullOrEmpty(cResultsFullGroupDirectory))
|
|
||||||
throw new NullReferenceException(nameof(cResultsFullGroupDirectory));
|
|
||||||
FileHolder fileHolder = item.ResizedFileHolder;
|
FileHolder fileHolder = item.ResizedFileHolder;
|
||||||
if (!imageResizes.ContainsKey(outputResolution))
|
if (!imageResizes.ContainsKey(outputResolution))
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
@ -433,26 +429,20 @@ public class C_Resize
|
|||||||
throw new NullReferenceException(nameof(item.Property.Id));
|
throw new NullReferenceException(nameof(item.Property.Id));
|
||||||
if (item.ImageFileHolder is null)
|
if (item.ImageFileHolder is null)
|
||||||
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
throw new NullReferenceException(nameof(item.ImageFileHolder));
|
||||||
if (string.IsNullOrEmpty(cResultsFullGroupDirectory))
|
|
||||||
throw new NullReferenceException(nameof(cResultsFullGroupDirectory));
|
|
||||||
string json;
|
string json;
|
||||||
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata) };
|
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata) };
|
||||||
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
List<DateTime> dateTimes = (from l in subFileTuples where changesFrom.Contains(l.Item1) select l.Item2).ToList();
|
||||||
FileInfo fileInfo = new(Path.Combine(AngleBracketCollection[0].Replace("<>", "{}"), string.Concat(item.ImageFileHolder.NameWithoutExtension, ".json")));
|
string usingRelativePath = Path.Combine(AngleBracketCollection[0].Replace("<>", "{}"), string.Concat(item.ImageFileHolder.NameWithoutExtension, ".json"));
|
||||||
string cResizeSingletonFile = Path.Combine(cResultsFullGroupDirectory, "{}", "_ _ _", $"{item.Property.Id.Value}{item.ImageFileHolder.ExtensionLowered}.json");
|
string cResizeSingletonFile = Path.Combine(cResultsFullGroupDirectory, "{}", Property.Models.Stateless.IResult.AllInOne, $"{item.Property.Id.Value}{item.ImageFileHolder.ExtensionLowered}.json");
|
||||||
if (fileInfo.Exists)
|
FileInfo fileInfo = new(cResizeSingletonFile);
|
||||||
|
if (!fileInfo.Exists)
|
||||||
{
|
{
|
||||||
if (!File.Exists(cResizeSingletonFile))
|
if (File.Exists(usingRelativePath))
|
||||||
{
|
{
|
||||||
fileInfo.MoveTo(cResizeSingletonFile);
|
File.Move(usingRelativePath, fileInfo.FullName);
|
||||||
fileInfo = new(cResizeSingletonFile);
|
fileInfo.Refresh();
|
||||||
}
|
}
|
||||||
}
|
if (!fileInfo.Exists)
|
||||||
else
|
|
||||||
{
|
|
||||||
if (File.Exists(cResizeSingletonFile))
|
|
||||||
fileInfo = new(cResizeSingletonFile);
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
if (fileInfo.Directory?.Parent is null)
|
if (fileInfo.Directory?.Parent is null)
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
|
@ -137,21 +137,24 @@ public class UnitTestResize
|
|||||||
aResultsFullGroupDirectory,
|
aResultsFullGroupDirectory,
|
||||||
contentDescription: string.Empty,
|
contentDescription: string.Empty,
|
||||||
singletonDescription: "Properties for each image",
|
singletonDescription: "Properties for each image",
|
||||||
collectionDescription: string.Empty));
|
collectionDescription: string.Empty,
|
||||||
|
converted: false));
|
||||||
metadata.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(
|
metadata.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(
|
||||||
_PropertyConfiguration,
|
_PropertyConfiguration,
|
||||||
sourceDirectory,
|
sourceDirectory,
|
||||||
bResultsFullGroupDirectory,
|
bResultsFullGroupDirectory,
|
||||||
contentDescription: string.Empty,
|
contentDescription: string.Empty,
|
||||||
singletonDescription: "Metadata as key value pairs",
|
singletonDescription: "Metadata as key value pairs",
|
||||||
collectionDescription: string.Empty));
|
collectionDescription: string.Empty,
|
||||||
|
converted: true));
|
||||||
resize.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(
|
resize.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(
|
||||||
_PropertyConfiguration,
|
_PropertyConfiguration,
|
||||||
sourceDirectory,
|
sourceDirectory,
|
||||||
cResultsFullGroupDirectory,
|
cResultsFullGroupDirectory,
|
||||||
contentDescription: "Resized image",
|
contentDescription: "Resized image",
|
||||||
singletonDescription: "Resize dimensions for each resolution",
|
singletonDescription: "Resize dimensions for each resolution",
|
||||||
collectionDescription: string.Empty));
|
collectionDescription: string.Empty,
|
||||||
|
converted: true));
|
||||||
string sourceDirectoryFile = ".json";
|
string sourceDirectoryFile = ".json";
|
||||||
Property.Models.FileHolder fileHolder = new(Path.Combine(sourceDirectory, sourceFileName));
|
Property.Models.FileHolder fileHolder = new(Path.Combine(sourceDirectory, sourceFileName));
|
||||||
string relativePath = Property.Models.Stateless.IPath.GetRelativePath(fileHolder.FullName, length);
|
string relativePath = Property.Models.Stateless.IPath.GetRelativePath(fileHolder.FullName, length);
|
||||||
|
@ -199,21 +199,24 @@ public class UnitTestFace
|
|||||||
aResultsFullGroupDirectory,
|
aResultsFullGroupDirectory,
|
||||||
contentDescription: string.Empty,
|
contentDescription: string.Empty,
|
||||||
singletonDescription: "Properties for each image",
|
singletonDescription: "Properties for each image",
|
||||||
collectionDescription: string.Empty));
|
collectionDescription: string.Empty,
|
||||||
|
converted: false));
|
||||||
metadata.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(
|
metadata.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(
|
||||||
_PropertyConfiguration,
|
_PropertyConfiguration,
|
||||||
sourceDirectory,
|
sourceDirectory,
|
||||||
bResultsFullGroupDirectory,
|
bResultsFullGroupDirectory,
|
||||||
contentDescription: string.Empty,
|
contentDescription: string.Empty,
|
||||||
singletonDescription: "Metadata as key value pairs",
|
singletonDescription: "Metadata as key value pairs",
|
||||||
collectionDescription: string.Empty));
|
collectionDescription: string.Empty,
|
||||||
|
converted: true));
|
||||||
resize.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(
|
resize.AngleBracketCollection.AddRange(Property.Models.Stateless.IResult.GetDirectoryInfoCollection(
|
||||||
_PropertyConfiguration,
|
_PropertyConfiguration,
|
||||||
sourceDirectory,
|
sourceDirectory,
|
||||||
cResultsFullGroupDirectory,
|
cResultsFullGroupDirectory,
|
||||||
contentDescription: "Resized image",
|
contentDescription: "Resized image",
|
||||||
singletonDescription: "Resize dimensions for each resolution",
|
singletonDescription: "Resize dimensions for each resolution",
|
||||||
collectionDescription: string.Empty));
|
collectionDescription: string.Empty,
|
||||||
|
converted: true));
|
||||||
string sourceDirectoryFile = ".json";
|
string sourceDirectoryFile = ".json";
|
||||||
Property.Models.FileHolder fileHolder = new(Path.Combine(sourceDirectory, sourceFileName));
|
Property.Models.FileHolder fileHolder = new(Path.Combine(sourceDirectory, sourceFileName));
|
||||||
string relativePath = Property.Models.Stateless.IPath.GetRelativePath(fileHolder.FullName, length);
|
string relativePath = Property.Models.Stateless.IPath.GetRelativePath(fileHolder.FullName, length);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user