Save Closest is ready again with

all Deterministic Hash Code Key
This commit is contained in:
2022-08-20 00:57:48 -07:00
parent be7a6abbf4
commit f72fcee1db
16 changed files with 235 additions and 136 deletions

View File

@ -8,7 +8,7 @@ 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 View_by_Distance.Shared.Models.Properties;
using View_by_Distance.Shared.Models.Stateless;
using WindowsShortcutFactory;
@ -17,7 +17,7 @@ namespace View_by_Distance.Instance.Models;
/// <summary>
// List<D_Faces>
/// </summary>
public class D_Face : Shared.Models.Properties.IFace, IFace
public class D_Face : IFace, Shared.Models.Methods.IFace
{
internal List<string> AngleBracketCollection { get; }
@ -116,7 +116,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
_RelativePath = relativePath;
}
private D_Face(int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation, Shared.Models.Properties.IFace face)
private D_Face(int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation, IFace face)
{
_Α = face.α;
_DateTime = face.DateTime;
@ -290,6 +290,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
D_Face? face = null;
Rectangle rectangle;
double[] rawEncoding;
double deterministicHashCodeKey;
Shared.Models.FaceEncoding faceEncoding;
FaceRecognitionDotNet.Image? knownImage;
FaceRecognitionDotNet.Image? rotatedImage;
@ -368,7 +369,8 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
faceEncoding = new(rawEncoding, faceEncodings[0].Size);
face.Update(α, faceEncoding, populated: true);
}
faceFile = Path.Combine(facesDirectory, $"{i} - {item.ImageFileHolder.NameWithoutExtension}.png");
deterministicHashCodeKey = Named.GetDeterministicHashCodeKey(item, face);
faceFile = Path.Combine(facesDirectory, $"{deterministicHashCodeKey}{item.ImageFileHolder.ExtensionLowered}.png");
preRotated.Save(faceFile, System.Drawing.Imaging.ImageFormat.Png);
results.Add(face);
}
@ -508,6 +510,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
FileInfo fileInfo;
bool check = false;
string parentCheck;
double deterministicHashCodeKey;
List<string> imageFiles = new();
string[] changesFrom = new string[] { nameof(A_Property), nameof(B_Metadata), nameof(C_Resize) };
string facesDirectory = Path.Combine(AngleBracketCollection[0].Replace("<>", "()"), item.ImageFileHolder.NameWithoutExtension);
@ -515,14 +518,15 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
bool facesDirectoryExisted = Directory.Exists(facesDirectory);
if (!facesDirectoryExisted)
_ = Directory.CreateDirectory(facesDirectory);
for (int i = 0; i < faceCollection.Count; i++)
foreach (IFace face in faceCollection)
{
if (!faceCollection[i].Populated || faceCollection[i]?.Location is null)
if (!face.Populated || face.Location?.NormalizedPixelPercentage is null)
{
imageFiles.Add(string.Empty);
continue;
}
fileInfo = new FileInfo(Path.Combine(facesDirectory, $"{i} - {item.ImageFileHolder.NameWithoutExtension}.png"));
deterministicHashCodeKey = Named.GetDeterministicHashCodeKey(item, face);
fileInfo = new FileInfo(Path.Combine(facesDirectory, $"{deterministicHashCodeKey}{item.ImageFileHolder.ExtensionLowered}.png"));
if (!fileInfo.Exists)
{
if (fileInfo.Directory?.Parent is null)
@ -552,12 +556,12 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
WindowsShortcut windowsShortcut;
const string pattern = @"[\\,\/,\:,\*,\?,\"",\<,\>,\|]";
string dFacesContentDirectory = Path.Combine(dResultsFullGroupDirectory, $"({ticks})");
List<(Item, (string, Shared.Models.Properties.IFace?, (string, string, string, string))[])> collections = Item.GetCollection(propertyLogic, items, dFacesContentDirectory);
foreach ((Item item, (string personKey, Shared.Models.Properties.IFace? _, (string, string, string, string))[] collection) in collections)
List<(Item, (string, IFace?, (string, string, string, string))[])> collections = Item.GetCollection(propertyLogic, items, dFacesContentDirectory);
foreach ((Item item, (string personKey, IFace? _, (string, string, string, string))[] collection) in collections)
{
if (collection.Length != 1)
continue;
foreach ((string personKey, Shared.Models.Properties.IFace? _, (string directory, string copyDirectory, string copyFileName, string shortcutFileName)) in collection)
foreach ((string personKey, IFace? _, (string directory, string copyDirectory, string copyFileName, string shortcutFileName)) in collection)
{
if (string.IsNullOrEmpty(personKey))
continue;