Added Class Library FaceRecognitionDotNet
This commit is contained in:
@ -1,15 +1,16 @@
|
||||
using FaceRecognitionDotNet;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Phares.Shared;
|
||||
using ShellProgressBar;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Text.Json;
|
||||
using View_by_Distance.FaceRecognitionDotNet;
|
||||
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;
|
||||
using View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
namespace View_by_Distance.Instance;
|
||||
|
||||
@ -548,7 +549,7 @@ public class DlibDotNet
|
||||
}
|
||||
}
|
||||
|
||||
private void FullDoWork(Property.Models.Configuration configuration, string[] juliePhares, Model model, PredictorModel predictorModel, string argZero, Person[] people, PropertyLogic propertyLogic, List<PropertyHolder[]> propertyHolderCollections)
|
||||
private void FullDoWork(Property.Models.Configuration configuration, string[] juliePhares, Model model, PredictorModel predictorModel, string argZero, Dictionary<string, List<Person>> peopleCollection, PropertyLogic propertyLogic, List<PropertyHolder[]> propertyHolderCollections)
|
||||
{
|
||||
if (_Log is null)
|
||||
throw new Exception($"{nameof(_Log)} is null!");
|
||||
@ -673,8 +674,10 @@ public class DlibDotNet
|
||||
_Exceptions.Add(sourceDirectory);
|
||||
if (exceptionCount == 0 && _ArgZeroIsConfigurationRootDirectory)
|
||||
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)
|
||||
propertyLogic.AddToPropertyLogicAllCollection(filteredPropertyHolderCollection);
|
||||
if (exceptionCount == 0 && _Configuration.LoadOrCreateThenSaveImageFacesResults.Value && _Configuration.SaveShortcuts.HasValue && _Configuration.SaveShortcuts.Value && propertyLogic.NamedFaceInfoDeterministicHashCodeIndices.Any())
|
||||
_Faces.SaveShortcuts(configuration, juliePhares, model, predictorModel, propertyLogic, peopleCollection, outputResolution, filteredPropertyHolderCollection, propertyCollection, faceCollections);
|
||||
if (exceptionCount == 0 && _Configuration.LoadOrCreateThenSaveDistanceResults.HasValue && _Configuration.LoadOrCreateThenSaveDistanceResults.Value)
|
||||
_Distance.LoadOrCreateThenSaveDistanceResults(configuration, model, predictorModel, sourceDirectory, outputResolution, sourceDirectoryChanges, filteredPropertyHolderCollection, faceCollections);
|
||||
if (_Resize.AngleBracketCollection.Any())
|
||||
@ -696,6 +699,7 @@ public class DlibDotNet
|
||||
}
|
||||
if (_ArgZeroIsConfigurationRootDirectory && outputResolution == _Configuration.OutputResolutions[0])
|
||||
{
|
||||
propertyLogic.SaveAllCollection();
|
||||
if (!_Configuration.LoadOrCreateThenSaveImageFacesResults.Value && !_Configuration.LoadOrCreateThenSaveDirectoryDistanceResults.Value && !_Configuration.LoadOrCreateThenSaveDistanceResults.Value)
|
||||
break;
|
||||
if (_Exceptions.Count == 0)
|
||||
@ -729,8 +733,9 @@ public class DlibDotNet
|
||||
private void Search(Property.Models.Configuration configuration, string[] juliePhares, bool reverse, Model model, PredictorModel predictorModel, string argZero, Person[] people)
|
||||
{
|
||||
PropertyLogic propertyLogic = GetPropertyLogic();
|
||||
Dictionary<string, List<Person>> peopleCollection = A2_People.Convert(people);
|
||||
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);
|
||||
FullDoWork(configuration, juliePhares, model, predictorModel, argZero, peopleCollection, propertyLogic, propertyHolderCollections);
|
||||
}
|
||||
|
||||
internal void RenameQueue(Property.Models.Configuration configuration, Model model, PredictorModel predictorModel) => _Rename.RenameQueue(configuration, model, predictorModel);
|
||||
|
@ -52,31 +52,12 @@
|
||||
<PackageReference Include="ShellProgressBar" Version="5.1.0" />
|
||||
<PackageReference Include="WindowsShortcutFactory" Version="1.0.1" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="DlibDotNet" Version="19.21.0.20210302" />
|
||||
<!--PackageReference Include="configuration.MKL" Version="19.21.0.20210302" /-->
|
||||
<!--PackageReference Include="DlibDotNet-WithCUDA" Version="19.17.0.20190429" /-->
|
||||
<!--PackageReference Include="configuration.CUDA92" Version="19.21.0.20210302" /-->
|
||||
<!--PackageReference Include="configuration.CUDA102" Version="19.21.0.20210302" /-->
|
||||
<!--PackageReference Include="configuration.CUDA110" Version="19.21.0.20210302" /-->
|
||||
<!--PackageReference Include="configuration.CUDA111" Version="19.21.0.20210302" /-->
|
||||
<!--PackageReference Include="configuration.CUDA112" Version="19.21.0.20210302" /-->
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="FaceRecognitionDotNet" Version="1.3.0.4" />
|
||||
<!--PackageReference Include="FaceRecognitionDotNet.MKL" Version="1.3.0.4" /-->
|
||||
<!--PackageReference Include="FaceRecognitionDotNet-WithCUDA" Version="1.2.3.10" /-->
|
||||
<!--PackageReference Include="FaceRecognitionDotNet.CUDA92" Version="1.3.0.4" /-->
|
||||
<!--PackageReference Include="FaceRecognitionDotNet.CUDA102" Version="1.3.0.4" /-->
|
||||
<!--PackageReference Include="FaceRecognitionDotNet.CUDA110" Version="1.3.0.4" /-->
|
||||
<!--PackageReference Include="FaceRecognitionDotNet.CUDA111" Version="1.3.0.4" /-->
|
||||
<!--PackageReference Include="FaceRecognitionDotNet.CUDA112" Version="1.3.0.4" /-->
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Shared\View-by-Distance.Shared.csproj" />
|
||||
<ProjectReference Include="..\Property\Property.csproj" />
|
||||
<ProjectReference Include="..\Metadata\Metadata.csproj" />
|
||||
<ProjectReference Include="..\Resize\Resize.csproj" />
|
||||
<ProjectReference Include="..\FaceRecognitionDotNet\FaceRecognitionDotNet.csproj" />
|
||||
<ProjectReference Include="..\Property-Compare\Property-Compare.csproj" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
@ -76,4 +76,18 @@ internal class A2_People
|
||||
return results.ToArray();
|
||||
}
|
||||
|
||||
internal static Dictionary<string, List<Person>> Convert(Person[] people)
|
||||
{
|
||||
Dictionary<string, List<Person>> results = new();
|
||||
string personKey;
|
||||
foreach (Person person in people)
|
||||
{
|
||||
personKey = Shared.Models.Stateless.Methods.IPersonBirthday.GetFormatted(person.Birthday);
|
||||
if (!results.ContainsKey(personKey))
|
||||
results.Add(personKey, new List<Person>());
|
||||
results[personKey].Add(person);
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
using FaceRecognitionDotNet;
|
||||
using System.Drawing;
|
||||
using System.Text.Json;
|
||||
using View_by_Distance.Metadata.Models;
|
||||
using View_by_Distance.Property.Models;
|
||||
using View_by_Distance.Resize.Models;
|
||||
using View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
namespace View_by_Distance.Instance.Models;
|
||||
|
||||
@ -33,7 +33,7 @@ internal class D2_FaceLandmarks
|
||||
|
||||
#pragma warning disable CA1416
|
||||
|
||||
private static Bitmap RotateBitmap(System.Drawing.Image image, float angle)
|
||||
private static Bitmap RotateBitmap(Image image, float angle)
|
||||
{
|
||||
Bitmap result;
|
||||
Bitmap bitmap = new(image);
|
||||
@ -63,7 +63,7 @@ internal class D2_FaceLandmarks
|
||||
rotatedImageFileFullName = imageFiles[i][1];
|
||||
try
|
||||
{
|
||||
using (System.Drawing.Image image = System.Drawing.Image.FromFile(resizedFileInfo.FullName))
|
||||
using (Image image = Image.FromFile(resizedFileInfo.FullName))
|
||||
{
|
||||
using Graphics graphic = Graphics.FromImage(image);
|
||||
if (face.FaceLandmarks is null || !face.FaceLandmarks.Any())
|
||||
@ -92,7 +92,7 @@ internal class D2_FaceLandmarks
|
||||
}
|
||||
if (face.α.HasValue)
|
||||
{
|
||||
using System.Drawing.Image image = System.Drawing.Image.FromFile(resizedFileInfo.FullName);
|
||||
using Image image = Image.FromFile(resizedFileInfo.FullName);
|
||||
rotated = RotateBitmap(image, (float)face.α.Value);
|
||||
if (rotated is not null)
|
||||
{
|
||||
|
@ -1,14 +1,15 @@
|
||||
using FaceRecognitionDotNet;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using System.Text.RegularExpressions;
|
||||
using View_by_Distance.FaceRecognitionDotNet;
|
||||
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.Stateless;
|
||||
using WindowsShortcutFactory;
|
||||
|
||||
namespace View_by_Distance.Instance.Models;
|
||||
@ -32,8 +33,8 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
protected double? _Α;
|
||||
protected DateTime _DateTime;
|
||||
protected Shared.Models.FaceEncoding _FaceEncoding;
|
||||
protected Dictionary<string, Shared.Models.FacePoint[]> _FaceLandmarks;
|
||||
protected Shared.Models.Location _Location;
|
||||
protected Dictionary<string, FacePoint[]> _FaceLandmarks;
|
||||
protected Location _Location;
|
||||
protected int? _LocationIndex;
|
||||
protected OutputResolution _OutputResolution;
|
||||
protected bool _Populated;
|
||||
@ -41,9 +42,9 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
public double? α => _Α;
|
||||
public DateTime DateTime => _DateTime;
|
||||
public Shared.Models.FaceEncoding FaceEncoding => _FaceEncoding;
|
||||
public Dictionary<string, Shared.Models.FacePoint[]> FaceLandmarks => _FaceLandmarks;
|
||||
public Dictionary<string, FacePoint[]> FaceLandmarks => _FaceLandmarks;
|
||||
public OutputResolution OutputResolution => _OutputResolution;
|
||||
public Shared.Models.Location Location => _Location;
|
||||
public Location Location => _Location;
|
||||
public int? LocationIndex => _LocationIndex;
|
||||
public bool Populated => _Populated;
|
||||
public string RelativePath => _RelativePath;
|
||||
@ -51,7 +52,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
#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)
|
||||
public D_Face(double? α, DateTime dateTime, Shared.Models.FaceEncoding faceEncoding, Dictionary<string, FacePoint[]> faceLandmarks, Location location, int? locationIndex, OutputResolution outputResolution, bool populated, string relativePath)
|
||||
{
|
||||
_Α = α;
|
||||
_DateTime = dateTime;
|
||||
@ -76,7 +77,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
_WriteIndentedJsonSerializerOptions = new JsonSerializerOptions { WriteIndented = true };
|
||||
}
|
||||
|
||||
private D_Face(Shared.Models.Location location)
|
||||
private D_Face(Location location)
|
||||
{
|
||||
_Α = α;
|
||||
_DateTime = DateTime.MinValue;
|
||||
@ -102,12 +103,12 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
_RelativePath = string.Empty;
|
||||
}
|
||||
|
||||
private D_Face(A_Property property, int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation, string relativePath, int? i, Shared.Models.Location location)
|
||||
private D_Face(A_Property property, int outputResolutionWidth, int outputResolutionHeight, int outputResolutionOrientation, string relativePath, int? i, Location location)
|
||||
{
|
||||
DateTime?[] dateTimes;
|
||||
dateTimes = new DateTime?[] { property.CreationTime, property.LastWriteTime, property.DateTime, property.DateTimeDigitized, property.DateTimeOriginal, property.GPSDateStamp };
|
||||
_DateTime = (from l in dateTimes where l.HasValue select l.Value).Min();
|
||||
_FaceLandmarks = new Dictionary<string, Shared.Models.FacePoint[]>();
|
||||
_FaceLandmarks = new Dictionary<string, FacePoint[]>();
|
||||
_OutputResolution = new(outputResolutionHeight, outputResolutionOrientation, outputResolutionWidth);
|
||||
_Location = location;
|
||||
_LocationIndex = i;
|
||||
@ -223,15 +224,15 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
int width;
|
||||
int height;
|
||||
Graphics graphics;
|
||||
Rectangle rectangle;
|
||||
Location location;
|
||||
Bitmap preRotated;
|
||||
Shared.Models.Location location;
|
||||
Rectangle rectangle;
|
||||
using Bitmap source = new(resizedFileInfo.FullName);
|
||||
for (int i = 0; i < faceCollection.Count; i++)
|
||||
{
|
||||
if (!faceCollection[i].Populated || faceCollection[i]?.Location is null)
|
||||
continue;
|
||||
location = new Shared.Models.Location(faceCollection[i].Location.Confidence,
|
||||
location = new Location(faceCollection[i].Location.Confidence,
|
||||
faceCollection[i].Location.Bottom,
|
||||
faceCollection[i].Location.Left,
|
||||
faceCollection[i].Location.Right,
|
||||
@ -255,7 +256,7 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
throw new Exception();
|
||||
if (_Configuration.NumJitters is null)
|
||||
throw new Exception();
|
||||
FaceRecognitionDotNet.Location[] locations;
|
||||
Location[] locations;
|
||||
const int numberOfTimesToUpSample = 1;
|
||||
FaceRecognitionDotNet.Image? unknownImage = null;
|
||||
if (resizedFileInfo.Exists)
|
||||
@ -284,18 +285,18 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
int rightEyeY;
|
||||
Bitmap rotated;
|
||||
string faceFile;
|
||||
Location location;
|
||||
Bitmap preRotated;
|
||||
Graphics graphics;
|
||||
D_Face? face = null;
|
||||
Rectangle rectangle;
|
||||
double[] rawEncoding;
|
||||
Shared.Models.Location location;
|
||||
FaceRecognitionDotNet.Image knownImage;
|
||||
FaceRecognitionDotNet.Image? knownImage;
|
||||
FaceRecognitionDotNet.Image? rotatedImage;
|
||||
Shared.Models.FaceEncoding faceEncoding;
|
||||
FaceRecognitionDotNet.Image rotatedImage;
|
||||
FaceRecognitionDotNet.FaceEncoding[] faceEncodings;
|
||||
IEnumerable<FaceRecognitionDotNet.FacePoint> facePoints;
|
||||
IDictionary<FacePart, IEnumerable<FaceRecognitionDotNet.FacePoint>>[] faceLandmarks;
|
||||
IEnumerable<FacePoint> facePoints;
|
||||
IDictionary<FacePart, IEnumerable<FacePoint>>[] faceLandmarks;
|
||||
using Bitmap source = unknownImage.ToBitmap();
|
||||
padding = (int)((source.Width + source.Height) / 2 * .01);
|
||||
for (int i = 0; i < locations.Length; i++)
|
||||
@ -319,27 +320,31 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
// source.Save(Path.Combine(_Configuration.RootDirectory, "source.jpg"));
|
||||
// preRotated.Save(Path.Combine(_Configuration.RootDirectory, $"{p} - preRotated.jpg"));
|
||||
using (knownImage = FaceRecognition.LoadImage(preRotated))
|
||||
faceLandmarks = faceRecognition.FaceLandmark(knownImage, faceLocations: null, _PredictorModel, _Model).ToArray();
|
||||
if (knownImage is null)
|
||||
throw new Exception($"{nameof(knownImage)} is null");
|
||||
faceLandmarks = faceRecognition.FaceLandmark(knownImage, faceLocations: null, _PredictorModel, _Model).ToArray();
|
||||
if (faceLandmarks.Length == 0 && p < _Configuration.PaddingLoops.Value)
|
||||
continue;
|
||||
else if (faceLandmarks.Length != 1)
|
||||
continue;
|
||||
foreach (KeyValuePair<FacePart, IEnumerable<FaceRecognitionDotNet.FacePoint>> keyValuePair in faceLandmarks[0])
|
||||
face.FaceLandmarks.Add(keyValuePair.Key.ToString(), (from l in keyValuePair.Value select new Shared.Models.FacePoint(l.Index, l.Point.X, l.Point.Y)).ToArray());
|
||||
foreach (KeyValuePair<FacePart, IEnumerable<FacePoint>> keyValuePair in faceLandmarks[0])
|
||||
face.FaceLandmarks.Add(keyValuePair.Key.ToString(), keyValuePair.Value.ToArray());
|
||||
if (!faceLandmarks[0].ContainsKey(FacePart.LeftEye) || !faceLandmarks[0].ContainsKey(FacePart.RightEye))
|
||||
continue;
|
||||
facePoints = faceLandmarks[0][FacePart.LeftEye];
|
||||
leftEyeX = (int)(from l in facePoints select l.Point.X).Average();
|
||||
leftEyeY = (int)(from l in facePoints select l.Point.Y).Average();
|
||||
leftEyeX = (int)(from l in facePoints select l.X).Average();
|
||||
leftEyeY = (int)(from l in facePoints select l.Y).Average();
|
||||
facePoints = faceLandmarks[0][FacePart.RightEye];
|
||||
rightEyeX = (int)(from l in facePoints select l.Point.X).Average();
|
||||
rightEyeY = (int)(from l in facePoints select l.Point.Y).Average();
|
||||
rightEyeX = (int)(from l in facePoints select l.X).Average();
|
||||
rightEyeY = (int)(from l in facePoints select l.Y).Average();
|
||||
α = Shared.Models.Stateless.Methods.IFace.Getα(rightEyeX, leftEyeX, rightEyeY, leftEyeY);
|
||||
using (rotated = RotateBitmap(preRotated, (float)α.Value))
|
||||
{
|
||||
// rotated.Save(Path.Combine(_Configuration.RootDirectory, $"{p} - rotated.jpg"));
|
||||
using (rotatedImage = FaceRecognition.LoadImage(rotated))
|
||||
faceEncodings = faceRecognition.FaceEncodings(rotatedImage, knownFaceLocation: null, _Configuration.NumJitters.Value, _PredictorModel, _Model).ToArray();
|
||||
if (rotatedImage is null)
|
||||
throw new Exception($"{nameof(rotatedImage)} is null");
|
||||
faceEncodings = faceRecognition.FaceEncodings(rotatedImage, knownFaceLocation: null, _Configuration.NumJitters.Value, _PredictorModel, _Model).ToArray();
|
||||
if (faceEncodings.Length == 0 && p < _Configuration.PaddingLoops.Value)
|
||||
continue;
|
||||
else if (faceEncodings.Length != 1)
|
||||
@ -495,29 +500,26 @@ 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)
|
||||
internal void SaveShortcuts(Property.Models.Configuration configuration, string[] juliePhares, Model model, PredictorModel predictorModel, PropertyLogic propertyLogic, Dictionary<string, List<Person>> peopleCollection, 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;
|
||||
bool? isWrongYear;
|
||||
FileInfo fileInfo;
|
||||
TimeSpan timeSpan;
|
||||
DateTime? birthDate;
|
||||
string copyDirectory;
|
||||
string? relativePath;
|
||||
string isWrongYearFlag;
|
||||
string subDirectoryName;
|
||||
DateTime minimumDateTime;
|
||||
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++)
|
||||
{
|
||||
@ -532,37 +534,42 @@ public class D_Face : Shared.Models.Properties.IFace, IFace
|
||||
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..]}");
|
||||
if (!propertyLogic.NamedFaceInfoDeterministicHashCodeIndices.ContainsKey(propertyHolder.Property.Id.Value))
|
||||
directory = Path.Combine(dFacesContentDirectory, $"Unnamed{relativePath[2..]}");
|
||||
else
|
||||
{
|
||||
oldIndex = propertyHolder.Property.Indices[1];
|
||||
if (!propertyLogic.NamedFaceInfo.ContainsKey(oldIndex))
|
||||
directory = Path.Combine(dFacesContentDirectory, $"Unnamed{relativePath[2..]}");
|
||||
faceCollection = faceCollections[i];
|
||||
keys = propertyLogic.NamedFaceInfoDeterministicHashCodeIndices[propertyHolder.Property.Id.Value];
|
||||
minimumDateTime = Property.Models.Stateless.A_Property.GetMinimumDateTime(propertyHolder.Property);
|
||||
(isWrongYear, _) = propertyHolder.Property.IsWrongYear(propertyHolder.ImageFileInfo.FullName, minimumDateTime);
|
||||
isWrongYearFlag = isWrongYear is null ? "#" : isWrongYear.Value ? "~" : "=";
|
||||
subDirectoryName = $"{isWrongYearFlag}{minimumDateTime:yyyy}";
|
||||
if (!faceCollection.Any())
|
||||
directory = Path.Combine(dFacesContentDirectory, $"None{relativePath[2..]}", subDirectoryName);
|
||||
else if (keys.Length != 1)
|
||||
directory = Path.Combine(dFacesContentDirectory, $"Not Supported{relativePath[2..]}", subDirectoryName);
|
||||
else if (faceCollection.Count != 1)
|
||||
directory = Path.Combine(dFacesContentDirectory, $"Many{relativePath[2..]}", subDirectoryName);
|
||||
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 (isWrongYear is not null && !isWrongYear.Value && personKey[..2] is "19" or "20")
|
||||
{
|
||||
personKey = keys[0];
|
||||
if (juliePhares.Contains(personKey))
|
||||
copyDirectory = Path.Combine(dFacesContentDirectory, "Named Images");
|
||||
directory = Path.Combine(dFacesContentDirectory, "Named Shortcuts", personKey);
|
||||
birthDate = Shared.Models.Stateless.Methods.IPersonBirthday.Get(personKey);
|
||||
if (birthDate.HasValue)
|
||||
{
|
||||
if (minimumDateTime < birthDate.Value)
|
||||
subDirectoryName = "!---";
|
||||
else
|
||||
{
|
||||
timeSpan = new(minimumDateTime.Ticks - birthDate.Value.Ticks);
|
||||
subDirectoryName = $"^{Math.Floor(timeSpan.TotalDays / 365):000}";
|
||||
}
|
||||
}
|
||||
}
|
||||
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..]}");
|
||||
directory = Path.Combine(dFacesContentDirectory, "Named Shortcuts", personKey, subDirectoryName);
|
||||
if (juliePhares.Contains(personKey))
|
||||
copyDirectory = Path.Combine(dFacesContentDirectory, "Named Images", personKey, subDirectoryName);
|
||||
}
|
||||
}
|
||||
if (!Directory.Exists(directory))
|
||||
@ -603,7 +610,7 @@ 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)
|
||||
private static bool HasLeftAndRight(Dictionary<string, FacePoint[]> faceLandmarks)
|
||||
{
|
||||
bool result = true;
|
||||
if (!faceLandmarks.ContainsKey(FacePart.LeftEye.ToString()))
|
||||
|
@ -1,10 +1,10 @@
|
||||
using FaceRecognitionDotNet;
|
||||
using System.Text.Json;
|
||||
using View_by_Distance.Instance.Models.Stateless;
|
||||
using View_by_Distance.Metadata.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.Stateless;
|
||||
|
||||
namespace View_by_Distance.Instance.Models;
|
||||
|
||||
|
@ -1,8 +1,8 @@
|
||||
using FaceRecognitionDotNet;
|
||||
using System.Text.Json;
|
||||
using View_by_Distance.Metadata.Models;
|
||||
using View_by_Distance.Property.Models;
|
||||
using View_by_Distance.Resize.Models;
|
||||
using View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
namespace View_by_Distance.Instance.Models;
|
||||
|
||||
|
@ -1,9 +1,10 @@
|
||||
using FaceRecognitionDotNet;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using View_by_Distance.FaceRecognitionDotNet;
|
||||
using View_by_Distance.Metadata.Models;
|
||||
using View_by_Distance.Property.Models;
|
||||
using View_by_Distance.Resize.Models;
|
||||
using View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
namespace View_by_Distance.Instance.Models;
|
||||
|
||||
@ -203,10 +204,10 @@ internal class E_Distance
|
||||
bool check = false;
|
||||
string parentCheck;
|
||||
FileInfo[] fileInfoCollection;
|
||||
System.IO.DirectoryInfo directoryInfo;
|
||||
System.IO.DirectoryInfo tvsDirectoryInfo;
|
||||
string fileNameWithoutExtension;
|
||||
List<string[]> directories = new();
|
||||
System.IO.DirectoryInfo directoryInfo;
|
||||
System.IO.DirectoryInfo tvsDirectoryInfo;
|
||||
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,
|
||||
@ -289,8 +290,8 @@ internal class E_Distance
|
||||
private static List<(string, List<Shared.Models.Face>, List<FaceEncoding>)> GetMatches(List<(string, List<KeyValuePair<string, Shared.Models.Face[]>>)> files)
|
||||
{
|
||||
List<(string, List<Shared.Models.Face>, List<FaceEncoding>)> results = new();
|
||||
List<Shared.Models.Face> faces;
|
||||
FaceEncoding faceEncoding;
|
||||
List<Shared.Models.Face> faces;
|
||||
List<FaceEncoding> faceEncodings;
|
||||
foreach ((string, List<KeyValuePair<string, Shared.Models.Face[]>>) file in files)
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
using FaceRecognitionDotNet;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using View_by_Distance.Property.Models;
|
||||
using View_by_Distance.Shared.Models.Methods;
|
||||
using View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
namespace View_by_Distance.Instance.Models;
|
||||
|
||||
|
@ -10,7 +10,6 @@ namespace View_by_Distance.Instance;
|
||||
|
||||
public class Program
|
||||
{
|
||||
|
||||
public static void Secondary(List<string> args)
|
||||
{
|
||||
LoggerConfiguration loggerConfiguration = new();
|
||||
|
@ -86,7 +86,7 @@
|
||||
"PropertiesChangedForResize": false,
|
||||
"Reverse": false,
|
||||
"xRootDirectory": "C:/Tmp/phares/Pictures",
|
||||
"RootDirectory": "F:/Tmp/Phares/Compare/Images 2022-07-27 - 20220727 - III",
|
||||
"RootDirectory": "C:/Tmp/Phares/Compare/Images 2022-07-27 - f642c5669a1d89d598a2efd70da9dc7129d02c15 - III",
|
||||
"SaveFullYearOfRandomFiles": true,
|
||||
"SaveResizedSubFiles": true,
|
||||
"SaveShortcuts": true,
|
||||
@ -159,7 +159,8 @@
|
||||
"176 x 176",
|
||||
"256 x 256",
|
||||
"353 x 353",
|
||||
"1024 x 768"
|
||||
"1024 x 768",
|
||||
"1920 x 1080"
|
||||
],
|
||||
"OutputResolutions": [
|
||||
"1920 x 1080"
|
||||
|
@ -100,7 +100,8 @@
|
||||
"176 x 176",
|
||||
"256 x 256",
|
||||
"353 x 353",
|
||||
"1024 x 768"
|
||||
"1024 x 768",
|
||||
"1920 x 1080"
|
||||
],
|
||||
"PropertyContentCollectionFiles": [],
|
||||
"SaveFaceLandmarkForOutputResolutions": [
|
||||
|
Reference in New Issue
Block a user