Removed old GetRectangle
RectangleIntersectMinimums AddUserSecrets
This commit is contained in:
parent
2ff966d6b0
commit
8863fd763f
@ -22,6 +22,7 @@ completedColumns:
|
|||||||
- [setup-photo-prism-again-in-wsl-docker](tasks/setup-photo-prism-again-in-wsl-docker.md)
|
- [setup-photo-prism-again-in-wsl-docker](tasks/setup-photo-prism-again-in-wsl-docker.md)
|
||||||
- [run-scan-originals](tasks/run-scan-originals.md)
|
- [run-scan-originals](tasks/run-scan-originals.md)
|
||||||
- [find-incorrectly-mapped-faces](tasks/find-incorrectly-mapped-faces.md)
|
- [find-incorrectly-mapped-faces](tasks/find-incorrectly-mapped-faces.md)
|
||||||
|
- [shrink-percent](tasks/shrink-percent.md)
|
||||||
|
|
||||||
## Done
|
## Done
|
||||||
|
|
||||||
|
13
.kanbn/tasks/shrink-percent.md
Normal file
13
.kanbn/tasks/shrink-percent.md
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
created: 2023-06-12T15:44:11.932Z
|
||||||
|
updated: 2023-06-12T15:45:59.891Z
|
||||||
|
assigned: ""
|
||||||
|
progress: 0
|
||||||
|
tags: []
|
||||||
|
---
|
||||||
|
|
||||||
|
# shrink-percent
|
||||||
|
|
||||||
|
## Sub-tasks
|
||||||
|
|
||||||
|
- [x] shrink percent of the intersect rectangle 0.99
|
@ -17,12 +17,13 @@ public partial class E_Distance
|
|||||||
private readonly bool _DistanceRenameToMatch;
|
private readonly bool _DistanceRenameToMatch;
|
||||||
private readonly float[] _RangeFaceConfidence;
|
private readonly float[] _RangeFaceConfidence;
|
||||||
private readonly bool _DistanceMoveUnableToMatch;
|
private readonly bool _DistanceMoveUnableToMatch;
|
||||||
|
private readonly float _RectangleIntersectMinimum;
|
||||||
private readonly List<string> _AllMappedFaceFiles;
|
private readonly List<string> _AllMappedFaceFiles;
|
||||||
private readonly List<string> _AllMappedFaceFileNames;
|
private readonly List<string> _AllMappedFaceFileNames;
|
||||||
private readonly double _RangeDistanceToleranceAverage;
|
private readonly double _RangeDistanceToleranceAverage;
|
||||||
private readonly List<string> _DuplicateMappedFaceFiles;
|
private readonly List<string> _DuplicateMappedFaceFiles;
|
||||||
|
|
||||||
public E_Distance(bool distanceMoveUnableToMatch, bool distanceRenameToMatch, int faceConfidencePercent, float[] rangeDistanceTolerance, float[] rangeFaceConfidence)
|
public E_Distance(bool distanceMoveUnableToMatch, bool distanceRenameToMatch, int faceConfidencePercent, float[] rangeDistanceTolerance, float[] rangeFaceConfidence, float[] rectangleIntersectMinimum)
|
||||||
{
|
{
|
||||||
_Debug = new();
|
_Debug = new();
|
||||||
_Moved = new();
|
_Moved = new();
|
||||||
@ -35,6 +36,7 @@ public partial class E_Distance
|
|||||||
_DistanceRenameToMatch = distanceRenameToMatch;
|
_DistanceRenameToMatch = distanceRenameToMatch;
|
||||||
_FaceConfidencePercent = faceConfidencePercent;
|
_FaceConfidencePercent = faceConfidencePercent;
|
||||||
_DistanceMoveUnableToMatch = distanceMoveUnableToMatch;
|
_DistanceMoveUnableToMatch = distanceMoveUnableToMatch;
|
||||||
|
_RectangleIntersectMinimum = rectangleIntersectMinimum.Max();
|
||||||
_RangeDistanceToleranceAverage = rangeDistanceTolerance.Average();
|
_RangeDistanceToleranceAverage = rangeDistanceTolerance.Average();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -242,7 +244,7 @@ public partial class E_Distance
|
|||||||
throw new NotSupportedException();
|
throw new NotSupportedException();
|
||||||
if (filteredFaces.Any())
|
if (filteredFaces.Any())
|
||||||
{
|
{
|
||||||
intersectFaces = Shared.Models.Stateless.Methods.ILocation.FilterByIntersect(filteredFaces, locationContainer.NormalizedRectangle);
|
intersectFaces = Shared.Models.Stateless.Methods.ILocation.FilterByIntersect(filteredFaces, locationContainer.NormalizedRectangle, _RectangleIntersectMinimum);
|
||||||
if (intersectFaces.Any())
|
if (intersectFaces.Any())
|
||||||
checkFaces.AddRange(GetClosestFaceByDistanceIgnoringTolerance(mappingFromItem, intersectFaces, modelsFaceEncoding));
|
checkFaces.AddRange(GetClosestFaceByDistanceIgnoringTolerance(mappingFromItem, intersectFaces, modelsFaceEncoding));
|
||||||
}
|
}
|
||||||
|
@ -140,12 +140,6 @@ public class D_Face
|
|||||||
|
|
||||||
#pragma warning disable CA1416
|
#pragma warning disable CA1416
|
||||||
|
|
||||||
private static (int width, int height) Get(string file)
|
|
||||||
{
|
|
||||||
using Bitmap source = new(file);
|
|
||||||
return new(source.Width, source.Height);
|
|
||||||
}
|
|
||||||
|
|
||||||
private PropertyItem GetPropertyItem(int id, string value)
|
private PropertyItem GetPropertyItem(int id, string value)
|
||||||
{
|
{
|
||||||
PropertyItem result = (PropertyItem)_ConstructorInfo.Invoke(null);
|
PropertyItem result = (PropertyItem)_ConstructorInfo.Invoke(null);
|
||||||
@ -304,7 +298,6 @@ public class D_Face
|
|||||||
{
|
{
|
||||||
List<LocationContainer<MetadataExtractor.Directory>> results = new();
|
List<LocationContainer<MetadataExtractor.Directory>> results = new();
|
||||||
string? json;
|
string? json;
|
||||||
int width, height;
|
|
||||||
Location? location;
|
Location? location;
|
||||||
Rectangle? rectangle;
|
Rectangle? rectangle;
|
||||||
List<int> skip = new();
|
List<int> skip = new();
|
||||||
@ -327,14 +320,12 @@ public class D_Face
|
|||||||
if (face.Location is not null && face.OutputResolution is not null)
|
if (face.Location is not null && face.OutputResolution is not null)
|
||||||
continue;
|
continue;
|
||||||
json = Metadata.Models.Stateless.Methods.IMetadata.GetOutputResolution(locationContainer.Directories);
|
json = Metadata.Models.Stateless.Methods.IMetadata.GetOutputResolution(locationContainer.Directories);
|
||||||
if (json is not null)
|
if (json is null)
|
||||||
{
|
|
||||||
outputResolutionCheck = JsonSerializer.Deserialize<OutputResolution>(json);
|
|
||||||
if (outputResolutionCheck is not null && (outputResolutionCheck.Width != outputResolutionWidth || outputResolutionCheck.Height != outputResolutionHeight))
|
|
||||||
continue;
|
continue;
|
||||||
}
|
outputResolutionCheck = JsonSerializer.Deserialize<OutputResolution>(json);
|
||||||
(width, height) = Get(locationContainer.File);
|
if (outputResolutionCheck is null || outputResolutionCheck.Width != outputResolutionWidth || outputResolutionCheck.Height != outputResolutionHeight)
|
||||||
rectangle = Shared.Models.Stateless.Methods.ILocation.GetRectangle(height, ILocation.Digits, ILocation.Factor, locationContainer.NormalizedRectangle, outputResolutionHeight, outputResolutionWidth, width);
|
continue;
|
||||||
|
rectangle = Shared.Models.Stateless.Methods.ILocation.GetRectangle(ILocation.Digits, locationContainer.NormalizedRectangle, outputResolutionCheck);
|
||||||
if (rectangle is null)
|
if (rectangle is null)
|
||||||
continue;
|
continue;
|
||||||
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(outputResolutionHeight, rectangle.Value, outputResolutionWidth);
|
location = Shared.Models.Stateless.Methods.ILocation.GetLocation(outputResolutionHeight, rectangle.Value, outputResolutionWidth);
|
||||||
|
@ -106,7 +106,7 @@ public partial class DlibDotNet
|
|||||||
_FaceParts = new D2_FaceParts(imageCodecInfo, encoderParameters, filenameExtension, configuration.CheckDFaceAndUpWriteDates, configuration.OverrideForFaceLandmarkImages);
|
_FaceParts = new D2_FaceParts(imageCodecInfo, encoderParameters, filenameExtension, configuration.CheckDFaceAndUpWriteDates, configuration.OverrideForFaceLandmarkImages);
|
||||||
}
|
}
|
||||||
_MapConfiguration = Get(configuration, _Faces.FileNameExtension, _Faces.HiddenFileNameExtension, _FaceParts.FileNameExtension);
|
_MapConfiguration = Get(configuration, _Faces.FileNameExtension, _Faces.HiddenFileNameExtension, _FaceParts.FileNameExtension);
|
||||||
_Distance = new(configuration.DistanceMoveUnableToMatch, configuration.DistanceRenameToMatch, _Configuration.FaceConfidencePercent, configuration.RangeDistanceTolerance, configuration.RangeFaceConfidence);
|
_Distance = new(configuration.DistanceMoveUnableToMatch, configuration.DistanceRenameToMatch, _Configuration.FaceConfidencePercent, configuration.RangeDistanceTolerance, configuration.RangeFaceConfidence, configuration.RectangleIntersectMinimums);
|
||||||
if (_PropertyRootExistedBefore || !_ArgZeroIsConfigurationRootDirectory)
|
if (_PropertyRootExistedBefore || !_ArgZeroIsConfigurationRootDirectory)
|
||||||
{
|
{
|
||||||
_GenealogicalDataCommunicationFooterLines = null;
|
_GenealogicalDataCommunicationFooterLines = null;
|
||||||
@ -783,7 +783,7 @@ public partial class DlibDotNet
|
|||||||
}
|
}
|
||||||
Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping = Map.Models.Stateless.Methods.IMapLogic.GetIdToNormalizedRectangleToFace(distinctFilteredMappingCollection);
|
Dictionary<int, Dictionary<int, Mapping>> idToNormalizedRectangleToMapping = Map.Models.Stateless.Methods.IMapLogic.GetIdToNormalizedRectangleToFace(distinctFilteredMappingCollection);
|
||||||
if (Directory.Exists(fPhotoPrismContentDirectory))
|
if (Directory.Exists(fPhotoPrismContentDirectory))
|
||||||
F_PhotoPrism.WriteMatches(fPhotoPrismContentDirectory, _Configuration.MappingDefaultName, _Configuration.PersonBirthdayFormat, ticks, distinctFilteredFaces, mapLogic);
|
F_PhotoPrism.WriteMatches(fPhotoPrismContentDirectory, _Configuration.MappingDefaultName, _Configuration.PersonBirthdayFormat, _Configuration.RectangleIntersectMinimums, ticks, distinctFilteredFaces, mapLogic);
|
||||||
if (_Configuration.SaveShortcutsForOutputResolutions.Contains(outputResolution))
|
if (_Configuration.SaveShortcutsForOutputResolutions.Contains(outputResolution))
|
||||||
mapLogic.SaveShortcutsForOutputResolutionsDuringMapLogic(containers, personKeyToIds, dFacesContentDirectory, distinctFilteredMappingCollection);
|
mapLogic.SaveShortcutsForOutputResolutionsDuringMapLogic(containers, personKeyToIds, dFacesContentDirectory, distinctFilteredMappingCollection);
|
||||||
if (!string.IsNullOrEmpty(_Configuration.PersonCharacters))
|
if (!string.IsNullOrEmpty(_Configuration.PersonCharacters))
|
||||||
|
@ -67,6 +67,7 @@ public class Configuration
|
|||||||
[Display(Name = "Face Distance Tolerance"), Required] public float[] RangeDistanceTolerance { get; set; }
|
[Display(Name = "Face Distance Tolerance"), Required] public float[] RangeDistanceTolerance { get; set; }
|
||||||
[Display(Name = "Face Area Permille Tolerance"), Required] public float[] RangeFaceAreaTolerance { get; set; }
|
[Display(Name = "Face Area Permille Tolerance"), Required] public float[] RangeFaceAreaTolerance { get; set; }
|
||||||
[Display(Name = "Location Minimum Confidence"), Required] public float[] RangeFaceConfidence { get; set; }
|
[Display(Name = "Location Minimum Confidence"), Required] public float[] RangeFaceConfidence { get; set; }
|
||||||
|
[Display(Name = "Rectangle Intersect Minimums"), Required] public float[] RectangleIntersectMinimums { get; set; }
|
||||||
[Display(Name = "Reverse"), Required] public bool? Reverse { get; set; }
|
[Display(Name = "Reverse"), Required] public bool? Reverse { get; set; }
|
||||||
[Display(Name = "Save Blur Hash For Output Resolutions"), Required] public string[] SaveBlurHashForOutputResolutions { get; set; }
|
[Display(Name = "Save Blur Hash For Output Resolutions"), Required] public string[] SaveBlurHashForOutputResolutions { get; set; }
|
||||||
[Display(Name = "Save Face Distances For Output Resolutions"), Required] public string[] SaveFaceDistancesForOutputResolutions { get; set; }
|
[Display(Name = "Save Face Distances For Output Resolutions"), Required] public string[] SaveFaceDistancesForOutputResolutions { get; set; }
|
||||||
@ -200,6 +201,7 @@ public class Configuration
|
|||||||
throw new NullReferenceException(nameof(configuration.RangeFaceConfidence));
|
throw new NullReferenceException(nameof(configuration.RangeFaceConfidence));
|
||||||
if (configuration.RangeDistanceTolerance is null || configuration.RangeDistanceTolerance.Length != 3)
|
if (configuration.RangeDistanceTolerance is null || configuration.RangeDistanceTolerance.Length != 3)
|
||||||
throw new NullReferenceException(nameof(configuration.RangeDistanceTolerance));
|
throw new NullReferenceException(nameof(configuration.RangeDistanceTolerance));
|
||||||
|
configuration.RectangleIntersectMinimums ??= Array.Empty<float>();
|
||||||
if (configuration.Reverse is null)
|
if (configuration.Reverse is null)
|
||||||
throw new NullReferenceException(nameof(configuration.Reverse));
|
throw new NullReferenceException(nameof(configuration.Reverse));
|
||||||
configuration.SaveBlurHashForOutputResolutions ??= Array.Empty<string>();
|
configuration.SaveBlurHashForOutputResolutions ??= Array.Empty<string>();
|
||||||
@ -289,6 +291,7 @@ public class Configuration
|
|||||||
configuration.RangeDistanceTolerance,
|
configuration.RangeDistanceTolerance,
|
||||||
configuration.RangeFaceAreaTolerance,
|
configuration.RangeFaceAreaTolerance,
|
||||||
configuration.RangeFaceConfidence,
|
configuration.RangeFaceConfidence,
|
||||||
|
configuration.RectangleIntersectMinimums,
|
||||||
configuration.Reverse.Value,
|
configuration.Reverse.Value,
|
||||||
configuration.SaveBlurHashForOutputResolutions,
|
configuration.SaveBlurHashForOutputResolutions,
|
||||||
configuration.SaveFaceDistancesForOutputResolutions,
|
configuration.SaveFaceDistancesForOutputResolutions,
|
||||||
|
@ -63,6 +63,7 @@ public class Configuration
|
|||||||
public float[] RangeDistanceTolerance { init; get; }
|
public float[] RangeDistanceTolerance { init; get; }
|
||||||
public float[] RangeFaceAreaTolerance { init; get; }
|
public float[] RangeFaceAreaTolerance { init; get; }
|
||||||
public float[] RangeFaceConfidence { init; get; }
|
public float[] RangeFaceConfidence { init; get; }
|
||||||
|
public float[] RectangleIntersectMinimums { init; get; }
|
||||||
public bool Reverse { init; get; }
|
public bool Reverse { init; get; }
|
||||||
public string[] SaveBlurHashForOutputResolutions { init; get; }
|
public string[] SaveBlurHashForOutputResolutions { init; get; }
|
||||||
public string[] SaveFaceDistancesForOutputResolutions { init; get; }
|
public string[] SaveFaceDistancesForOutputResolutions { init; get; }
|
||||||
@ -141,6 +142,7 @@ public class Configuration
|
|||||||
float[] rangeDistanceTolerance,
|
float[] rangeDistanceTolerance,
|
||||||
float[] rangeFaceAreaPermyriadTolerance,
|
float[] rangeFaceAreaPermyriadTolerance,
|
||||||
float[] rangeFaceConfidence,
|
float[] rangeFaceConfidence,
|
||||||
|
float[] rectangleIntersectMinimums,
|
||||||
bool reverse,
|
bool reverse,
|
||||||
string[] saveBlurHashForOutputResolutions,
|
string[] saveBlurHashForOutputResolutions,
|
||||||
string[] saveFaceDistancesForOutputResolutions,
|
string[] saveFaceDistancesForOutputResolutions,
|
||||||
@ -218,6 +220,7 @@ public class Configuration
|
|||||||
RangeDistanceTolerance = rangeDistanceTolerance;
|
RangeDistanceTolerance = rangeDistanceTolerance;
|
||||||
RangeFaceAreaTolerance = rangeFaceAreaPermyriadTolerance;
|
RangeFaceAreaTolerance = rangeFaceAreaPermyriadTolerance;
|
||||||
RangeFaceConfidence = rangeFaceConfidence;
|
RangeFaceConfidence = rangeFaceConfidence;
|
||||||
|
RectangleIntersectMinimums = rectangleIntersectMinimums;
|
||||||
Reverse = reverse;
|
Reverse = reverse;
|
||||||
SaveBlurHashForOutputResolutions = saveBlurHashForOutputResolutions;
|
SaveBlurHashForOutputResolutions = saveBlurHashForOutputResolutions;
|
||||||
SaveFaceDistancesForOutputResolutions = saveFaceDistancesForOutputResolutions;
|
SaveFaceDistancesForOutputResolutions = saveFaceDistancesForOutputResolutions;
|
||||||
|
@ -155,6 +155,9 @@
|
|||||||
0.2,
|
0.2,
|
||||||
0.8
|
0.8
|
||||||
],
|
],
|
||||||
|
"RectangleIntersectMinimums": [
|
||||||
|
0.99
|
||||||
|
],
|
||||||
"IgnoreRelativePaths": [],
|
"IgnoreRelativePaths": [],
|
||||||
"MixedYearRelativePaths": [],
|
"MixedYearRelativePaths": [],
|
||||||
"SaveFaceDistancesForOutputResolutions": [],
|
"SaveFaceDistancesForOutputResolutions": [],
|
||||||
|
@ -169,17 +169,19 @@ public class F_PhotoPrism
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void WriteMatches(string fPhotoPrismContentDirectory, string mappingDefaultName, string personBirthdayFormat, long ticks, List<Face> distinctFilteredFaces, Shared.Models.Methods.IMapLogic mapLogic)
|
public static void WriteMatches(string fPhotoPrismContentDirectory, string mappingDefaultName, string personBirthdayFormat, float[] rectangleIntersectMinimums, long ticks, List<Face> distinctFilteredFaces, Shared.Models.Methods.IMapLogic mapLogic)
|
||||||
{
|
{
|
||||||
string file;
|
string file;
|
||||||
string text;
|
string text;
|
||||||
|
double percent;
|
||||||
int? normalizedRectangle;
|
int? normalizedRectangle;
|
||||||
List<string> subjects = new();
|
List<string> subjects = new();
|
||||||
StringBuilder stringBuilder = new();
|
|
||||||
PersonContainer[]? personContainers;
|
PersonContainer[]? personContainers;
|
||||||
|
StringBuilder stringBuilder = new();
|
||||||
System.Drawing.Rectangle dlibRectangle;
|
System.Drawing.Rectangle dlibRectangle;
|
||||||
System.Drawing.Rectangle? prismRectangle;
|
System.Drawing.Rectangle? prismRectangle;
|
||||||
System.Drawing.Rectangle intersectRectangle;
|
System.Drawing.Rectangle intersectRectangle;
|
||||||
|
float rectangleIntersectMinimum = rectangleIntersectMinimums.Min();
|
||||||
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
Dictionary<int, PersonContainer[]>? normalizedRectangleToPersonContainers;
|
||||||
(MappingFromPhotoPrism MappingFromPhotoPrism, Shared.Models.Marker Marker, double Percent)[] sortedCollection;
|
(MappingFromPhotoPrism MappingFromPhotoPrism, Shared.Models.Marker Marker, double Percent)[] sortedCollection;
|
||||||
List<(MappingFromPhotoPrism MappingFromPhotoPrism, Shared.Models.Marker Marker, double Percent)> collection = new();
|
List<(MappingFromPhotoPrism MappingFromPhotoPrism, Shared.Models.Marker Marker, double Percent)> collection = new();
|
||||||
@ -201,14 +203,14 @@ public class F_PhotoPrism
|
|||||||
{
|
{
|
||||||
foreach (Shared.Models.Marker marker in mappingFromPhotoPrism.Markers)
|
foreach (Shared.Models.Marker marker in mappingFromPhotoPrism.Markers)
|
||||||
{
|
{
|
||||||
prismRectangle = ILocation.GetRectangle(face.OutputResolution, mappingFromPhotoPrism.DatabaseFile, marker);
|
prismRectangle = ILocation.GetRectangle(mappingFromPhotoPrism.DatabaseFile, marker, face.OutputResolution);
|
||||||
if (prismRectangle is null)
|
if (prismRectangle is null)
|
||||||
continue;
|
continue;
|
||||||
intersectRectangle = System.Drawing.Rectangle.Intersect(dlibRectangle, prismRectangle.Value);
|
intersectRectangle = System.Drawing.Rectangle.Intersect(dlibRectangle, prismRectangle.Value);
|
||||||
if (intersectRectangle.Width == 0 || intersectRectangle.Height == 0)
|
if (intersectRectangle.Width == 0 || intersectRectangle.Height == 0)
|
||||||
continue;
|
continue;
|
||||||
double percent = (double)intersectRectangle.Width * intersectRectangle.Height / (dlibRectangle.Width * dlibRectangle.Height);
|
percent = (double)intersectRectangle.Width * intersectRectangle.Height / (dlibRectangle.Width * dlibRectangle.Height);
|
||||||
if (percent < 0.000001)
|
if (percent < rectangleIntersectMinimum)
|
||||||
continue;
|
continue;
|
||||||
collection.Add(new(mappingFromPhotoPrism, marker, percent));
|
collection.Add(new(mappingFromPhotoPrism, marker, percent));
|
||||||
}
|
}
|
||||||
@ -220,10 +222,10 @@ public class F_PhotoPrism
|
|||||||
}
|
}
|
||||||
if (subjects.Any())
|
if (subjects.Any())
|
||||||
{
|
{
|
||||||
file = Path.Combine(fPhotoPrismContentDirectory, $"{ticks}-subject_alias_update.sql");
|
file = Path.Combine(fPhotoPrismContentDirectory, $"{ticks}-{rectangleIntersectMinimum}-subject_alias_update.sql");
|
||||||
text = string.Join(Environment.NewLine, subjects.Distinct());
|
text = string.Join(Environment.NewLine, subjects.Distinct());
|
||||||
_ = IPath.WriteAllText(file, text, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
_ = IPath.WriteAllText(file, text, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||||
file = Path.Combine(fPhotoPrismContentDirectory, $"{ticks}-marker_name_update.sql");
|
file = Path.Combine(fPhotoPrismContentDirectory, $"{ticks}-{rectangleIntersectMinimum}-marker_name_update.sql");
|
||||||
text = stringBuilder.ToString();
|
text = stringBuilder.ToString();
|
||||||
_ = IPath.WriteAllText(file, text, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
_ = IPath.WriteAllText(file, text, updateDateWhenMatches: false, compareBeforeWrite: true, updateToWhenMatches: null);
|
||||||
}
|
}
|
||||||
|
@ -10,20 +10,20 @@ public interface ILocation
|
|||||||
static Models.Location? GetLocation(int height, Rectangle rectangle, int width) =>
|
static Models.Location? GetLocation(int height, Rectangle rectangle, int width) =>
|
||||||
Location.GetLocation(height, rectangle, width);
|
Location.GetLocation(height, rectangle, width);
|
||||||
|
|
||||||
List<Models.Face> TestStatic_FilterByIntersect(Models.Face[] faces, int normalizedRectangle) =>
|
List<Models.Face> TestStatic_FilterByIntersect(Models.Face[] faces, int normalizedRectangle, float rectangleIntersectMinimum) =>
|
||||||
FilterByIntersect(faces, normalizedRectangle);
|
FilterByIntersect(faces, normalizedRectangle, rectangleIntersectMinimum);
|
||||||
static List<Models.Face> FilterByIntersect(Models.Face[] faces, int normalizedRectangle) =>
|
static List<Models.Face> FilterByIntersect(Models.Face[] faces, int normalizedRectangle, float rectangleIntersectMinimum) =>
|
||||||
Location.FilterByIntersect(faces, normalizedRectangle);
|
Location.FilterByIntersect(faces, normalizedRectangle, rectangleIntersectMinimum);
|
||||||
|
|
||||||
Rectangle? TestStatic_GetRectangle(Models.OutputResolution outputResolution, DatabaseFile databaseFile, Marker marker) =>
|
Rectangle? TestStatic_GetRectangle(DatabaseFile databaseFile, Marker marker, Models.OutputResolution outputResolution) =>
|
||||||
GetRectangle(outputResolution, databaseFile, marker);
|
GetRectangle(databaseFile, marker, outputResolution);
|
||||||
static Rectangle? GetRectangle(Models.OutputResolution outputResolution, DatabaseFile databaseFile, Marker marker) =>
|
static Rectangle? GetRectangle(DatabaseFile databaseFile, Marker marker, Models.OutputResolution outputResolution) =>
|
||||||
Location.GetRectangle(outputResolution, databaseFile, marker);
|
Location.GetRectangle(databaseFile, marker, outputResolution);
|
||||||
|
|
||||||
Models.Location? TestStatic_GetLocation(Models.OutputResolution outputResolution, DatabaseFile databaseFile, Marker marker) =>
|
Models.Location? TestStatic_GetLocation(DatabaseFile databaseFile, Marker marker, Models.OutputResolution outputResolution) =>
|
||||||
GetLocation(outputResolution, databaseFile, marker);
|
GetLocation(databaseFile, marker, outputResolution);
|
||||||
static Models.Location? GetLocation(Models.OutputResolution outputResolution, DatabaseFile databaseFile, Marker marker) =>
|
static Models.Location? GetLocation(DatabaseFile databaseFile, Marker marker, Models.OutputResolution outputResolution) =>
|
||||||
Location.GetLocation(outputResolution, databaseFile, marker);
|
Location.GetLocation(databaseFile, marker, outputResolution);
|
||||||
|
|
||||||
List<Models.Location> TestStatic_GetLocations<T>(List<MappingFromPhotoPrism> mappingFromPhotoPrismCollection, List<Models.Face> faces, List<LocationContainer<T>> containers) =>
|
List<Models.Location> TestStatic_GetLocations<T>(List<MappingFromPhotoPrism> mappingFromPhotoPrismCollection, List<Models.Face> faces, List<LocationContainer<T>> containers) =>
|
||||||
GetLocations(mappingFromPhotoPrismCollection, faces, containers);
|
GetLocations(mappingFromPhotoPrismCollection, faces, containers);
|
||||||
@ -35,15 +35,10 @@ public interface ILocation
|
|||||||
static Rectangle? GetNormalizedRectangle(int locationDigits, int normalizedRectangle) =>
|
static Rectangle? GetNormalizedRectangle(int locationDigits, int normalizedRectangle) =>
|
||||||
Location.GetNormalizedRectangle(locationDigits, normalizedRectangle.ToString());
|
Location.GetNormalizedRectangle(locationDigits, normalizedRectangle.ToString());
|
||||||
|
|
||||||
Rectangle? TestStatic_GetRectangle(Rectangle checkRectangle, int locationDigits, int locationFactor, int normalizedRectangle, Models.OutputResolution outputResolution, bool useOldWay) =>
|
Rectangle? TestStatic_GetRectangle(int locationDigits, int normalizedRectangle, Models.OutputResolution outputResolution) =>
|
||||||
GetRectangle(checkRectangle, locationDigits, locationFactor, normalizedRectangle, outputResolution, useOldWay);
|
GetRectangle(locationDigits, normalizedRectangle, outputResolution);
|
||||||
static Rectangle? GetRectangle(Rectangle checkRectangle, int locationDigits, int locationFactor, int normalizedRectangle, Models.OutputResolution outputResolution, bool useOldWay) =>
|
static Rectangle? GetRectangle(int locationDigits, int normalizedRectangle, Models.OutputResolution outputResolution) =>
|
||||||
Location.GetRectangle(checkRectangle, OutputResolution.Get(outputResolution).Height, locationDigits, locationFactor, normalizedRectangle.ToString(), OutputResolution.Get(outputResolution).Width, useOldWay);
|
Location.GetRectangle(locationDigits, normalizedRectangle.ToString(), outputResolution);
|
||||||
Rectangle? TestStatic_GetRectangle(int height, int locationDigits, int locationFactor, int normalizedRectangle, int outputResolutionHeight, int outputResolutionWidth, int width) =>
|
|
||||||
|
|
||||||
GetRectangle(height, locationDigits, locationFactor, normalizedRectangle, outputResolutionHeight, outputResolutionWidth, width);
|
|
||||||
static Rectangle? GetRectangle(int height, int locationDigits, int locationFactor, int normalizedRectangle, int outputResolutionHeight, int outputResolutionWidth, int width) =>
|
|
||||||
Location.GetRectangle(height, locationDigits, locationFactor, normalizedRectangle.ToString(), outputResolutionHeight, outputResolutionWidth, width);
|
|
||||||
|
|
||||||
string TestStatic_GetLeftPadded(int locationDigits, string value) =>
|
string TestStatic_GetLeftPadded(int locationDigits, string value) =>
|
||||||
GetLeftPadded(locationDigits, value);
|
GetLeftPadded(locationDigits, value);
|
||||||
@ -60,11 +55,6 @@ public interface ILocation
|
|||||||
static string GetLeftPadded(int locationDigits, int value) =>
|
static string GetLeftPadded(int locationDigits, int value) =>
|
||||||
GetLeftPadded(locationDigits, value.ToString());
|
GetLeftPadded(locationDigits, value.ToString());
|
||||||
|
|
||||||
(int?, int?) TestStatic_GetXY(int locationDigits, int locationFactor, int width, int height, string normalizedRectangle) =>
|
|
||||||
GetXY(locationDigits, locationFactor, width, height, normalizedRectangle);
|
|
||||||
static (int?, int?) GetXY(int locationDigits, int locationFactor, int width, int height, string normalizedRectangle) =>
|
|
||||||
Location.GetXY(locationDigits, locationFactor, width, height, normalizedRectangle);
|
|
||||||
|
|
||||||
Models.Location? TestStatic_GetLocation(Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
|
Models.Location? TestStatic_GetLocation(Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
|
||||||
GetLocation(location, locationDigits, locationFactor, height, width, zCount);
|
GetLocation(location, locationDigits, locationFactor, height, width, zCount);
|
||||||
static Models.Location? GetLocation(Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
|
static Models.Location? GetLocation(Models.Location? location, int locationDigits, int locationFactor, int height, int width, int zCount) =>
|
||||||
|
@ -108,30 +108,6 @@ internal abstract class Location
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static (int?, int?) GetXY(int locationDigits, int locationFactor, int width, int height, string normalizedRectangle)
|
|
||||||
{
|
|
||||||
int? x;
|
|
||||||
int? y;
|
|
||||||
int center = 2;
|
|
||||||
decimal factor = locationFactor;
|
|
||||||
int each = (locationDigits - 1) / center;
|
|
||||||
string segmentA = normalizedRectangle[..each];
|
|
||||||
string segmentB = normalizedRectangle[each..^1];
|
|
||||||
if (!int.TryParse(segmentA, out int xNormalized) || !int.TryParse(segmentB, out int yNormalized))
|
|
||||||
{
|
|
||||||
x = null;
|
|
||||||
y = null;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
decimal xValue = xNormalized / factor * width;
|
|
||||||
decimal yValue = yNormalized / factor * height;
|
|
||||||
x = (int)Math.Round(xValue, 0);
|
|
||||||
y = (int)Math.Round(yValue, 0);
|
|
||||||
}
|
|
||||||
return new(x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static int GetConfidencePercent(int faceConfidencePercent, float[] rangeFaceConfidence, double confidence)
|
internal static int GetConfidencePercent(int faceConfidencePercent, float[] rangeFaceConfidence, double confidence)
|
||||||
{
|
{
|
||||||
int result = (int)(confidence / rangeFaceConfidence[1] * faceConfidencePercent);
|
int result = (int)(confidence / rangeFaceConfidence[1] * faceConfidencePercent);
|
||||||
@ -162,7 +138,7 @@ internal abstract class Location
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Rectangle? GetRectangle(int locationDigits, int height, string normalizedRectangle, int width)
|
internal static Rectangle? GetRectangle(int height, int locationDigits, string normalizedRectangle, int width)
|
||||||
{
|
{
|
||||||
Rectangle? result;
|
Rectangle? result;
|
||||||
Rectangle? rectangle = GetNormalizedRectangle(locationDigits, normalizedRectangle);
|
Rectangle? rectangle = GetNormalizedRectangle(locationDigits, normalizedRectangle);
|
||||||
@ -176,42 +152,15 @@ internal abstract class Location
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Rectangle? GetRectangle(Rectangle checkRectangle, int height, int locationDigits, int locationFactor, string normalizedRectangle, int width, bool useOldWay)
|
internal static Rectangle? GetRectangle(int locationDigits, string normalizedRectangle, Models.OutputResolution outputResolution)
|
||||||
{
|
{
|
||||||
Rectangle? result;
|
Rectangle? result;
|
||||||
if (useOldWay)
|
if (normalizedRectangle.Length != locationDigits || normalizedRectangle[0] is not '4' and not '8')
|
||||||
{
|
throw new NotSupportedException("Old way has been removed!");
|
||||||
(int? x, int? y) = GetXY(locationDigits, locationFactor, width, height, normalizedRectangle);
|
(int width, int height) = OutputResolution.Get(outputResolution);
|
||||||
if (x is null || y is null)
|
result = GetRectangle(height, locationDigits, normalizedRectangle, width);
|
||||||
throw new Exception();
|
|
||||||
result = new(x.Value - (checkRectangle.Width / 2), y.Value - (checkRectangle.Height / 2), checkRectangle.Width, checkRectangle.Height);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (normalizedRectangle.Length != locationDigits)
|
|
||||||
result = null;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
result = GetRectangle(locationDigits, height, normalizedRectangle, width);
|
|
||||||
if (result is null)
|
if (result is null)
|
||||||
throw new NullReferenceException(nameof(result));
|
throw new NullReferenceException(nameof(result));
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal static Rectangle? GetRectangle(int height, int locationDigits, int locationFactor, string normalizedRectangle, int outputResolutionHeight, int outputResolutionWidth, int width)
|
|
||||||
{
|
|
||||||
Rectangle? result;
|
|
||||||
if (normalizedRectangle.Length == locationDigits && normalizedRectangle[0] is '4' or '8')
|
|
||||||
result = GetRectangle(locationDigits, outputResolutionHeight, normalizedRectangle, outputResolutionWidth);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
(int? x, int? y) = GetXY(locationDigits, locationFactor, outputResolutionWidth, outputResolutionHeight, normalizedRectangle);
|
|
||||||
if (x is null || y is null)
|
|
||||||
throw new Exception();
|
|
||||||
result = new(x.Value - (width / 2), y.Value - (height / 2), width, height);
|
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,7 +170,7 @@ internal abstract class Location
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Rectangle? GetRectangle(Models.OutputResolution outputResolution, DatabaseFile databaseFile, Marker marker)
|
internal static Rectangle? GetRectangle(DatabaseFile databaseFile, Marker marker, Models.OutputResolution outputResolution)
|
||||||
{
|
{
|
||||||
Rectangle? result;
|
Rectangle? result;
|
||||||
bool matches = Matches(outputResolution, databaseFile);
|
bool matches = Matches(outputResolution, databaseFile);
|
||||||
@ -255,10 +204,10 @@ internal abstract class Location
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static Models.Location? GetLocation(Models.OutputResolution outputResolution, DatabaseFile databaseFile, Marker marker)
|
internal static Models.Location? GetLocation(DatabaseFile databaseFile, Marker marker, Models.OutputResolution outputResolution)
|
||||||
{
|
{
|
||||||
Models.Location? result;
|
Models.Location? result;
|
||||||
Rectangle? rectangle = GetRectangle(outputResolution, databaseFile, marker);
|
Rectangle? rectangle = GetRectangle(databaseFile, marker, outputResolution);
|
||||||
if (rectangle is null)
|
if (rectangle is null)
|
||||||
result = null;
|
result = null;
|
||||||
else
|
else
|
||||||
@ -300,7 +249,7 @@ internal abstract class Location
|
|||||||
foreach (Marker marker in mappingFromPhotoPrism.Markers)
|
foreach (Marker marker in mappingFromPhotoPrism.Markers)
|
||||||
{
|
{
|
||||||
any = false;
|
any = false;
|
||||||
prismRectangle = GetRectangle(outputResolution, mappingFromPhotoPrism.DatabaseFile, marker);
|
prismRectangle = GetRectangle(mappingFromPhotoPrism.DatabaseFile, marker, outputResolution);
|
||||||
if (prismRectangle is null)
|
if (prismRectangle is null)
|
||||||
break;
|
break;
|
||||||
location = GetLocation(mappingFromPhotoPrism.DatabaseFile, marker, prismRectangle.Value);
|
location = GetLocation(mappingFromPhotoPrism.DatabaseFile, marker, prismRectangle.Value);
|
||||||
@ -341,10 +290,9 @@ internal abstract class Location
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static List<Models.Face> FilterByIntersect(Models.Face[] faces, int normalizedRectangle)
|
internal static List<Models.Face> FilterByIntersect(Models.Face[] faces, int normalizedRectangle, float rectangleIntersectMinimum)
|
||||||
{
|
{
|
||||||
List<Models.Face> results = new();
|
List<Models.Face> results = new();
|
||||||
bool useOldWay;
|
|
||||||
double? percent;
|
double? percent;
|
||||||
Rectangle checkRectangle;
|
Rectangle checkRectangle;
|
||||||
Rectangle? sourceRectangle;
|
Rectangle? sourceRectangle;
|
||||||
@ -354,21 +302,17 @@ internal abstract class Location
|
|||||||
if (face.Location is null || face.OutputResolution is null)
|
if (face.Location is null || face.OutputResolution is null)
|
||||||
continue;
|
continue;
|
||||||
checkRectangle = new(face.Location.Left, face.Location.Top, face.Location.Right - face.Location.Left, face.Location.Bottom - face.Location.Top);
|
checkRectangle = new(face.Location.Left, face.Location.Top, face.Location.Right - face.Location.Left, face.Location.Bottom - face.Location.Top);
|
||||||
for (int i = 1; i < 3; i++)
|
sourceRectangle = GetRectangle(Stateless.ILocation.Digits, normalizedRectangle.ToString(), face.OutputResolution);
|
||||||
{
|
|
||||||
useOldWay = i == 1;
|
|
||||||
sourceRectangle = ILocation.GetRectangle(checkRectangle, Stateless.ILocation.Digits, Stateless.ILocation.Factor, normalizedRectangle, face.OutputResolution, useOldWay);
|
|
||||||
if (sourceRectangle is null)
|
if (sourceRectangle is null)
|
||||||
continue;
|
continue;
|
||||||
intersectRectangle = Rectangle.Intersect(checkRectangle, sourceRectangle.Value);
|
intersectRectangle = Rectangle.Intersect(checkRectangle, sourceRectangle.Value);
|
||||||
if (intersectRectangle.Width == 0 || intersectRectangle.Height == 0)
|
if (intersectRectangle.Width == 0 || intersectRectangle.Height == 0)
|
||||||
continue;
|
continue;
|
||||||
percent = (double)intersectRectangle.Width * intersectRectangle.Height / (checkRectangle.Width * checkRectangle.Height);
|
percent = (double)intersectRectangle.Width * intersectRectangle.Height / (checkRectangle.Width * checkRectangle.Height);
|
||||||
if (percent < 0.000001)
|
if (percent < rectangleIntersectMinimum)
|
||||||
continue;
|
continue;
|
||||||
results.Add(face);
|
results.Add(face);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
@ -6,6 +6,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<UserSecretsId>e8c3d25d-9715-4b35-9010-1cdc74840190</UserSecretsId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VSTestLogger>trx</VSTestLogger>
|
<VSTestLogger>trx</VSTestLogger>
|
||||||
|
@ -39,7 +39,8 @@ public partial class UnitTestCalculations
|
|||||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||||
.AddEnvironmentVariables()
|
.AddEnvironmentVariables()
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
|
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true)
|
||||||
|
.AddUserSecrets<UnitTestCalculations>();
|
||||||
configurationRoot = configurationBuilder.Build();
|
configurationRoot = configurationBuilder.Build();
|
||||||
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||||
@ -93,6 +94,7 @@ public partial class UnitTestCalculations
|
|||||||
throw new NullReferenceException(nameof(age));
|
throw new NullReferenceException(nameof(age));
|
||||||
Assert.IsNotNull(age);
|
Assert.IsNotNull(age);
|
||||||
Assert.IsTrue(age.Value > 42.6092);
|
Assert.IsTrue(age.Value > 42.6092);
|
||||||
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -114,6 +116,7 @@ public partial class UnitTestCalculations
|
|||||||
Assert.IsTrue($"({l}{d.ToString("0.00")[1..]})" == "(637967784888423594.62)");
|
Assert.IsTrue($"({l}{d.ToString("0.00")[1..]})" == "(637967784888423594.62)");
|
||||||
d = 0.45;
|
d = 0.45;
|
||||||
Assert.IsTrue($"({l}{d.ToString("0.00")[1..]})" == "(637967784888423594.45)");
|
Assert.IsTrue($"({l}{d.ToString("0.00")[1..]})" == "(637967784888423594.45)");
|
||||||
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -123,6 +126,7 @@ public partial class UnitTestCalculations
|
|||||||
Assert.IsTrue(successful == "_ Manual Copy Successful");
|
Assert.IsTrue(successful == "_ Manual Copy Successful");
|
||||||
string verify = $"_ {nameof(Shared.Models.Stateless.IMapLogic.ManualCopy).Humanize(LetterCasing.Title)} Verify";
|
string verify = $"_ {nameof(Shared.Models.Stateless.IMapLogic.ManualCopy).Humanize(LetterCasing.Title)} Verify";
|
||||||
Assert.IsTrue(verify == "_ Manual Copy Verify");
|
Assert.IsTrue(verify == "_ Manual Copy Verify");
|
||||||
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -154,6 +158,7 @@ public partial class UnitTestCalculations
|
|||||||
// "7680x4320 - Hog - Large"
|
// "7680x4320 - Hog - Large"
|
||||||
// [8] [string]:
|
// [8] [string]:
|
||||||
// "()"
|
// "()"
|
||||||
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -170,6 +175,7 @@ public partial class UnitTestCalculations
|
|||||||
Location location = new(bottom, confidence, left, right, top);
|
Location location = new(bottom, confidence, left, right, top);
|
||||||
_ = new Location(confidence, height, location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, 1);
|
_ = new Location(confidence, height, location, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, 1);
|
||||||
_ = new Location(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
_ = new Location(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
||||||
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -186,7 +192,7 @@ public partial class UnitTestCalculations
|
|||||||
width = 100;
|
width = 100;
|
||||||
height = 100;
|
height = 100;
|
||||||
areaPermyriad = IMapping.GetAreaPermyriad(faceAreaPermyriad, bottom, height, left, right, top, width);
|
areaPermyriad = IMapping.GetAreaPermyriad(faceAreaPermyriad, bottom, height, left, right, top, width);
|
||||||
Assert.IsTrue(areaPermyriad == 1000);
|
Assert.IsTrue(areaPermyriad == 10000);
|
||||||
left = 0;
|
left = 0;
|
||||||
right = 50;
|
right = 50;
|
||||||
top = 0;
|
top = 0;
|
||||||
@ -195,7 +201,7 @@ public partial class UnitTestCalculations
|
|||||||
height = 100;
|
height = 100;
|
||||||
location = new(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
location = new(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
||||||
areaPermyriad = IMapping.GetAreaPermyriad(faceAreaPermyriad, height, location, width);
|
areaPermyriad = IMapping.GetAreaPermyriad(faceAreaPermyriad, height, location, width);
|
||||||
Assert.IsTrue(areaPermyriad == 250);
|
Assert.IsTrue(areaPermyriad == 2500);
|
||||||
left = 0;
|
left = 0;
|
||||||
right = 25;
|
right = 25;
|
||||||
top = 0;
|
top = 0;
|
||||||
@ -205,30 +211,8 @@ public partial class UnitTestCalculations
|
|||||||
location = new(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
location = new(bottom, confidence, height, left, Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, right, top, width, 1);
|
||||||
OutputResolution outputResolution = new(height, 0, width);
|
OutputResolution outputResolution = new(height, 0, width);
|
||||||
areaPermyriad = IMapping.GetAreaPermyriad(faceAreaPermyriad, location, outputResolution);
|
areaPermyriad = IMapping.GetAreaPermyriad(faceAreaPermyriad, location, outputResolution);
|
||||||
Assert.IsTrue(areaPermyriad == 62);
|
Assert.IsTrue(areaPermyriad == 625);
|
||||||
}
|
NonThrowTryCatch();
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestNormalizedRectangle()
|
|
||||||
{
|
|
||||||
int? x, y;
|
|
||||||
int normalizedRectangle;
|
|
||||||
int bottom, height, left, right, top, width;
|
|
||||||
string normalizedRectanglePadded;
|
|
||||||
width = 2048;
|
|
||||||
height = 1365;
|
|
||||||
normalizedRectanglePadded = "617214031";
|
|
||||||
(x, y) = ILocation.GetXY(Shared.Models.Stateless.ILocation.Digits, Shared.Models.Stateless.ILocation.Factor, width, height, normalizedRectanglePadded);
|
|
||||||
if (x is null || y is null)
|
|
||||||
throw new Exception();
|
|
||||||
Assert.IsTrue(x.Value == 1264);
|
|
||||||
Assert.IsTrue(y.Value == 192);
|
|
||||||
left = x.Value;
|
|
||||||
right = x.Value + 125;
|
|
||||||
top = y.Value;
|
|
||||||
bottom = y.Value + 100;
|
|
||||||
normalizedRectangle = ILocation.GetNormalizedRectangle(bottom, height, left, Shared.Models.Stateless.ILocation.Digits, right, top, width);
|
|
||||||
Assert.IsTrue(normalizedRectangle == 461140607);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -241,6 +225,7 @@ public partial class UnitTestCalculations
|
|||||||
y2 = 10f;
|
y2 = 10f;
|
||||||
double distance = Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));
|
double distance = Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2));
|
||||||
Assert.IsTrue(distance == 1.4142135623730951);
|
Assert.IsTrue(distance == 1.4142135623730951);
|
||||||
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
@ -266,6 +251,7 @@ public partial class UnitTestCalculations
|
|||||||
value = 1.6f;
|
value = 1.6f;
|
||||||
check = ILocation.GetConfidencePercent(faceConfidencePercent, new float[] { minimum, target, maximum }, value);
|
check = ILocation.GetConfidencePercent(faceConfidencePercent, new float[] { minimum, target, maximum }, value);
|
||||||
Assert.IsTrue(check == 200);
|
Assert.IsTrue(check == 200);
|
||||||
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
@ -36,7 +36,9 @@ public class UnitTestExample
|
|||||||
isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
|
isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
|
||||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||||
.AddEnvironmentVariables()
|
.AddEnvironmentVariables()
|
||||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
|
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true)
|
||||||
|
.AddUserSecrets<UnitTestExample>();
|
||||||
configurationRoot = configurationBuilder.Build();
|
configurationRoot = configurationBuilder.Build();
|
||||||
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||||
|
@ -38,7 +38,8 @@ public partial class UnitTestHardCoded
|
|||||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||||
.AddEnvironmentVariables()
|
.AddEnvironmentVariables()
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
|
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true)
|
||||||
|
.AddUserSecrets<UnitTestHardCoded>();
|
||||||
configurationRoot = configurationBuilder.Build();
|
configurationRoot = configurationBuilder.Build();
|
||||||
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||||
@ -83,10 +84,13 @@ public partial class UnitTestHardCoded
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodDel()
|
public void TestMethodDel()
|
||||||
{
|
{
|
||||||
string source = @"F:\Tmp\Phares\Compare\Images 2022-09-15 - 7390c13 - III - Results\E) Distance\2022-09-15\7680 x 4320\7680x4320 - Hog - Large\()\(637992984751968513)";
|
string directory = @"F:\Tmp\Phares\Compare\Images 2022-09-15 - 7390c13 - III - Results\E) Distance\2022-09-15\7680 x 4320\7680x4320 - Hog - Large\()\(637992984751968513)";
|
||||||
|
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||||
|
{
|
||||||
for (int i = 1; i < 11; i++)
|
for (int i = 1; i < 11; i++)
|
||||||
_ = IPath.DeleteEmptyDirectories(source);
|
_ = IPath.DeleteEmptyDirectories(directory);
|
||||||
Assert.IsTrue(true);
|
Assert.IsTrue(true);
|
||||||
|
}
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -114,50 +118,16 @@ public partial class UnitTestHardCoded
|
|||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestMethodDamn()
|
|
||||||
{
|
|
||||||
// string name;
|
|
||||||
// string[] directories;
|
|
||||||
// string? directoryName;
|
|
||||||
// string checkDirectory;
|
|
||||||
// string sourceDirectory = @"F:\Tmp\Phares\Compare\Images 2022-09-15 - 7390c13 - III - Results\E) Distance\2022-09-15\7680 x 4320\7680x4320 - Hog - Large\()";
|
|
||||||
// directories = Directory.GetDirectories(sourceDirectory, "*", SearchOption.TopDirectoryOnly);
|
|
||||||
// foreach (string directory in directories)
|
|
||||||
// {
|
|
||||||
// directoryName = Path.GetDirectoryName(directory);
|
|
||||||
// if (directoryName is null)
|
|
||||||
// continue;
|
|
||||||
// name = Path.GetFileName(directory);
|
|
||||||
// if (name.Length is 1 or 20)
|
|
||||||
// continue;
|
|
||||||
// checkDirectory = Path.Combine(directoryName, "b", name);
|
|
||||||
// Directory.Move(directory, checkDirectory);
|
|
||||||
// }
|
|
||||||
// directories = Directory.GetDirectories(Path.Combine(sourceDirectory, "b"), "*", SearchOption.TopDirectoryOnly);
|
|
||||||
// foreach (string directory in directories)
|
|
||||||
// {
|
|
||||||
// directoryName = Path.GetDirectoryName(directory);
|
|
||||||
// if (directoryName is null)
|
|
||||||
// continue;
|
|
||||||
// name = Path.GetFileName(directory);
|
|
||||||
// if (name.Length is 1 or 20)
|
|
||||||
// continue;
|
|
||||||
// checkDirectory = Path.Combine(directoryName, $"{name[..^4]})");
|
|
||||||
// if (Directory.Exists(checkDirectory))
|
|
||||||
// continue;
|
|
||||||
// Directory.Move(directory, checkDirectory);
|
|
||||||
// }
|
|
||||||
// Assert.IsTrue(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodDel2()
|
public void TestMethodDel2()
|
||||||
{
|
{
|
||||||
string source = @"F:\Tmp\Phares\Compare\Images 2022-09-15 - 7390c13 - III - Results\E) Distance\2022-09-15\7680 x 4320\7680x4320 - Hog - Large\()\(637992984751968513)";
|
string directory = @"F:\Tmp\Phares\Compare\Images 2022-09-15 - 7390c13 - III - Results\E) Distance\2022-09-15\7680 x 4320\7680x4320 - Hog - Large\()\(637992984751968513)";
|
||||||
|
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||||
|
{
|
||||||
for (int i = 1; i < 11; i++)
|
for (int i = 1; i < 11; i++)
|
||||||
_ = IPath.DeleteEmptyDirectories(source);
|
_ = IPath.DeleteEmptyDirectories(directory);
|
||||||
Assert.IsTrue(true);
|
Assert.IsTrue(true);
|
||||||
|
}
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,10 +199,12 @@ public partial class UnitTestHardCoded
|
|||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodRenameAbandoned()
|
public void TestMethodRenameAbandoned()
|
||||||
|
{
|
||||||
|
string directory = @"D:\1) Images A\Images-1e85c0ba-Results\A2) People\1e85c0ba\{}\!\Abandoned";
|
||||||
|
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||||
{
|
{
|
||||||
string checkFile;
|
string checkFile;
|
||||||
string source = @"D:\1) Images A\Images-1e85c0ba-Results\A2) People\1e85c0ba\{}\!\Abandoned";
|
string[] files = Directory.GetFiles(directory, "*.abd", SearchOption.TopDirectoryOnly);
|
||||||
string[] files = Directory.GetFiles(source, "*.abd", SearchOption.TopDirectoryOnly);
|
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
checkFile = file[..^4];
|
checkFile = file[..^4];
|
||||||
@ -241,15 +213,18 @@ public partial class UnitTestHardCoded
|
|||||||
File.Move(file, checkFile);
|
File.Move(file, checkFile);
|
||||||
}
|
}
|
||||||
Assert.IsTrue(true);
|
Assert.IsTrue(true);
|
||||||
|
}
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodRenameDelete()
|
public void TestMethodRenameDelete()
|
||||||
|
{
|
||||||
|
string directory = @"D:\1) Images A\Images-1e85c0ba-Results\A) Property\1e85c0ba\{}";
|
||||||
|
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||||
{
|
{
|
||||||
string checkFile;
|
string checkFile;
|
||||||
string source = @"D:\1) Images A\Images-1e85c0ba-Results\A) Property\1e85c0ba\{}";
|
string[] files = Directory.GetFiles(directory, "*.del", SearchOption.AllDirectories);
|
||||||
string[] files = Directory.GetFiles(source, "*.del", SearchOption.AllDirectories);
|
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
checkFile = file[..^4];
|
checkFile = file[..^4];
|
||||||
@ -258,15 +233,18 @@ public partial class UnitTestHardCoded
|
|||||||
File.Move(file, checkFile);
|
File.Move(file, checkFile);
|
||||||
}
|
}
|
||||||
Assert.IsTrue(true);
|
Assert.IsTrue(true);
|
||||||
|
}
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodRenameOld()
|
public void TestMethodRenameOld()
|
||||||
|
{
|
||||||
|
string directory = @"D:\2) Images B\Not-Copy-Copy-1e85c0ba-Results\E) Distance\1e85c0ba\()";
|
||||||
|
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||||
{
|
{
|
||||||
string checkFile;
|
string checkFile;
|
||||||
string source = @"D:\2) Images B\Not-Copy-Copy-1e85c0ba-Results\E) Distance\1e85c0ba\()";
|
string[] files = Directory.GetFiles(directory, "*.old", SearchOption.AllDirectories);
|
||||||
string[] files = Directory.GetFiles(source, "*.old", SearchOption.AllDirectories);
|
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
{
|
{
|
||||||
checkFile = file[..^4];
|
checkFile = file[..^4];
|
||||||
@ -275,11 +253,15 @@ public partial class UnitTestHardCoded
|
|||||||
File.Move(file, checkFile);
|
File.Move(file, checkFile);
|
||||||
}
|
}
|
||||||
Assert.IsTrue(true);
|
Assert.IsTrue(true);
|
||||||
|
}
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodAncestryGenealogicalDataCommunication()
|
public void TestMethodAncestryGenealogicalDataCommunication()
|
||||||
|
{
|
||||||
|
string directory = "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])";
|
||||||
|
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||||
{
|
{
|
||||||
List<string> mappedLines;
|
List<string> mappedLines;
|
||||||
Dictionary<string, List<string>> individuals;
|
Dictionary<string, List<string>> individuals;
|
||||||
@ -287,16 +269,16 @@ public partial class UnitTestHardCoded
|
|||||||
GenealogicalDataCommunicationLines genealogicalDataCommunicationLines;
|
GenealogicalDataCommunicationLines genealogicalDataCommunicationLines;
|
||||||
List<(bool, string)> genealogicalDataCommunicationFiles = new()
|
List<(bool, string)> genealogicalDataCommunicationFiles = new()
|
||||||
{
|
{
|
||||||
new(false, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Ancestry-Roberts/Roberts Family Tree.ged"),
|
new(false, Path.Combine(directory, "Ancestry-Roberts/Roberts Family Tree.ged")),
|
||||||
new(false, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Ancestry-Phares/Phares Jr Family Tree.ged"),
|
new(false, Path.Combine(directory, "Ancestry-Phares/Phares Jr Family Tree.ged")),
|
||||||
new(true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160708345114583/638160708345114583.ged"),
|
new(true, Path.Combine(directory, "Code-638160708345114583/638160708345114583.ged")),
|
||||||
new(true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160728606500015/638160728606500015.ged"),
|
new(true, Path.Combine(directory, "Code-638160728606500015/638160728606500015.ged")),
|
||||||
new(true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160738845419877/638160738845419877.ged"),
|
new(true, Path.Combine(directory, "Code-638160738845419877/638160738845419877.ged")),
|
||||||
new(true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160743318283885/638160743318283885.ged"),
|
new(true, Path.Combine(directory, "Code-638160743318283885/638160743318283885.ged")),
|
||||||
new(false, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Ancestry-Porterfield/Porterfield Family Tree.ged"),
|
new(false, Path.Combine(directory, "Ancestry-Porterfield/Porterfield Family Tree.ged")),
|
||||||
new(true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160708345114583/638160708345114583-Export.ged"),
|
new(true, Path.Combine(directory, "Code-638160708345114583/638160708345114583-Export.ged")),
|
||||||
new(true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160738845419877/638160738845419877-Export.ged"),
|
new(true, Path.Combine(directory, "Code-638160738845419877/638160738845419877-Export.ged")),
|
||||||
new(true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160743318283885/638160743318283885-Export.ged"),
|
new(true, Path.Combine(directory, "Code-638160743318283885/638160743318283885-Export.ged")),
|
||||||
};
|
};
|
||||||
foreach ((bool requireNickName, string genealogicalDataCommunicationFile) in genealogicalDataCommunicationFiles)
|
foreach ((bool requireNickName, string genealogicalDataCommunicationFile) in genealogicalDataCommunicationFiles)
|
||||||
{
|
{
|
||||||
@ -312,11 +294,16 @@ public partial class UnitTestHardCoded
|
|||||||
if (IPath.WriteAllText($"{genealogicalDataCommunicationFile}.cln", string.Join(Environment.NewLine, mappedLines), updateDateWhenMatches: false, compareBeforeWrite: true))
|
if (IPath.WriteAllText($"{genealogicalDataCommunicationFile}.cln", string.Join(Environment.NewLine, mappedLines), updateDateWhenMatches: false, compareBeforeWrite: true))
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodAncestryGenealogicalDataCommunicationCleanToExport()
|
public void TestMethodAncestryGenealogicalDataCommunicationCleanToExport()
|
||||||
|
{
|
||||||
|
DateTime dateTime = DateTime.Now;
|
||||||
|
string saveDirectory = "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])";
|
||||||
|
if (Directory.Exists(Path.GetPathRoot(saveDirectory)) && Directory.Exists(saveDirectory))
|
||||||
{
|
{
|
||||||
int age;
|
int age;
|
||||||
long personKey;
|
long personKey;
|
||||||
@ -327,23 +314,21 @@ public partial class UnitTestHardCoded
|
|||||||
PersonName? personName;
|
PersonName? personName;
|
||||||
string personKeyFormatted;
|
string personKeyFormatted;
|
||||||
bool isDefaultName = false;
|
bool isDefaultName = false;
|
||||||
DateTime dateTime = DateTime.Now;
|
|
||||||
Dictionary<string, List<string>> individuals;
|
Dictionary<string, List<string>> individuals;
|
||||||
GenealogicalDataCommunication genealogicalDataCommunication;
|
GenealogicalDataCommunication genealogicalDataCommunication;
|
||||||
GenealogicalDataCommunicationLines genealogicalDataCommunicationLines;
|
GenealogicalDataCommunicationLines genealogicalDataCommunicationLines;
|
||||||
string saveDirectory = $"D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Ancestry-{dateTime.Ticks}";
|
|
||||||
List<(bool, bool, string)> genealogicalDataCommunicationFiles = new()
|
List<(bool, bool, string)> genealogicalDataCommunicationFiles = new()
|
||||||
{
|
{
|
||||||
new(false, false, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Ancestry-Roberts/Roberts Family Tree.ged.cln"),
|
new(false, false, Path.Combine(saveDirectory, "Ancestry-Roberts/Roberts Family Tree.ged.cln")),
|
||||||
new(false, false, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Ancestry-Phares/Phares Jr Family Tree.ged.cln"),
|
new(false, false, Path.Combine(saveDirectory, "Ancestry-Phares/Phares Jr Family Tree.ged.cln")),
|
||||||
new(true, true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160708345114583/638160708345114583.ged.cln"),
|
new(true, true, Path.Combine(saveDirectory, "Code-638160708345114583/638160708345114583.ged.cln")),
|
||||||
new(true, true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160728606500015/638160728606500015.ged.cln"),
|
new(true, true, Path.Combine(saveDirectory, "Code-638160728606500015/638160728606500015.ged.cln")),
|
||||||
new(true, true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160738845419877/638160738845419877.ged.cln"),
|
new(true, true, Path.Combine(saveDirectory, "Code-638160738845419877/638160738845419877.ged.cln")),
|
||||||
new(true, true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160743318283885/638160743318283885.ged.cln"),
|
new(true, true, Path.Combine(saveDirectory, "Code-638160743318283885/638160743318283885.ged.cln")),
|
||||||
new(false, false, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Ancestry-Porterfield/Porterfield Family Tree.ged.cln"),
|
new(false, false, Path.Combine(saveDirectory, "Ancestry-Porterfield/Porterfield Family Tree.ged.cln")),
|
||||||
new(true, true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160708345114583/638160708345114583-Export.ged.cln"),
|
new(true, true, Path.Combine(saveDirectory, "Code-638160708345114583/638160708345114583-Export.ged.cln")),
|
||||||
new(true, true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160738845419877/638160738845419877-Export.ged.cln"),
|
new(true, true, Path.Combine(saveDirectory, "Code-638160738845419877/638160738845419877-Export.ged.cln")),
|
||||||
new(true, true, "D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Code-638160743318283885/638160743318283885-Export.ged.cln"),
|
new(true, true, Path.Combine(saveDirectory, "Code-638160743318283885/638160743318283885-Export.ged.cln")),
|
||||||
};
|
};
|
||||||
foreach ((bool verify, bool requireNickName, string genealogicalDataCommunicationFile) in genealogicalDataCommunicationFiles)
|
foreach ((bool verify, bool requireNickName, string genealogicalDataCommunicationFile) in genealogicalDataCommunicationFiles)
|
||||||
{
|
{
|
||||||
@ -379,6 +364,7 @@ public partial class UnitTestHardCoded
|
|||||||
IGenealogicalDataCommunication.WriteFile(personKeyFormatted, personName, keyValuePair.Value, isDefaultName, directory, genealogicalDataCommunication, verify, first);
|
IGenealogicalDataCommunication.WriteFile(personKeyFormatted, personName, keyValuePair.Value, isDefaultName, directory, genealogicalDataCommunication, verify, first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -592,7 +578,7 @@ public partial class UnitTestHardCoded
|
|||||||
"MDevan Hazen 8/14/1999",
|
"MDevan Hazen 8/14/1999",
|
||||||
"MEthan Hazen 8/14/1999",
|
"MEthan Hazen 8/14/1999",
|
||||||
"FApril Hill 6/9/1980",
|
"FApril Hill 6/9/1980",
|
||||||
"MRandall Hill 1/16/1978", // https://www.facebook.com/randall.d.hill/about_contact_and_basic_info // https://www.facebook.com/photo.php?fbid=10154576010477639&set=pb.530957638.-2207520000.&type=3 // https://scontent-lax3-1.xx.fbcdn.net/v/t1.18169-9/16265790_10154576010477639_102119672782426718_n.jpg?_nc_cat=102&ccb=1-7&_nc_sid=174925&_nc_ohc=cWEECl9DMhoAX_qlUB-&_nc_ht=scontent-lax3-1.xx&oh=00_AfC4PZ-tytVowtRSu1AJtkxRkQb0_j0WSDk4MKquqs0img&oe=64531181
|
"MRandall Hill 1/16/1978", // https://www.facebook.com/randall.directory.hill/about_contact_and_basic_info // https://www.facebook.com/photo.php?fbid=10154576010477639&set=pb.530957638.-2207520000.&type=3 // https://scontent-lax3-1.xx.fbcdn.net/v/t1.18169-9/16265790_10154576010477639_102119672782426718_n.jpg?_nc_cat=102&ccb=1-7&_nc_sid=174925&_nc_ohc=cWEECl9DMhoAX_qlUB-&_nc_ht=scontent-lax3-1.xx&oh=00_AfC4PZ-tytVowtRSu1AJtkxRkQb0_j0WSDk4MKquqs0img&oe=64531181
|
||||||
"FBrenda Olson 8/27/1958", // https://www.facebook.com/barbara.olson.96/about_contact_and_basic_info
|
"FBrenda Olson 8/27/1958", // https://www.facebook.com/barbara.olson.96/about_contact_and_basic_info
|
||||||
"MChris Olson 11/13/1951",
|
"MChris Olson 11/13/1951",
|
||||||
"FShilo Zeches 4/9/1980",
|
"FShilo Zeches 4/9/1980",
|
||||||
@ -674,6 +660,10 @@ public partial class UnitTestHardCoded
|
|||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodFamily()
|
public void TestMethodFamily()
|
||||||
|
{
|
||||||
|
DateTime dateTime = DateTime.Now;
|
||||||
|
string saveDirectory = $"D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Norman-{dateTime.Ticks}";
|
||||||
|
if (Directory.Exists(Path.GetPathRoot(saveDirectory)) && Directory.Exists(saveDirectory))
|
||||||
{
|
{
|
||||||
int age;
|
int age;
|
||||||
string name;
|
string name;
|
||||||
@ -691,9 +681,7 @@ public partial class UnitTestHardCoded
|
|||||||
bool isDefaultName = false;
|
bool isDefaultName = false;
|
||||||
PersonBirthday personBirthday;
|
PersonBirthday personBirthday;
|
||||||
string[] family = GetFamily();
|
string[] family = GetFamily();
|
||||||
DateTime dateTime = DateTime.Now;
|
|
||||||
GenealogicalDataCommunication genealogicalDataCommunication;
|
GenealogicalDataCommunication genealogicalDataCommunication;
|
||||||
string saveDirectory = $"D:/1) Images A/Images-1e85c0ba-Results/A2) People/1e85c0ba/([])/Norman-{dateTime.Ticks}";
|
|
||||||
foreach (string familyMember in family)
|
foreach (string familyMember in family)
|
||||||
{
|
{
|
||||||
spaceSegments = familyMember[1..].Split(' ');
|
spaceSegments = familyMember[1..].Split(' ');
|
||||||
@ -732,9 +720,11 @@ public partial class UnitTestHardCoded
|
|||||||
genealogicalDataCommunication = new(null, null, null, null, null, null, null, 'U', personBirthday.Value, death, null);
|
genealogicalDataCommunication = new(null, null, null, null, null, null, null, 'U', personBirthday.Value, death, null);
|
||||||
IGenealogicalDataCommunication.WriteFile(personKeyFormatted, personName, null, isDefaultName, directory, genealogicalDataCommunication, verify, first);
|
IGenealogicalDataCommunication.WriteFile(personKeyFormatted, personName, null, isDefaultName, directory, genealogicalDataCommunication, verify, first);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Ignore]
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodGroup()
|
public void TestMethodGroup()
|
||||||
{
|
{
|
||||||
@ -761,14 +751,18 @@ public partial class UnitTestHardCoded
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodRename()
|
public void TestMethodRename()
|
||||||
{
|
{
|
||||||
// string[] directories = Directory.GetDirectories(@"D:\2) Images B\Not-Copy-Copy-1e85c0ba", "*;*", SearchOption.AllDirectories);
|
// string directory = @"D:\2) Images B\Not-Copy-Copy-1e85c0ba";
|
||||||
string[] directories = Directory.GetDirectories(@"D:\1) Images A\Images-1e85c0ba", "*;*", SearchOption.AllDirectories);
|
string directory = @"D:\1) Images A\Images-1e85c0ba";
|
||||||
// string[] directories = Directory.GetDirectories(@"D:\2) Images B\Not-Copy-Copy-1e85c0ba", "*", SearchOption.AllDirectories);
|
// string directory = @"D:\2) Images B\Not-Copy-Copy-1e85c0ba";
|
||||||
foreach (string directory in directories.OrderByDescending(l => l.Length - l.Replace(@"\", string.Empty).Length))
|
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||||
{
|
{
|
||||||
if (!directory.EndsWith(";9"))
|
string[] directories = Directory.GetDirectories(directory, "*;*", SearchOption.AllDirectories);
|
||||||
|
foreach (string subDirectory in directories.OrderByDescending(l => l.Length - l.Replace(@"\", string.Empty).Length))
|
||||||
|
{
|
||||||
|
if (!subDirectory.EndsWith(";9"))
|
||||||
continue;
|
continue;
|
||||||
Directory.Move(directory, $"{directory[..^2]} !9");
|
Directory.Move(subDirectory, $"{subDirectory[..^2]} !9");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
@ -776,9 +770,13 @@ public partial class UnitTestHardCoded
|
|||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMethodRenameForUnkown()
|
public void TestMethodRenameForUnkown()
|
||||||
{
|
{
|
||||||
string[] files = Directory.GetFiles(@"D:\1) Images A\Images-1e85c0ba-Results\E) Distance\1e85c0ba\(Bad-2023-06-18-less-0.4)", "*.unk", SearchOption.AllDirectories);
|
string directory = @"D:\1) Images A\Images-1e85c0ba-Results\E) Distance\1e85c0ba\(RectInt-2023-06-19-less-0.99)";
|
||||||
|
if (Directory.Exists(Path.GetPathRoot(directory)) && Directory.Exists(directory))
|
||||||
|
{
|
||||||
|
string[] files = Directory.GetFiles(directory, "*.unk", SearchOption.AllDirectories);
|
||||||
foreach (string file in files)
|
foreach (string file in files)
|
||||||
File.Move(file, file[..^4]);
|
File.Move(file, file[..^4]);
|
||||||
|
}
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,113 +0,0 @@
|
|||||||
using Microsoft.Extensions.Configuration;
|
|
||||||
using Microsoft.Extensions.Configuration.Json;
|
|
||||||
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
||||||
using Phares.Shared;
|
|
||||||
using Serilog;
|
|
||||||
using System.Diagnostics;
|
|
||||||
using System.Reflection;
|
|
||||||
using View_by_Distance.Shared.Models.Stateless.Methods;
|
|
||||||
using View_by_Distance.Tests.Models;
|
|
||||||
|
|
||||||
namespace View_by_Distance.Tests;
|
|
||||||
|
|
||||||
[TestClass]
|
|
||||||
public class UnitTestIsEnvironment
|
|
||||||
{
|
|
||||||
|
|
||||||
private readonly ILogger _Logger;
|
|
||||||
private readonly AppSettings _AppSettings;
|
|
||||||
private readonly string _WorkingDirectory;
|
|
||||||
private readonly IConfigurationRoot _ConfigurationRoot;
|
|
||||||
|
|
||||||
public UnitTestIsEnvironment()
|
|
||||||
{
|
|
||||||
ILogger logger;
|
|
||||||
AppSettings appSettings;
|
|
||||||
string workingDirectory;
|
|
||||||
IConfigurationRoot configurationRoot;
|
|
||||||
LoggerConfiguration loggerConfiguration = new();
|
|
||||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
|
||||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
|
||||||
.AddEnvironmentVariables()
|
|
||||||
.AddJsonFile("appsettings.Development.json");
|
|
||||||
configurationRoot = configurationBuilder.Build();
|
|
||||||
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
|
||||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
|
||||||
throw new Exception("Working directory name must have a value!");
|
|
||||||
workingDirectory = IWorkingDirectory.GetWorkingDirectory(assembly.GetName().Name, appSettings.WorkingDirectoryName);
|
|
||||||
Environment.SetEnvironmentVariable(nameof(workingDirectory), workingDirectory);
|
|
||||||
_ = ConfigurationLoggerConfigurationExtensions.Configuration(loggerConfiguration.ReadFrom, configurationRoot);
|
|
||||||
Log.Logger = loggerConfiguration.CreateLogger();
|
|
||||||
logger = Log.ForContext<UnitTestIsEnvironment>();
|
|
||||||
logger.Information("Complete");
|
|
||||||
_Logger = logger;
|
|
||||||
_AppSettings = appSettings;
|
|
||||||
_WorkingDirectory = workingDirectory;
|
|
||||||
_ConfigurationRoot = configurationRoot;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void NonThrowTryCatch()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{ throw new Exception(); }
|
|
||||||
catch (Exception) { }
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestMethodNull()
|
|
||||||
{
|
|
||||||
Assert.IsFalse(_Logger is null);
|
|
||||||
Assert.IsFalse(_AppSettings is null);
|
|
||||||
Assert.IsFalse(_WorkingDirectory is null);
|
|
||||||
Assert.IsFalse(_ConfigurationRoot is null);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestMethodTest()
|
|
||||||
{
|
|
||||||
List<string> jsonFiles = new();
|
|
||||||
foreach (IConfigurationProvider configurationProvider in _ConfigurationRoot.Providers)
|
|
||||||
{
|
|
||||||
if (configurationProvider is not JsonConfigurationProvider jsonConfigurationProvider || jsonConfigurationProvider.Source.Path is null)
|
|
||||||
continue;
|
|
||||||
jsonFiles.Add(jsonConfigurationProvider.Source.Path);
|
|
||||||
}
|
|
||||||
Assert.IsTrue(jsonFiles.Any());
|
|
||||||
foreach (string jsonFile in jsonFiles)
|
|
||||||
_ = new IsEnvironment(jsonFile);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
[TestCategory(nameof(IsEnvironment.Name.WindowsDevelopment))]
|
|
||||||
public void TestMethodTestCategory()
|
|
||||||
{
|
|
||||||
MethodBase? methodBase = new StackFrame().GetMethod();
|
|
||||||
if (methodBase is not null)
|
|
||||||
{
|
|
||||||
TestCategoryAttribute? testCategoryAttribute = methodBase.GetCustomAttribute<TestCategoryAttribute>();
|
|
||||||
if (testCategoryAttribute is not null)
|
|
||||||
{
|
|
||||||
foreach (string testCategory in testCategoryAttribute.TestCategories)
|
|
||||||
_ = new IsEnvironment(testCategory);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestMethodHardcoded()
|
|
||||||
{
|
|
||||||
_ = new IsEnvironment(isDevelopment: true, isStaging: false, isProduction: false);
|
|
||||||
_ = new IsEnvironment(isDevelopment: false, isStaging: true, isProduction: false);
|
|
||||||
_ = new IsEnvironment(isDevelopment: false, isStaging: false, isProduction: true);
|
|
||||||
}
|
|
||||||
|
|
||||||
[TestMethod]
|
|
||||||
public void TestMethodAssembly()
|
|
||||||
{
|
|
||||||
Assembly assembly = Assembly.GetExecutingAssembly();
|
|
||||||
bool debuggerWasAttachedAtLineZero = Debugger.IsAttached || assembly.Location.Contains(@"\bin\Debug");
|
|
||||||
IsEnvironment isEnvironment = new(processesCount: null, nullASPNetCoreEnvironmentIsDevelopment: debuggerWasAttachedAtLineZero, nullASPNetCoreEnvironmentIsProduction: !debuggerWasAttachedAtLineZero);
|
|
||||||
_ = IsEnvironment.GetEnvironmentName(isEnvironment);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -42,7 +42,8 @@ public class UnitTestResize
|
|||||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||||
.AddEnvironmentVariables()
|
.AddEnvironmentVariables()
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
|
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true)
|
||||||
|
.AddUserSecrets<UnitTestResize>();
|
||||||
configurationRoot = configurationBuilder.Build();
|
configurationRoot = configurationBuilder.Build();
|
||||||
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<IsPackable>false</IsPackable>
|
<IsPackable>false</IsPackable>
|
||||||
@ -6,6 +6,7 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
<TargetFramework>net7.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
|
<UserSecretsId>ecbdc76d-6037-4046-86a4-1a7626a3d342</UserSecretsId>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VSTestLogger>trx</VSTestLogger>
|
<VSTestLogger>trx</VSTestLogger>
|
||||||
|
@ -37,7 +37,8 @@ public class UnitTestExample
|
|||||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||||
.AddEnvironmentVariables()
|
.AddEnvironmentVariables()
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
|
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true)
|
||||||
|
.AddUserSecrets<UnitTestExample>();
|
||||||
configurationRoot = configurationBuilder.Build();
|
configurationRoot = configurationBuilder.Build();
|
||||||
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||||
|
@ -44,7 +44,8 @@ public class UnitTestFace
|
|||||||
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
IConfigurationBuilder configurationBuilder = new ConfigurationBuilder()
|
||||||
.AddEnvironmentVariables()
|
.AddEnvironmentVariables()
|
||||||
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
|
||||||
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true);
|
.AddJsonFile(isEnvironment.AppSettingsFileName, optional: false, reloadOnChange: true)
|
||||||
|
.AddUserSecrets<UnitTestFace>();
|
||||||
configurationRoot = configurationBuilder.Build();
|
configurationRoot = configurationBuilder.Build();
|
||||||
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
appSettings = Models.Binder.AppSettings.Get(configurationRoot);
|
||||||
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
if (string.IsNullOrEmpty(appSettings.WorkingDirectoryName))
|
||||||
@ -154,7 +155,7 @@ public class UnitTestFace
|
|||||||
const int ToleranceAfterFactor = 600;
|
const int ToleranceAfterFactor = 600;
|
||||||
Assert.IsTrue(DistanceDigits == 3);
|
Assert.IsTrue(DistanceDigits == 3);
|
||||||
Assert.IsTrue(DistanceFactor == 1000);
|
Assert.IsTrue(DistanceFactor == 1000);
|
||||||
Assert.IsTrue(_Configuration.RangeDistanceTolerance[1] == 0.6d);
|
Assert.IsTrue(_Configuration.RangeDistanceTolerance[1] == 0.6f);
|
||||||
Assert.IsTrue(ToleranceAfterFactor == 600);
|
Assert.IsTrue(ToleranceAfterFactor == 600);
|
||||||
double valueA = 0.00001d;
|
double valueA = 0.00001d;
|
||||||
int checkA = (int)(Math.Round(valueA, _Configuration.LocationDigits) * _Configuration.LocationFactor);
|
int checkA = (int)(Math.Round(valueA, _Configuration.LocationDigits) * _Configuration.LocationFactor);
|
||||||
@ -260,10 +261,10 @@ public class UnitTestFace
|
|||||||
FaceRecognition faceRecognition = new(_Configuration.NumberOfJitters, _Configuration.NumberOfTimesToUpsample, model, modelParameter, predictorModel);
|
FaceRecognition faceRecognition = new(_Configuration.NumberOfJitters, _Configuration.NumberOfTimesToUpsample, model, modelParameter, predictorModel);
|
||||||
List<(Location Location, FaceRecognitionDotNet.FaceEncoding? FaceEncoding, Dictionary<FacePart, FacePoint[]>? FaceParts)> collection;
|
List<(Location Location, FaceRecognitionDotNet.FaceEncoding? FaceEncoding, Dictionary<FacePart, FacePoint[]>? FaceParts)> collection;
|
||||||
collection = faceRecognition.GetCollection(image, locations: new(), includeFaceEncoding: true, includeFaceParts: true);
|
collection = faceRecognition.GetCollection(image, locations: new(), includeFaceEncoding: true, includeFaceParts: true);
|
||||||
Assert.IsTrue(collection.Count == 2);
|
Assert.IsTrue(collection.Count == 1);
|
||||||
List<FaceDistance> faceDistanceEncodings = (from l in collection where l.FaceEncoding is not null select new FaceDistance(l.FaceEncoding)).ToList();
|
List<FaceDistance> faceDistanceEncodings = (from l in collection where l.FaceEncoding is not null select new FaceDistance(l.FaceEncoding)).ToList();
|
||||||
List<FaceDistance> faceDistanceLengths = FaceRecognition.FaceDistances(faceDistanceEncodings, faceDistanceEncodings[0]);
|
List<FaceDistance> faceDistanceLengths = FaceRecognition.FaceDistances(faceDistanceEncodings, faceDistanceEncodings[0]);
|
||||||
Assert.IsTrue(faceDistanceLengths.Count == 2);
|
Assert.IsTrue(faceDistanceLengths.Count == 1);
|
||||||
Assert.IsNotNull(sourceFileName);
|
Assert.IsNotNull(sourceFileName);
|
||||||
NonThrowTryCatch();
|
NonThrowTryCatch();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user