/// <summary> /// Initializes a new instance of the DetectedFace class. /// </summary> public DetectedFace(FaceRectangle faceRectangle, System.Guid?faceId = default(System.Guid?), FaceLandmarks faceLandmarks = default(FaceLandmarks), FaceAttributes faceAttributes = default(FaceAttributes)) { FaceId = faceId; FaceRectangle = faceRectangle; FaceLandmarks = faceLandmarks; FaceAttributes = faceAttributes; CustomInit(); }
/// <summary> /// Initializes a new instance of the DetectedFace class. /// </summary> /// <param name="recognitionModel">Possible values include: /// 'recognition_01', 'recognition_02', 'recognition_03', /// 'recognition_04'</param> public DetectedFace(FaceRectangle faceRectangle, System.Guid?faceId = default(System.Guid?), string recognitionModel = default(string), FaceLandmarks faceLandmarks = default(FaceLandmarks), FaceAttributes faceAttributes = default(FaceAttributes)) { FaceId = faceId; RecognitionModel = recognitionModel; FaceRectangle = faceRectangle; FaceLandmarks = faceLandmarks; FaceAttributes = faceAttributes; CustomInit(); }
/// <summary> /// Validate the object. /// </summary> /// <exception cref="ValidationException"> /// Thrown if validation fails /// </exception> public virtual void Validate() { if (FaceRectangle == null) { throw new ValidationException(ValidationRules.CannotBeNull, "FaceRectangle"); } if (FaceRectangle != null) { FaceRectangle.Validate(); } if (FaceLandmarks != null) { FaceLandmarks.Validate(); } }
public void DisplayFaceLandmarks(Face.FaceRectangle faceRect, Face.FaceLandmarks landmarks, double scaleX, double scaleY) { // Mouth (6) AddFacialLandmark(faceRect, landmarks.MouthLeft, scaleX, scaleY, this.mouthleft); AddFacialLandmark(faceRect, landmarks.MouthRight, scaleX, scaleY, this.mouthright); AddFacialLandmark(faceRect, landmarks.UpperLipBottom, scaleX, scaleY, this.upperlipbottom); AddFacialLandmark(faceRect, landmarks.UpperLipTop, scaleX, scaleY, this.upperliptop); AddFacialLandmark(faceRect, landmarks.UnderLipBottom, scaleX, scaleY, this.underlipbottom); AddFacialLandmark(faceRect, landmarks.UnderLipTop, scaleX, scaleY, this.underliptop); // Eyes (10) AddFacialLandmark(faceRect, landmarks.EyeLeftBottom, scaleX, scaleY, eyeleftbottom); AddFacialLandmark(faceRect, landmarks.EyeLeftTop, scaleX, scaleY, eyelefttop); AddFacialLandmark(faceRect, landmarks.EyeLeftInner, scaleX, scaleY, eyeleftinner); AddFacialLandmark(faceRect, landmarks.EyeLeftOuter, scaleX, scaleY, eyeleftouter); AddFacialLandmark(faceRect, landmarks.EyeRightBottom, scaleX, scaleY, eyerightbottom); AddFacialLandmark(faceRect, landmarks.EyeRightTop, scaleX, scaleY, eyerighttop); AddFacialLandmark(faceRect, landmarks.EyeRightInner, scaleX, scaleY, eyerightinner); AddFacialLandmark(faceRect, landmarks.EyeRightOuter, scaleX, scaleY, eyerightouter); AddFacialLandmark(faceRect, landmarks.PupilLeft, scaleX, scaleY, pupilleft); AddFacialLandmark(faceRect, landmarks.PupilRight, scaleX, scaleY, pupilright); // nose (7) AddFacialLandmark(faceRect, landmarks.NoseLeftAlarOutTip, scaleX, scaleY, noseleftalarouttip); AddFacialLandmark(faceRect, landmarks.NoseLeftAlarTop, scaleX, scaleY, noseleftalartop); AddFacialLandmark(faceRect, landmarks.NoseRightAlarOutTip, scaleX, scaleY, noserightalarouttip); AddFacialLandmark(faceRect, landmarks.NoseRightAlarTop, scaleX, scaleY, noserightalartop); AddFacialLandmark(faceRect, landmarks.NoseRootLeft, scaleX, scaleY, noserootleft); AddFacialLandmark(faceRect, landmarks.NoseRootRight, scaleX, scaleY, noserootright); AddFacialLandmark(faceRect, landmarks.NoseTip, scaleX, scaleY, nosetip); // eyebrows (4) AddFacialLandmark(faceRect, landmarks.EyebrowLeftInner, scaleX, scaleY, eyebrowleftinner); AddFacialLandmark(faceRect, landmarks.EyebrowLeftOuter, scaleX, scaleY, eyebrowleftouter); AddFacialLandmark(faceRect, landmarks.EyebrowRightInner, scaleX, scaleY, eyebrowrightinner); AddFacialLandmark(faceRect, landmarks.EyebrowRightOuter, scaleX, scaleY, eyebrowrightouter); this.mainGrid.Visibility = Visibility.Visible; this.FaceLandmarksStoryboard.Begin(); }
public static void DisplayFaceLandmarks(Grid grid, Face.FaceRectangle faceRect, Face.FaceLandmarks landmarks, double scaleX, double scaleY, SolidColorBrush color = null) { // Mouth (6) SolidColorBrush colorBrush = color ?? new SolidColorBrush(Colors.White); AddFacialLandmark(grid, faceRect, landmarks.MouthLeft, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.MouthRight, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.UpperLipBottom, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.UpperLipTop, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.UnderLipBottom, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.UnderLipTop, scaleX, scaleY, colorBrush); // Eyes (10) colorBrush = color ?? new SolidColorBrush(Colors.Red); AddFacialLandmark(grid, faceRect, landmarks.EyeLeftBottom, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.EyeLeftTop, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.EyeLeftInner, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.EyeLeftOuter, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.EyeRightBottom, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.EyeRightTop, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.EyeRightInner, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.EyeRightOuter, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.PupilLeft, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.PupilRight, scaleX, scaleY, colorBrush); // nose (7) colorBrush = color ?? new SolidColorBrush(Colors.LimeGreen); AddFacialLandmark(grid, faceRect, landmarks.NoseLeftAlarOutTip, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.NoseLeftAlarTop, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.NoseRightAlarOutTip, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.NoseRightAlarTop, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.NoseRootLeft, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.NoseRootRight, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.NoseTip, scaleX, scaleY, colorBrush); // eyebrows (4) colorBrush = color ?? new SolidColorBrush(Colors.Yellow); AddFacialLandmark(grid, faceRect, landmarks.EyebrowLeftInner, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.EyebrowLeftOuter, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.EyebrowRightInner, scaleX, scaleY, colorBrush); AddFacialLandmark(grid, faceRect, landmarks.EyebrowRightOuter, scaleX, scaleY, colorBrush); }