public override void Draw(Canvas canvas) { if (this.mLFace == null) { return; } IList <MLPosition> face3dPoints = mLFace.Get3DKeyPoints(ML3DFace.LandmarkFive); float[] projectionMatrix = new float[4 * 4]; float[] viewMatrix = new float[4 * 4]; mLFace.Get3DProjectionMatrix(projectionMatrix, 1, 10); mLFace.Get3DViewMatrix(viewMatrix); int frameHeight = (int)UnScaleX(overlay.Height); // Image height int frameWidth = (int)UnScaleY(overlay.Width); // Image Width float[] adaptMatrix = { frameWidth / 2, 0, frameWidth / 2, 0, -frameHeight / 2, frameHeight / 2, 0, 0, 1 }; IList <MLPosition> face2dPoints = TranslateTo2D(face3dPoints, projectionMatrix, viewMatrix, adaptMatrix); StringBuilder sb = new StringBuilder(); // Draw 2D points Paint numPaint; numPaint = new Paint(); numPaint.Color = Color.Red; numPaint.TextSize = frameHeight / 80; for (int i = 0; i < face2dPoints.Count; i++) { MLPosition point = face2dPoints.ElementAt(i); canvas.DrawPoint(TranslateX(point.GetX().FloatValue()), TranslateY(point.GetY().FloatValue()), boxPaint); canvas.DrawText("" + i, TranslateX(point.GetX().FloatValue()), TranslateY(point.GetY().FloatValue()), numPaint); sb.Append(point.GetX() + " " + point.GetY() + "\n"); } }
private void DisplaySuccess(ML3DFace mLFace) { float[] projectionMatrix = new float[4 * 4]; float[] viewMatrix = new float[4 * 4]; mLFace.Get3DProjectionMatrix(projectionMatrix, 1, 10); mLFace.Get3DViewMatrix(viewMatrix); DecimalFormat decimalFormat = new DecimalFormat("0.00"); string result = "3DFaceEulerX: " + decimalFormat.Format(mLFace.Get3DFaceEulerX()); result += "\n3DFaceEulerY: " + decimalFormat.Format(mLFace.Get3DFaceEulerY()); result += "\n3DFaceEulerZ: " + decimalFormat.Format(mLFace.Get3DFaceEulerZ()); result += "\n3DProjectionMatrix:"; for (int i = 0; i < 16; i++) { result += " " + decimalFormat.Format(projectionMatrix[i]); } result += "\nViewMatrix:"; for (int i = 0; i < 16; i++) { result += " " + decimalFormat.Format(viewMatrix[i]); } this.mTextView.Text = result; }