Added Class Library FaceRecognitionDotNet
This commit is contained in:
@ -1,3 +1,4 @@
|
||||
using System.Drawing;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using View_by_Distance.Shared.Models.Methods;
|
||||
@ -14,18 +15,47 @@ public class FacePoint : Properties.IFacePoint, IFacePoint
|
||||
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)
|
||||
{ }
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
int hashCode = 1861411795;
|
||||
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;
|
||||
}
|
||||
|
||||
public static bool operator ==(FacePoint point1, FacePoint point2) => point1.Equals(point2);
|
||||
|
||||
public static bool operator !=(FacePoint point1, FacePoint point2) => !(point1 == point2);
|
||||
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
using System.Drawing;
|
||||
using System.Text.Json;
|
||||
using System.Text.Json.Serialization;
|
||||
using View_by_Distance.Shared.Models.Methods;
|
||||
|
||||
namespace View_by_Distance.Shared.Models;
|
||||
|
||||
public class Location : Properties.ILocation, ILocation
|
||||
public class Location : Properties.ILocation, ILocation, IEquatable<Location>
|
||||
{
|
||||
|
||||
protected double _Confidence;
|
||||
@ -28,10 +29,47 @@ public class Location : Properties.ILocation, ILocation
|
||||
_Top = top;
|
||||
}
|
||||
|
||||
public Location(int left, int top, int right, int bottom) :
|
||||
this(-1.0d, bottom, left, right, top)
|
||||
{ }
|
||||
|
||||
public Location(Rectangle rectangle, double confidence) :
|
||||
this(-1.0d, rectangle.Bottom, rectangle.Left, rectangle.Right, rectangle.Top)
|
||||
{ }
|
||||
|
||||
public Location(Location location, double confidence) :
|
||||
this(-1.0d, location.Bottom, location.Left, location.Right, location.Top)
|
||||
{ }
|
||||
|
||||
public override bool Equals(object? obj) => Equals(obj as Location);
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
string result = JsonSerializer.Serialize(this, new JsonSerializerOptions() { WriteIndented = true });
|
||||
return result;
|
||||
}
|
||||
|
||||
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();
|
||||
return hashCode;
|
||||
}
|
||||
|
||||
public bool Equals(Location? location)
|
||||
{
|
||||
return location is not null
|
||||
&& _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);
|
||||
|
||||
public static bool operator !=(Location location1, Location location2) => !(location1 == location2);
|
||||
|
||||
}
|
59
Shared/Models/Stateless/FacePart.cs
Normal file
59
Shared/Models/Stateless/FacePart.cs
Normal file
@ -0,0 +1,59 @@
|
||||
namespace View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the part of face.
|
||||
/// </summary>
|
||||
public enum FacePart
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the chin.
|
||||
/// </summary>
|
||||
Chin,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the left eyebrow.
|
||||
/// </summary>
|
||||
LeftEyebrow,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the right eyebrow.
|
||||
/// </summary>
|
||||
RightEyebrow,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the nose bridge.
|
||||
/// </summary>
|
||||
NoseBridge,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the nose tip.
|
||||
/// </summary>
|
||||
NoseTip,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the left eye.
|
||||
/// </summary>
|
||||
LeftEye,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the right eye.
|
||||
/// </summary>
|
||||
RightEye,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the top lip.
|
||||
/// </summary>
|
||||
TopLip,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the bottom lip.
|
||||
/// </summary>
|
||||
BottomLip,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the nose.
|
||||
/// </summary>
|
||||
Nose,
|
||||
|
||||
}
|
24
Shared/Models/Stateless/ImageFormat.cs
Normal file
24
Shared/Models/Stateless/ImageFormat.cs
Normal file
@ -0,0 +1,24 @@
|
||||
namespace View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the file format of the image.
|
||||
/// </summary>
|
||||
public enum ImageFormat
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Specifies that the bitmap (BMP) image format.
|
||||
/// </summary>
|
||||
Bmp,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies that the Joint Photographic Experts Group (JPEG) image format.
|
||||
/// </summary>
|
||||
Jpeg,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies that the W3C Portable Network Graphics (PNG) image format.
|
||||
/// </summary>
|
||||
Png,
|
||||
|
||||
}
|
@ -18,6 +18,9 @@ public interface IPersonBirthday
|
||||
string TestStatic_GetFormatted(Models.PersonBirthday personBirthday) => PersonBirthday.GetFormatted(personBirthday);
|
||||
static string GetFormatted(Models.PersonBirthday personBirthday) => PersonBirthday.GetFormatted(personBirthday);
|
||||
|
||||
DateTime? TestStatic_Get(string personKey) => PersonBirthday.Get(personKey);
|
||||
static DateTime? Get(string personKey) => PersonBirthday.Get(personKey);
|
||||
|
||||
string TestStatic_GetFileName(Models.PersonBirthday personBirthday) => PersonBirthday.GetFileName(personBirthday);
|
||||
static string GetFileName(Models.PersonBirthday personBirthday) => PersonBirthday.GetFileName(personBirthday);
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
using System.Globalization;
|
||||
|
||||
namespace View_by_Distance.Shared.Models.Stateless.Methods;
|
||||
|
||||
internal abstract class PersonBirthday
|
||||
@ -13,5 +15,5 @@ internal abstract class PersonBirthday
|
||||
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));
|
||||
internal static string GetFileFullName(Properties.IStorage storage, Models.PersonBirthday personBirthday) => Path.Combine(storage.PeopleRootDirectory, "{}", GetFileName(personBirthday));
|
||||
|
||||
internal static DateTime? Get(string personKey) => DateTime.TryParseExact(personKey, GetFormat(), CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTime) ? dateTime : null;
|
||||
}
|
19
Shared/Models/Stateless/Mode.cs
Normal file
19
Shared/Models/Stateless/Mode.cs
Normal file
@ -0,0 +1,19 @@
|
||||
namespace View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the image mode.
|
||||
/// </summary>
|
||||
public enum Mode
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Specifies that the rgb (8-bit Red, Green and Blue, 3 channels) image mode.
|
||||
/// </summary>
|
||||
Rgb,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies that the greyscale image mode.
|
||||
/// </summary>
|
||||
Greyscale
|
||||
|
||||
}
|
24
Shared/Models/Stateless/Model.cs
Normal file
24
Shared/Models/Stateless/Model.cs
Normal file
@ -0,0 +1,24 @@
|
||||
namespace View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the model of face detector.
|
||||
/// </summary>
|
||||
public enum Model
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Specifies that the model is HOG (Histograms of Oriented Gradients) based face detector.
|
||||
/// </summary>
|
||||
Hog,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies that the model is CNN (Convolutional Neural Network) based face detector.
|
||||
/// </summary>
|
||||
Cnn,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies that the custom face detector.
|
||||
/// </summary>
|
||||
Custom
|
||||
|
||||
}
|
24
Shared/Models/Stateless/PredictorModel.cs
Normal file
24
Shared/Models/Stateless/PredictorModel.cs
Normal file
@ -0,0 +1,24 @@
|
||||
namespace View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
/// <summary>
|
||||
/// Specifies the dimension of vector which be returned from detector.
|
||||
/// </summary>
|
||||
public enum PredictorModel
|
||||
{
|
||||
|
||||
/// <summary>
|
||||
/// Specifies that the large scale detector. The detector returns 68 points for represent face.
|
||||
/// </summary>
|
||||
Large,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies that the small scale detector. The detector returns 5 points for represent face.
|
||||
/// </summary>
|
||||
Small,
|
||||
|
||||
/// <summary>
|
||||
/// Specifies that the custom detector.
|
||||
/// </summary>
|
||||
Custom
|
||||
|
||||
}
|
Reference in New Issue
Block a user