Added Class Library FaceRecognitionDotNet
This commit is contained in:
26
FaceRecognitionDotNet/Extensions/FaceDetector.cs
Normal file
26
FaceRecognitionDotNet/Extensions/FaceDetector.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using DlibDotNet;
|
||||
using View_by_Distance.Shared.Models;
|
||||
|
||||
namespace View_by_Distance.FaceRecognitionDotNet.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// An abstract base class that provides functionality to detect face locations from image.
|
||||
/// </summary>
|
||||
public abstract class FaceDetector : DisposableObject
|
||||
{
|
||||
|
||||
#region Methods
|
||||
|
||||
internal IEnumerable<Location> Detect(Image image, int numberOfTimesToUpsample) => RawDetect(image.Matrix, numberOfTimesToUpsample);
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerable collection of face location correspond to all faces in specified image.
|
||||
/// </summary>
|
||||
/// <param name="matrix">The matrix contains a face.</param>
|
||||
/// <param name="numberOfTimesToUpsample">The number of times to up-sample the image when finding faces.</param>
|
||||
/// <returns>An enumerable collection of face location correspond to all faces.</returns>
|
||||
protected abstract IEnumerable<Location> RawDetect(MatrixBase matrix, int numberOfTimesToUpsample);
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
36
FaceRecognitionDotNet/Extensions/FaceLandmarkDetector.cs
Normal file
36
FaceRecognitionDotNet/Extensions/FaceLandmarkDetector.cs
Normal file
@ -0,0 +1,36 @@
|
||||
using DlibDotNet;
|
||||
using View_by_Distance.Shared.Models;
|
||||
using View_by_Distance.Shared.Models.Stateless;
|
||||
|
||||
namespace View_by_Distance.FaceRecognitionDotNet.Extensions;
|
||||
|
||||
/// <summary>
|
||||
/// An abstract base class that provides functionality to detect face parts locations from face image.
|
||||
/// </summary>
|
||||
public abstract class FaceLandmarkDetector : DisposableObject
|
||||
{
|
||||
|
||||
#region Methods
|
||||
|
||||
internal FullObjectDetection Detect(Image image, Location location) => RawDetect(image.Matrix, location);
|
||||
|
||||
internal IEnumerable<Dictionary<FacePart, IEnumerable<FacePoint>>> GetLandmarks(IEnumerable<FacePoint[]> landmarkTuples) => RawGetLandmarks(landmarkTuples);
|
||||
|
||||
/// <summary>
|
||||
/// Returns an object contains information of face parts corresponds to specified location in specified image.
|
||||
/// </summary>
|
||||
/// <param name="matrix">The matrix contains a face.</param>
|
||||
/// <param name="location">The location rectangle for a face.</param>
|
||||
/// <returns>An object contains information of face parts.</returns>
|
||||
protected abstract FullObjectDetection RawDetect(MatrixBase matrix, Location location);
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerable collection of dictionary of face parts locations (eyes, nose, etc).
|
||||
/// </summary>
|
||||
/// <param name="landmarkTuples">The enumerable collection of face parts location.</param>
|
||||
/// <returns>An enumerable collection of dictionary of face parts locations (eyes, nose, etc).</returns>
|
||||
protected abstract IEnumerable<Dictionary<FacePart, IEnumerable<FacePoint>>> RawGetLandmarks(IEnumerable<FacePoint[]> landmarkTuples);
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
Reference in New Issue
Block a user