FaceFile for D2
This commit is contained in:
Face/Models
FaceParts/Models
Instance
Resize/Models
Shared/Models
Tests/Models
TestsWithFaceRecognitionDotNet/Models
@ -1,58 +1,35 @@
|
||||
using System.Drawing;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public class FacePoint : Properties.IFacePoint
|
||||
[method: JsonConstructor]
|
||||
public class FacePoint(int index, int x, int y) : Properties.IFacePoint
|
||||
{
|
||||
public int Index { get; } = index;
|
||||
public int X { get; } = x;
|
||||
public int Y { get; } = y;
|
||||
|
||||
protected int _Index;
|
||||
protected int _X;
|
||||
protected int _Y;
|
||||
public int Index => _Index;
|
||||
public int X => _X;
|
||||
public int Y => _Y;
|
||||
|
||||
private readonly Point _Point;
|
||||
|
||||
[JsonConstructor]
|
||||
public FacePoint(int index, int x, int y)
|
||||
{
|
||||
_Index = index;
|
||||
_X = x;
|
||||
_Y = y;
|
||||
_Point = new(x, y);
|
||||
}
|
||||
|
||||
public FacePoint(Point point, int index) :
|
||||
this(index, point.X, point.Y)
|
||||
{ }
|
||||
private readonly Point _Point = new(x, y);
|
||||
|
||||
public override bool Equals(object? obj) => obj is FacePoint point && Equals(point);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
#pragma warning disable IDE0070
|
||||
public override int GetHashCode()
|
||||
#pragma warning restore IDE0070
|
||||
{
|
||||
int hashCode = 1861411795;
|
||||
hashCode = hashCode * -1521134295 + _Point.GetHashCode();
|
||||
hashCode = hashCode * -1521134295 + _Index.GetHashCode();
|
||||
hashCode = (hashCode * -1521134295) + _Point.GetHashCode();
|
||||
hashCode = (hashCode * -1521134295) + Index.GetHashCode();
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public bool Equals(FacePoint? facePoint)
|
||||
{
|
||||
return facePoint is not null
|
||||
&& _X == facePoint.X
|
||||
&& _Y == facePoint.Y
|
||||
&& _Index == facePoint.Index;
|
||||
&& X == facePoint.X
|
||||
&& Y == facePoint.Y
|
||||
&& Index == facePoint.Index;
|
||||
}
|
||||
|
||||
public static bool operator ==(FacePoint point1, FacePoint point2) => point1.Equals(point2);
|
||||
|
Reference in New Issue
Block a user