Change to the Normalized Pixel Percentage Formula
This commit is contained in:
@ -6,42 +6,54 @@ namespace View_by_Distance.Shared.Models;
|
||||
public class Location : Properties.ILocation, IEquatable<Location>
|
||||
{
|
||||
|
||||
protected int _Bottom;
|
||||
protected double _Confidence;
|
||||
protected int _Left;
|
||||
protected readonly int? _NormalizedPixelPercentage;
|
||||
protected int _Right;
|
||||
protected int _Top;
|
||||
public double Confidence => _Confidence;
|
||||
public int Bottom => _Bottom;
|
||||
public int Left => _Left;
|
||||
public int? NormalizedPixelPercentage => _NormalizedPixelPercentage;
|
||||
public int Right => _Right;
|
||||
public int Top => _Top;
|
||||
public int Bottom { init; get; }
|
||||
public double Confidence { init; get; }
|
||||
public int Left { init; get; }
|
||||
public int? NormalizedPixelPercentage { init; get; }
|
||||
public int Right { init; get; }
|
||||
public int Top { init; get; }
|
||||
|
||||
[JsonConstructor]
|
||||
public Location(int bottom, double confidence, int left, int? normalizedPixelPercentage, int right, int top)
|
||||
{
|
||||
_Confidence = confidence;
|
||||
_Bottom = bottom;
|
||||
_Left = left;
|
||||
_NormalizedPixelPercentage = normalizedPixelPercentage;
|
||||
_Right = right;
|
||||
_Top = top;
|
||||
Confidence = confidence;
|
||||
Bottom = bottom;
|
||||
Left = left;
|
||||
NormalizedPixelPercentage = normalizedPixelPercentage;
|
||||
Right = right;
|
||||
Top = top;
|
||||
Stateless.Methods.Location.Check(bottom, left, normalizedPixelPercentage, right, top, zCount: 1);
|
||||
}
|
||||
|
||||
public Location(double confidence, int height, Location location, int locationDigits, int locationFactor, int width, int zCount) :
|
||||
this(location.Bottom, confidence, location.Left, Stateless.Methods.Location.GetNormalizedPixelPercentage(location.Bottom, height, location.Left, locationDigits, locationFactor, location.Right, location.Top, width, zCount), location.Right, location.Top) =>
|
||||
Stateless.Methods.Location.Check(_Bottom, _Left, _NormalizedPixelPercentage, _Right, _Top, zCount);
|
||||
this(
|
||||
location.Bottom,
|
||||
confidence,
|
||||
location.Left,
|
||||
Stateless.Methods.Location.GetNormalizedPixelPercentage(location.Bottom, height, location.Left, locationDigits, locationFactor, location.Right, location.Top, width, zCount),
|
||||
location.Right,
|
||||
location.Top) =>
|
||||
Stateless.Methods.Location.Check(Bottom, Left, NormalizedPixelPercentage, Right, Top, zCount);
|
||||
|
||||
public Location(int bottom, double confidence, int height, int left, int locationDigits, int locationFactor, int right, int top, int width, int zCount) :
|
||||
this(bottom, confidence, left, Stateless.Methods.Location.GetNormalizedPixelPercentage(bottom, height, left, locationDigits, locationFactor, right, top, width, zCount), right, top) =>
|
||||
Stateless.Methods.Location.Check(_Bottom, height, _Left, _NormalizedPixelPercentage, _Right, _Top, width, zCount);
|
||||
this(
|
||||
bottom,
|
||||
confidence,
|
||||
left,
|
||||
Stateless.Methods.Location.GetNormalizedPixelPercentage(bottom, height, left, locationDigits, locationFactor, right, top, width, zCount),
|
||||
right,
|
||||
top) =>
|
||||
Stateless.Methods.Location.Check(Bottom, height, Left, NormalizedPixelPercentage, Right, Top, width, zCount);
|
||||
|
||||
public Location(Location location, int locationDigits, int locationFactor, int zCount) :
|
||||
this(location.Bottom, location.Confidence, location.Left, Stateless.Methods.Location.GetNormalizedPixelPercentage(location.Bottom, height: location.Bottom - location.Top, location.Left, locationDigits, locationFactor, location.Right, location.Top, width: location.Right - location.Left, zCount), location.Right, location.Top) =>
|
||||
Stateless.Methods.Location.Check(_Bottom, _Left, _NormalizedPixelPercentage, _Right, _Top, zCount);
|
||||
public Location(int height, Location location, int locationDigits, int locationFactor, int width, int zCount) :
|
||||
this(
|
||||
location.Bottom,
|
||||
location.Confidence,
|
||||
location.Left,
|
||||
Stateless.Methods.Location.GetNormalizedPixelPercentage(location.Bottom, height, location.Left, locationDigits, locationFactor, location.Right, location.Top, width, zCount),
|
||||
location.Right,
|
||||
location.Top) =>
|
||||
Stateless.Methods.Location.Check(Bottom, Left, NormalizedPixelPercentage, Right, Top, zCount);
|
||||
|
||||
public Location(double confidence, int factor, int height, Location location, int locationDigits, int locationFactor, int width, int zCount)
|
||||
{
|
||||
@ -52,13 +64,15 @@ public class Location : Properties.ILocation, IEquatable<Location>
|
||||
int right = Math.Min(location.Right + x, width);
|
||||
int top = Math.Max(location.Top - y, 0);
|
||||
int normalizedPixelPercentage = Stateless.Methods.Location.GetNormalizedPixelPercentage(location.Bottom, height, location.Left, locationDigits, locationFactor, location.Right, location.Top, width, zCount);
|
||||
Stateless.Methods.Location.Check(bottom, left, _NormalizedPixelPercentage, right, top, zCount);
|
||||
_Confidence = confidence;
|
||||
_Bottom = bottom;
|
||||
_Left = left;
|
||||
_NormalizedPixelPercentage = normalizedPixelPercentage;
|
||||
_Right = right;
|
||||
_Top = top;
|
||||
if (location.NormalizedPixelPercentage is null || normalizedPixelPercentage != location.NormalizedPixelPercentage.Value)
|
||||
throw new Exception();
|
||||
Stateless.Methods.Location.Check(bottom, left, NormalizedPixelPercentage, right, top, zCount);
|
||||
Confidence = confidence;
|
||||
Bottom = bottom;
|
||||
Left = left;
|
||||
NormalizedPixelPercentage = normalizedPixelPercentage;
|
||||
Right = right;
|
||||
Top = top;
|
||||
}
|
||||
|
||||
public override bool Equals(object? obj) => Equals(obj as Location);
|
||||
@ -72,20 +86,20 @@ public class Location : Properties.ILocation, IEquatable<Location>
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hashCode = -773114317;
|
||||
hashCode = hashCode * -1521134295 + _Bottom.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + _Left.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + _Right.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + _Top.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + Bottom.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + Left.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + Right.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + Top.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public bool Equals(Location? location)
|
||||
{
|
||||
return location is not null
|
||||
&& _Bottom == location.Bottom
|
||||
&& _Left == location.Left
|
||||
&& _Right == location.Right
|
||||
&& _Top == location.Top;
|
||||
&& Bottom == location.Bottom
|
||||
&& Left == location.Left
|
||||
&& Right == location.Right
|
||||
&& Top == location.Top;
|
||||
}
|
||||
|
||||
public static bool operator ==(Location location1, Location location2) => EqualityComparer<Location>.Default.Equals(location1, location2);
|
||||
|
Reference in New Issue
Block a user