From 0a42ca7ccb1636577f5727d06b9811374c7c2e55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9rgio=20Faria?= Date: Tue, 20 May 2014 23:55:19 +0100 Subject: [PATCH] Avoid allocating PointF's in a loop. --- .../src/main/java/cat/lafosca/facecropper/FaceCropper.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/FaceCropper-library/src/main/java/cat/lafosca/facecropper/FaceCropper.java b/FaceCropper-library/src/main/java/cat/lafosca/facecropper/FaceCropper.java index fc37964..9e47e1d 100644 --- a/FaceCropper-library/src/main/java/cat/lafosca/facecropper/FaceCropper.java +++ b/FaceCropper-library/src/main/java/cat/lafosca/facecropper/FaceCropper.java @@ -120,6 +120,8 @@ public Bitmap cropFace(Bitmap original) { int endX = 0; int endY = 0; + PointF centerFace = new PointF(); + // Calculates minimum box to fit all detected faces for (int i = 0; i < faceCount; i++) { FaceDetector.Face face = faces[i]; @@ -135,7 +137,6 @@ else if (SizeMode.EyeDistanceFactorMargin.equals(mSizeMode)) { faceSize = Math.max(faceSize, mFaceMinSize); - PointF centerFace = new PointF(); face.getMidPoint(centerFace); int tInitX = (int) (centerFace.x - faceSize / 2);