/// <summary> /// 検出値を取得 /// </summary> void FaceModule_FrameProcessed(object sender, FrameProcessedEventArgs args) { FaceData.Update(); var face = FaceData.QueryFaceByIndex(0); if (face != null) { // 検出値 FaceRect = face.Detection.BoundingRect; Landmark = face.Landmarks.Points; FaceExp = face.Expressions.ExpressionResults; // 体位置 BodyPos = SmoothBody.SmoothValue(GetBodyPos(FaceRect)); // 頭角度 HeadAng = SmoothHead.SmoothValue(GetHeadAng(Landmark)); // 視線 EyesPos = SmoothEyes.SmoothValue(GetEyesPos(Landmark)); // 目パチ float eyeL = FaceExp[FaceExpression.EXPRESSION_EYES_CLOSED_LEFT].intensity; float eyeR = FaceExp[FaceExpression.EXPRESSION_EYES_CLOSED_RIGHT].intensity; EyesClose = SmoothEyesClose.SmoothValue(Mathf.Max(eyeL, eyeR)); EyesClose = EyesClose < 50 ? 0 : (EyesClose - 50) * 2; // 眉上 float browRaiL = FaceExp[FaceExpression.EXPRESSION_BROW_RAISER_LEFT].intensity; float browRaiR = FaceExp[FaceExpression.EXPRESSION_BROW_RAISER_RIGHT].intensity; BrowRai = SmoothBrowRai.SmoothValue(Mathf.Max(browRaiL, browRaiR)); // 眉下 float browLowL = FaceExp[FaceExpression.EXPRESSION_BROW_LOWERER_LEFT].intensity; float browLowR = FaceExp[FaceExpression.EXPRESSION_BROW_LOWERER_RIGHT].intensity; BrowLow = SmoothBrowLow.SmoothValue(Mathf.Max(browLowL, browLowR)); // 笑顔 Smile = SmoothSmile.SmoothValue(FaceExp[FaceExpression.EXPRESSION_SMILE].intensity); // キス(口開と若干競合) Kiss = SmoothKiss.SmoothValue(FaceExp[FaceExpression.EXPRESSION_KISS].intensity); // 口開(キスと若干競合) Mouth = SmoothMouth.SmoothValue(FaceExp[FaceExpression.EXPRESSION_MOUTH_OPEN].intensity); // べー(口開と競合) Tongue = SmoothTongue.SmoothValue(FaceExp[FaceExpression.EXPRESSION_TONGUE_OUT].intensity); Ready = true; } }
private void ProcessLandmarks() { FaceData faceData = faceModule.CreateOutput(); faceData.Update(); int numOfFaces = faceData.NumberOfDetectedFaces > maxTrackedFaces ? maxTrackedFaces : faceData.NumberOfDetectedFaces; boundingBoxes.Clear(); landmarks.Clear(); Face face; RectI32 boundingRect; LandmarkPoint[] groupPoints; LandmarkPoint[] allPoints; for (int i = 0; i < numOfFaces; i++) { face = faceData.QueryFaceByIndex(i); boundingRect = face.Detection.BoundingRect; boundingBoxes.Add(boundingRect); if (face != null && face.Landmarks != null) { if (extractLandmarkGroup) { face.Landmarks.QueryPointsByGroup(landmarkGroup, out groupPoints); } else { groupPoints = face.Landmarks.Points; } if (groupPoints != null) { landmarks.Add(groupPoints); } allPoints = face.Landmarks.Points; if (allPoints != null) { allLandmarks.Add(allPoints); } } } faceData.Dispose(); faceModule.Dispose(); }