AppSettings and Configuration changes,

major changes to E_Distance and minor for D_Face
This commit is contained in:
2022-08-19 21:37:36 -07:00
parent 004017b9dd
commit be7a6abbf4
60 changed files with 1269 additions and 1344 deletions

View File

@ -7,40 +7,40 @@ namespace View_by_Distance.Shared.Models;
public class Location : Properties.ILocation, ILocation, IEquatable<Location>
{
public double Confidence => _Confidence;
protected double _Confidence;
protected int _Bottom;
protected double _Confidence;
protected int _Left;
protected double? _PixelPercentage;
protected readonly int? _NormalizedPixelPercentage;
protected int _Right;
protected int _Top;
public int Bottom => _Bottom;
public double Confidence => _Confidence;
public int Left => _Left;
public double? PixelPercentage => _PixelPercentage;
public int? NormalizedPixelPercentage => _NormalizedPixelPercentage;
public int Right => _Right;
public int Top => _Top;
[JsonConstructor]
public Location(double confidence, int bottom, int left, double? pixelPercentage, int right, int top)
public Location(int bottom, double confidence, int left, int? normalizedPixelPercentage, int right, int top)
{
_Confidence = confidence;
_Bottom = bottom;
_Left = left;
_PixelPercentage = pixelPercentage;
_NormalizedPixelPercentage = normalizedPixelPercentage;
_Right = right;
_Top = top;
}
public Location(double confidence, int bottom, int left, int right, int top, int width, int height) :
this(confidence, bottom, left, GetPixelPercentage(bottom, left, right, top, width, height), right, top)
this(bottom, confidence, left, GetNormalizedPixelPercentage(bottom, height, left, right, top, width), right, top)
{ }
public Location(double confidence, Location location, int width, int height) :
this(confidence, location.Bottom, location.Left, location.Right, location.Top, width, height)
this(location.Bottom, confidence, location.Left, GetNormalizedPixelPercentage(location.Bottom, height, location.Left, location.Right, location.Top, width), location.Right, location.Top)
{ }
public Location(int left, int top, int right, int bottom, int width, int height) :
this(-1.0d, bottom, left, right, top, width, height)
this(bottom, -1.0d, left, GetNormalizedPixelPercentage(bottom, height, left, right, top, width), right, top)
{ }
public override bool Equals(object? obj) => Equals(obj as Location);
@ -61,13 +61,13 @@ public class Location : Properties.ILocation, ILocation, IEquatable<Location>
return hashCode;
}
public static double GetPixelPercentage(int left, int top, int right, int bottom, int width, int height)
public static int GetNormalizedPixelPercentage(int bottom, int height, int left, int right, int top, int width)
{
double result;
double xCenter = left + ((right - left) / 2);
double yCenter = top + ((bottom - top) / 2);
result = ((yCenter * width) + xCenter) / (width * height);
return (double)Math.Round((decimal)result, 4);
return (int)(Math.Round((decimal)result, 4) * Stateless.Methods.ILocation.Factor);
}
public bool Equals(Location? location)

View File

@ -3,9 +3,10 @@ namespace View_by_Distance.Shared.Models.Properties;
public interface ILocation
{
public double Confidence { get; }
public int Bottom { get; }
public double Confidence { get; }
public int Left { get; }
public int? NormalizedPixelPercentage { get; }
public int Right { get; }
public int Top { get; }

View File

@ -0,0 +1,8 @@
namespace View_by_Distance.Shared.Models.Stateless.Methods;
public interface ILocation
{ // ...
public const int Factor = 10000;
}

View File

@ -12,9 +12,6 @@ public interface IPersonBirthday
string TestStatic_GetFormat() => PersonBirthday.GetFormat();
static string GetFormat() => PersonBirthday.GetFormat();
string[] TestStatic_GetSegments(string personKey) => PersonBirthday.GetSegments(personKey);
static string[] GetSegments(string personKey) => PersonBirthday.GetSegments(personKey);
DateTime? TestStatic_GetDateTime(string personKey) => PersonBirthday.GetDateTime(personKey);
static DateTime? GetDateTime(string personKey) => PersonBirthday.GetDateTime(personKey);

View File

@ -10,7 +10,6 @@ internal abstract class PersonBirthday
// ...
internal static string GetFormat() => "yyyy-MM-dd_HH";
internal static string[] GetSegments(string personKey) => personKey.Split('\t');
internal static string GetFormatted(Models.PersonBirthday personBirthday) => personBirthday.Value.ToString(GetFormat());
internal static string GetFileName(Models.PersonBirthday personBirthday) => $"{personBirthday.Value.ToString(GetFormat())}.json";
internal static bool DoesBirthDateExits(Properties.IStorage storage, Models.PersonBirthday personBirthday) => File.Exists(GetFileFullName(storage, personBirthday));
@ -21,8 +20,7 @@ internal abstract class PersonBirthday
internal static Models.PersonBirthday? GetPersonBirthday(string personKey)
{
Models.PersonBirthday? result;
string[] segments = GetSegments(personKey);
DateTime? dateTime = GetDateTime(segments[0]);
DateTime? dateTime = GetDateTime(personKey);
if (dateTime is null)
result = null;
else