Change to the Normalized Pixel Percentage Formula
This commit is contained in:
@ -273,7 +273,6 @@ public partial class DlibDotNet
|
||||
configuration.MapLogicSigma,
|
||||
configuration.MappingDefaultName,
|
||||
configuration.MappingMoveUnableToMatch,
|
||||
configuration.MappingSaveFaceEncoding,
|
||||
configuration.MappingSaveNotMapped,
|
||||
configuration.MappingSaveMapped,
|
||||
configuration.MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping,
|
||||
@ -282,8 +281,6 @@ public partial class DlibDotNet
|
||||
configuration.PersonBirthdayFormat,
|
||||
configuration.PersonKeyFormat,
|
||||
configuration.SortingDaysDeltaTolerance,
|
||||
configuration.SortingFacesToSkipAfterSortBeforeLoad,
|
||||
configuration.SortingFacesToTakeAfterSortBeforeLoad,
|
||||
configuration.SortingMaximumPerFaceShouldBeHigh,
|
||||
configuration.SortingMaximumPerKey,
|
||||
configuration.SortingSigma);
|
||||
@ -740,7 +737,7 @@ public partial class DlibDotNet
|
||||
if (string.IsNullOrEmpty(eResultsFullGroupDirectory))
|
||||
throw new NullReferenceException(nameof(eResultsFullGroupDirectory));
|
||||
List<Face> distinctFilteredFaces = SetMappingThenGetDistinctFilteredFacesWithMapping(argZero, containers);
|
||||
List<Face> selectedFilteredFaces = E_Distance.GetSelectedFilteredFaces(_MapConfiguration, distinctFilteredFaces);
|
||||
List<Face> selectedFilteredFaces = E_Distance.GetSelectedFilteredFaces(distinctFilteredFaces);
|
||||
E_Distance.SetFaceDistances(_AppSettings.MaxDegreeOfParallelism, ticks, selectedFilteredFaces);
|
||||
MapLogic mapLogic = new(_AppSettings.MaxDegreeOfParallelism, _Configuration.PropertyConfiguration, _MapConfiguration, _Faces.FileNameExtension, _Faces.HiddenFileNameExtension, _FaceParts.FileNameExtension, ticks, personContainers, eResultsFullGroupDirectory, distinctFilteredFaces, distance);
|
||||
SortingContainer[] sortingContainers = E_Distance.SetFaceMappingSortingCollectionThenGetSortingContainers(_AppSettings.MaxDegreeOfParallelism, _MapConfiguration, ticks, mapLogic, selectedFilteredFaces);
|
||||
|
@ -34,7 +34,6 @@ public class Configuration
|
||||
[Display(Name = "Mapped Max Index"), Required] public int? MappedMaxIndex { get; set; }
|
||||
[Display(Name = "Mapping Default Name"), Required] public string MappingDefaultName { get; set; }
|
||||
[Display(Name = "Mapping Move Unable to Match by 1 Tick"), Required] public bool? MappingMoveUnableToMatch { get; set; }
|
||||
[Display(Name = "Mapping Save Face Encoding"), Required] public bool? MappingSaveFaceEncoding { get; set; }
|
||||
[Display(Name = "Mapping Save Mapped"), Required] public bool? MappingSaveMapped { get; set; }
|
||||
[Display(Name = "Mapping Save Not Mapped"), Required] public bool? MappingSaveNotMapped { get; set; }
|
||||
[Display(Name = "Mapping Use Deterministic Hash Code Unknown Face Key Value Pairs for Add to Mapping"), Required] public bool? MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { get; set; }
|
||||
@ -69,8 +68,6 @@ public class Configuration
|
||||
[Display(Name = "Save Shortcuts"), Required] public string[] SaveShortcutsForOutputResolutions { get; set; }
|
||||
[Display(Name = "Skip Search"), Required] public bool? SkipSearch { get; set; }
|
||||
[Display(Name = "Sorting Days Delta Tolerance"), Required] public int? SortingDaysDeltaTolerance { get; set; }
|
||||
[Display(Name = "Sorting Faces To Skip After Sort Before Load"), Required] public int? SortingFacesToSkipAfterSortBeforeLoad { get; set; }
|
||||
[Display(Name = "Sorting Faces To Take After Sort Before Load"), Required] public int? SortingFacesToTakeAfterSortBeforeLoad { get; set; }
|
||||
[Display(Name = "SortingMaximumPerFaceShould be High"), Required] public int? SortingMaximumPerFaceShouldBeHigh { get; set; }
|
||||
[Display(Name = "Sorting Maximum Per Key"), Required] public int? SortingMaximumPerKey { get; set; }
|
||||
[Display(Name = "Sorting Sigma"), Required] public int? SortingSigma { get; set; }
|
||||
@ -132,8 +129,6 @@ public class Configuration
|
||||
throw new NullReferenceException(nameof(configuration.MappingDefaultName));
|
||||
if (configuration.MappingMoveUnableToMatch is null)
|
||||
throw new NullReferenceException(nameof(configuration.MappingMoveUnableToMatch));
|
||||
if (configuration.MappingSaveFaceEncoding is null)
|
||||
throw new NullReferenceException(nameof(configuration.MappingSaveFaceEncoding));
|
||||
if (configuration.MappingSaveNotMapped is null)
|
||||
throw new NullReferenceException(nameof(configuration.MappingSaveNotMapped));
|
||||
if (configuration.MappingSaveMapped is null)
|
||||
@ -194,10 +189,6 @@ public class Configuration
|
||||
throw new NullReferenceException(nameof(configuration.SkipSearch));
|
||||
if (configuration.SortingDaysDeltaTolerance is null)
|
||||
throw new NullReferenceException(nameof(configuration.SortingDaysDeltaTolerance));
|
||||
if (configuration.SortingFacesToSkipAfterSortBeforeLoad is null)
|
||||
throw new NullReferenceException(nameof(configuration.SortingFacesToSkipAfterSortBeforeLoad));
|
||||
if (configuration.SortingFacesToTakeAfterSortBeforeLoad is null)
|
||||
throw new NullReferenceException(nameof(configuration.SortingFacesToTakeAfterSortBeforeLoad));
|
||||
if (configuration.SortingMaximumPerFaceShouldBeHigh is null)
|
||||
throw new NullReferenceException(nameof(configuration.SortingMaximumPerFaceShouldBeHigh));
|
||||
if (configuration.SortingMaximumPerKey is null)
|
||||
@ -241,7 +232,6 @@ public class Configuration
|
||||
configuration.MappedMaxIndex,
|
||||
configuration.MappingDefaultName,
|
||||
configuration.MappingMoveUnableToMatch.Value,
|
||||
configuration.MappingSaveFaceEncoding.Value,
|
||||
configuration.MappingSaveNotMapped.Value,
|
||||
configuration.MappingSaveMapped.Value,
|
||||
configuration.MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping.Value,
|
||||
@ -275,8 +265,6 @@ public class Configuration
|
||||
configuration.SaveShortcutsForOutputResolutions,
|
||||
configuration.SkipSearch.Value,
|
||||
configuration.SortingDaysDeltaTolerance.Value,
|
||||
configuration.SortingFacesToSkipAfterSortBeforeLoad.Value,
|
||||
configuration.SortingFacesToTakeAfterSortBeforeLoad.Value,
|
||||
configuration.SortingMaximumPerFaceShouldBeHigh.Value,
|
||||
configuration.SortingMaximumPerKey.Value,
|
||||
configuration.SortingSigma.Value,
|
||||
|
@ -33,7 +33,6 @@ public class Configuration
|
||||
public int? MappedMaxIndex { init; get; }
|
||||
public string MappingDefaultName { init; get; }
|
||||
public bool MappingMoveUnableToMatch { init; get; }
|
||||
public bool MappingSaveFaceEncoding { init; get; }
|
||||
public bool MappingSaveNotMapped { init; get; }
|
||||
public bool MappingSaveMapped { init; get; }
|
||||
public bool MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping { init; get; }
|
||||
@ -67,8 +66,6 @@ public class Configuration
|
||||
public string[] SaveShortcutsForOutputResolutions { init; get; }
|
||||
public bool SkipSearch { init; get; }
|
||||
public int SortingDaysDeltaTolerance { init; get; }
|
||||
public int SortingFacesToSkipAfterSortBeforeLoad { init; get; }
|
||||
public int SortingFacesToTakeAfterSortBeforeLoad { init; get; }
|
||||
public int SortingMaximumPerFaceShouldBeHigh { init; get; }
|
||||
public int SortingMaximumPerKey { init; get; }
|
||||
public int SortingSigma { init; get; }
|
||||
@ -101,7 +98,6 @@ public class Configuration
|
||||
int? mappedMaxIndex,
|
||||
string mappingDefaultName,
|
||||
bool mappingMoveUnableToMatch,
|
||||
bool mappingSaveFaceEncoding,
|
||||
bool mappingSaveNotMapped,
|
||||
bool mappingSaveMapped,
|
||||
bool mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping,
|
||||
@ -135,8 +131,6 @@ public class Configuration
|
||||
string[] saveShortcutsForOutputResolutions,
|
||||
bool skipSearch,
|
||||
int sortingDaysDeltaTolerance,
|
||||
int sortingFacesToSkipAfterSortBeforeLoad,
|
||||
int sortingFacesToTakeAfterSortBeforeLoad,
|
||||
int sortingMaximumPerFaceShouldBeHigh,
|
||||
int sortingMaximumPerKey,
|
||||
int sortingSigma,
|
||||
@ -168,7 +162,6 @@ public class Configuration
|
||||
MappedMaxIndex = mappedMaxIndex;
|
||||
MappingDefaultName = mappingDefaultName;
|
||||
MappingMoveUnableToMatch = mappingMoveUnableToMatch;
|
||||
MappingSaveFaceEncoding = mappingSaveFaceEncoding;
|
||||
MappingSaveNotMapped = mappingSaveNotMapped;
|
||||
MappingSaveMapped = mappingSaveMapped;
|
||||
MappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping = mappingUseDeterministicHashCodeUnknownFaceKeyValuePairsForAddToMapping;
|
||||
@ -202,8 +195,6 @@ public class Configuration
|
||||
SaveShortcutsForOutputResolutions = saveShortcutsForOutputResolutions;
|
||||
SkipSearch = skipSearch;
|
||||
SortingDaysDeltaTolerance = sortingDaysDeltaTolerance;
|
||||
SortingFacesToSkipAfterSortBeforeLoad = sortingFacesToSkipAfterSortBeforeLoad;
|
||||
SortingFacesToTakeAfterSortBeforeLoad = sortingFacesToTakeAfterSortBeforeLoad;
|
||||
SortingMaximumPerFaceShouldBeHigh = sortingMaximumPerFaceShouldBeHigh;
|
||||
SortingMaximumPerKey = sortingMaximumPerKey;
|
||||
SortingSigma = sortingSigma;
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Reflection;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using View_by_Distance.FaceRecognitionDotNet;
|
||||
@ -33,6 +34,7 @@ public class D_Face
|
||||
private readonly ImageCodecInfo _ImageCodecInfo;
|
||||
private readonly ModelParameter _ModelParameter;
|
||||
private readonly PredictorModel _PredictorModel;
|
||||
private readonly ConstructorInfo _ConstructorInfo;
|
||||
private readonly EncoderParameters _EncoderParameters;
|
||||
private readonly ImageCodecInfo _HiddenImageCodecInfo;
|
||||
private readonly EncoderParameters _HiddenEncoderParameters;
|
||||
@ -53,6 +55,10 @@ public class D_Face
|
||||
_HiddenImageCodecInfo = hiddenImageCodecInfo;
|
||||
_HiddenEncoderParameters = hiddenEncoderParameters;
|
||||
_HiddenFileNameExtension = hiddenFileNameExtension;
|
||||
ConstructorInfo? constructorInfo = typeof(PropertyItem).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Public, null, Array.Empty<Type>(), null);
|
||||
if (constructorInfo is null)
|
||||
throw new Exception();
|
||||
_ConstructorInfo = constructorInfo;
|
||||
_WriteIndentedAndWhenWritingNull = new JsonSerializerOptions { WriteIndented = true, DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull };
|
||||
}
|
||||
|
||||
@ -144,31 +150,65 @@ public class D_Face
|
||||
return result;
|
||||
}
|
||||
|
||||
private static byte[] GetBytes(string value)
|
||||
{
|
||||
byte[] results = new byte[value.Length + 1];
|
||||
for (int i = 0; i < value.Length; i++)
|
||||
results[i] = (byte)value[i];
|
||||
results[value.Length] = 0x00;
|
||||
return results;
|
||||
}
|
||||
|
||||
private PropertyItem GetPropertyItem(int id, string value)
|
||||
{
|
||||
PropertyItem result = (PropertyItem)_ConstructorInfo.Invoke(null);
|
||||
byte[] bytes = GetBytes(value);
|
||||
result.Id = id;
|
||||
result.Len = value.Length + 1;
|
||||
result.Type = 2;
|
||||
result.Value = bytes;
|
||||
return result;
|
||||
}
|
||||
|
||||
private void SaveFaces(FileHolder resizedFileHolder, List<(Face, FileInfo?, string)> collection)
|
||||
{
|
||||
int pixel;
|
||||
int width;
|
||||
int height;
|
||||
string json;
|
||||
Bitmap bitmap;
|
||||
Graphics graphics;
|
||||
Location? location;
|
||||
Rectangle rectangle;
|
||||
PropertyItem? propertyItem;
|
||||
int software = (int)IExif.Tags.Software;
|
||||
int userComment = (int)IExif.Tags.UserComment;
|
||||
using Bitmap source = new(resizedFileHolder.FullName);
|
||||
int imageDescription = (int)IExif.Tags.ImageDescription;
|
||||
foreach ((Face face, FileInfo? fileInfo, string fileName) in collection)
|
||||
{
|
||||
if (fileInfo is null)
|
||||
continue;
|
||||
if (face.FaceEncoding is null || face?.Location is null)
|
||||
if (face.FaceEncoding is null || face?.Location?.NormalizedPixelPercentage is null || face?.OutputResolution is null)
|
||||
continue;
|
||||
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(face.Location, _Configuration.LocationDigits, _Configuration.LocationFactor, source.Height, source.Width, collection.Count);
|
||||
if (location is null)
|
||||
continue;
|
||||
width = location.Right - location.Left;
|
||||
height = location.Bottom - location.Top;
|
||||
json = JsonSerializer.Serialize(face.FaceEncoding);
|
||||
pixel = Shared.Models.Stateless.Methods.ILocation.GetNormalizedPixelPercentage(face.Location, _Configuration.LocationDigits, _Configuration.LocationFactor, face.OutputResolution);
|
||||
rectangle = new Rectangle(location.Left, location.Top, width, height);
|
||||
using (bitmap = new(width, height))
|
||||
{
|
||||
using (graphics = Graphics.FromImage(bitmap))
|
||||
graphics.DrawImage(source, new Rectangle(0, 0, width, height), rectangle, GraphicsUnit.Pixel);
|
||||
propertyItem = GetPropertyItem(userComment, json);
|
||||
bitmap.SetPropertyItem(propertyItem);
|
||||
propertyItem = GetPropertyItem(imageDescription, pixel.ToString());
|
||||
bitmap.SetPropertyItem(propertyItem);
|
||||
propertyItem = GetPropertyItem(software, face.Location.NormalizedPixelPercentage.Value.ToString());
|
||||
bitmap.SetPropertyItem(propertyItem);
|
||||
bitmap.Save(fileInfo.FullName, _ImageCodecInfo, _EncoderParameters);
|
||||
}
|
||||
if (File.Exists(fileName))
|
||||
@ -304,7 +344,6 @@ public class D_Face
|
||||
results = JsonSerializer.Deserialize<List<Face>>(json);
|
||||
if (results is null)
|
||||
throw new NullReferenceException(nameof(results));
|
||||
results = Shared.Models.Stateless.Methods.IFace.GetVerifiedFaces(_Configuration.LocationDigits, _Configuration.LocationFactor, results);
|
||||
if (!_Configuration.ForceFaceLastWriteTimeToCreationTime)
|
||||
{
|
||||
normalizedPixelPercentageCollection = Shared.Models.Stateless.Methods.IFace.GetInts(results);
|
||||
|
@ -116,11 +116,11 @@ internal class E_Distance : Shared.Models.Methods.IFaceDistance
|
||||
return results;
|
||||
}
|
||||
|
||||
internal static List<Face> GetSelectedFilteredFaces(Map.Models.Configuration configuration, List<Face> distinctFilteredFaces)
|
||||
internal static List<Face> GetSelectedFilteredFaces(List<Face> distinctFilteredFaces)
|
||||
{
|
||||
List<Face> results;
|
||||
Face[] orderedFilteredFaces = (from l in distinctFilteredFaces orderby l.Mapping is not null, l.Mapping?.MappingFromItem.MinimumDateTime descending select l).ToArray();
|
||||
results = orderedFilteredFaces.Skip(configuration.SortingFacesToSkipAfterSortBeforeLoad).Take(configuration.SortingFacesToTakeAfterSortBeforeLoad).ToList();
|
||||
results = orderedFilteredFaces.ToList();
|
||||
return results;
|
||||
}
|
||||
|
||||
|
@ -66,8 +66,8 @@
|
||||
"ForceResizeLastWriteTimeToCreationTime": false,
|
||||
"LoadOrCreateThenSaveIndex": false,
|
||||
"LocationConfidenceFactor": 2,
|
||||
"LocationDigits": 6,
|
||||
"LocationFactor": 1000000,
|
||||
"LocationDigits": 9,
|
||||
"LocationFactor": 10000,
|
||||
"MapLogicSigma": 3,
|
||||
"MappedMaxIndex": 1034720,
|
||||
"MappingDefaultName": "John Doe~25",
|
||||
@ -113,8 +113,6 @@
|
||||
"SaveResizedSubFiles": true,
|
||||
"SkipSearch": false,
|
||||
"SortingDaysDeltaTolerance": 700,
|
||||
"SortingFacesToSkipAfterSortBeforeLoad": 0,
|
||||
"SortingFacesToTakeAfterSortBeforeLoad": 55000,
|
||||
"SortingMaximumPerFaceShouldBeHigh": 1000,
|
||||
"SortingMaximumPerKey": 27,
|
||||
"SortingSigma": 3,
|
||||
|
@ -66,8 +66,8 @@
|
||||
"ForceResizeLastWriteTimeToCreationTime": false,
|
||||
"LoadOrCreateThenSaveIndex": false,
|
||||
"LocationConfidenceFactor": 2,
|
||||
"LocationDigits": 6,
|
||||
"LocationFactor": 1000000,
|
||||
"LocationDigits": 9,
|
||||
"LocationFactor": 10000,
|
||||
"MapLogicSigma": 3,
|
||||
"MappedMaxIndex": 1034720,
|
||||
"MappingDefaultName": "John Doe~25",
|
||||
@ -112,8 +112,6 @@
|
||||
"SaveResizedSubFiles": true,
|
||||
"SkipSearch": false,
|
||||
"SortingDaysDeltaTolerance": 700,
|
||||
"SortingFacesToSkipAfterSortBeforeLoad": 0,
|
||||
"SortingFacesToTakeAfterSortBeforeLoad": 55000,
|
||||
"SortingMaximumPerFaceShouldBeHigh": 1000,
|
||||
"SortingMaximumPerKey": 27,
|
||||
"SortingSigma": 3,
|
||||
|
@ -66,8 +66,8 @@
|
||||
"ForceResizeLastWriteTimeToCreationTime": false,
|
||||
"LoadOrCreateThenSaveIndex": false,
|
||||
"LocationConfidenceFactor": 2,
|
||||
"LocationDigits": 6,
|
||||
"LocationFactor": 1000000,
|
||||
"LocationDigits": 9,
|
||||
"LocationFactor": 10000,
|
||||
"MapLogicSigma": 3,
|
||||
"MappedMaxIndex": 1034720,
|
||||
"MappingDefaultName": "John Doe~25",
|
||||
@ -112,8 +112,6 @@
|
||||
"SaveResizedSubFiles": true,
|
||||
"SkipSearch": false,
|
||||
"SortingDaysDeltaTolerance": 700,
|
||||
"SortingFacesToSkipAfterSortBeforeLoad": 0,
|
||||
"SortingFacesToTakeAfterSortBeforeLoad": 55000,
|
||||
"SortingMaximumPerFaceShouldBeHigh": 1000,
|
||||
"SortingMaximumPerKey": 27,
|
||||
"SortingSigma": 3,
|
||||
|
Reference in New Issue
Block a user