After testing E_Distance.SaveGroupedFaceEncodings

This commit is contained in:
2022-08-07 12:29:46 -07:00
parent 2158b4cfc2
commit daf5f428b9
57 changed files with 2626 additions and 660 deletions

View File

@ -1,4 +1,3 @@
using System.Drawing;
using System.Text.Json;
using System.Text.Json.Serialization;
using View_by_Distance.Shared.Models.Methods;
@ -8,37 +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 int _Left;
protected double? _PixelPercentage;
protected int _Right;
protected int _Top;
public double Confidence => _Confidence;
public int Bottom => _Bottom;
public int Left => _Left;
public double? PixelPercentage => _PixelPercentage;
public int Right => _Right;
public int Top => _Top;
[JsonConstructor]
public Location(double confidence, int bottom, int left, int right, int top)
public Location(double confidence, int bottom, int left, double? pixelPercentage, int right, int top)
{
_Confidence = confidence;
_Bottom = bottom;
_Left = left;
_PixelPercentage = pixelPercentage;
_Right = right;
_Top = top;
}
public Location(int left, int top, int right, int bottom) :
this(-1.0d, bottom, left, right, 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)
{ }
public Location(Rectangle rectangle, double confidence) :
this(-1.0d, rectangle.Bottom, rectangle.Left, rectangle.Right, rectangle.Top)
public Location(double confidence, Location location, int width, int height) :
this(confidence, location.Bottom, location.Left, location.Right, location.Top, width, height)
{ }
public Location(Location location, double confidence) :
this(-1.0d, location.Bottom, location.Left, 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)
{ }
public override bool Equals(object? obj) => Equals(obj as Location);
@ -59,6 +61,15 @@ 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)
{
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);
}
public bool Equals(Location? location)
{
return location is not null