@@ -9,11 +9,11 @@ import coil.transform.Transformation
99import com.google.mlkit.vision.common.InputImage
1010import com.google.mlkit.vision.face.FaceDetection
1111import com.google.mlkit.vision.face.FaceDetectorOptions
12+ import kotlinx.coroutines.suspendCancellableCoroutine
1213import java.io.ByteArrayOutputStream
1314import java.util.*
1415import kotlin.coroutines.resume
1516import kotlin.coroutines.resumeWithException
16- import kotlinx.coroutines.suspendCancellableCoroutine
1717
1818/* *
1919 * Finds the largest face in an image, and center crops around it.
@@ -53,10 +53,10 @@ class CenterOnFaceTransformation constructor(
5353
5454 // Initialize FaceDetectorOptions
5555 val highAccuracyOpts = FaceDetectorOptions .Builder ()
56- .setPerformanceMode(FaceDetectorOptions .PERFORMANCE_MODE_ACCURATE )
57- .setLandmarkMode(FaceDetectorOptions .LANDMARK_MODE_ALL )
58- .setClassificationMode(FaceDetectorOptions .CLASSIFICATION_MODE_ALL )
59- .build()
56+ .setPerformanceMode(FaceDetectorOptions .PERFORMANCE_MODE_ACCURATE )
57+ .setLandmarkMode(FaceDetectorOptions .LANDMARK_MODE_ALL )
58+ .setClassificationMode(FaceDetectorOptions .CLASSIFICATION_MODE_ALL )
59+ .build()
6060
6161 // Get a face detector.
6262 val detector = FaceDetection .getClient(highAccuracyOpts)
@@ -99,11 +99,11 @@ class CenterOnFaceTransformation constructor(
9999 */
100100 private fun frameBitmap (input : Bitmap , square : Rect ): Bitmap {
101101 return Bitmap .createBitmap(
102- input,
103- square.left,
104- square.top,
105- square.width(),
106- square.height()
102+ input,
103+ square.left,
104+ square.top,
105+ square.width(),
106+ square.height()
107107 )
108108 }
109109
@@ -127,19 +127,20 @@ class CenterOnFaceTransformation constructor(
127127 val centerY = boundingBox.exactCenterY()
128128
129129 val halfWidth = Collections .min(
130- listOf (
131- centerX,
132- centerY,
133- input.width.toFloat() - centerX,
134- input.height.toFloat() - centerY
135- )
130+ listOf (
131+ centerX,
132+ centerY,
133+ input.width.toFloat() - centerX,
134+ input.height.toFloat() - centerY
135+ )
136136 )
137137 val width = halfWidth * 2
138138 val left = (centerX - halfWidth).toInt()
139139 val top = (centerY - halfWidth).toInt()
140140 val right = left + width.toInt()
141141 val bottom = top + width.toInt()
142- return Rect (left, top, right, bottom
142+ return Rect (
143+ left, top, right, bottom
143144 )
144145 }
145146
@@ -299,10 +300,10 @@ class CenterOnFaceTransformation constructor(
299300 }
300301
301302 return Rect (
302- left,
303- top,
304- right,
305- bottom
303+ left,
304+ top,
305+ right,
306+ bottom
306307 )
307308 }
308309}
0 commit comments