使用适用于 Android 的 ML Kit 进行人脸检测

问题描述 投票:0回答:0

我目前正在制作一个人脸检测应用程序。 当我快速移动相机时,有时从检测器中获取非面部图像。

override fun analyze(imageProxy: ImageProxy) {

    val t1 = System.currentTimeMillis()

    val btm = imageProxy.toBitmap() ?: return
    val image: InputImage = InputImage.fromBitmap(btm, imageProxy.imageInfo.rotationDegrees)
    detectInImage(image)
        .addOnSuccessListener { results ->
                val items = results.mapNotNull {
                    it
                }
                val rotated = btm.rotateBitmap(imageProxy.imageInfo.rotationDegrees)
                rotated?.let {
                    onFacesDetected(items, it)
                    onOutlineDetected(items, Rect(0,0, btm.width, btm.height))
                }
            
            imageProxy.close()
        }
        .addOnFailureListener {
            onFailure(it)
            imageProxy.close()
        }
}

也许我配置人脸检测器或 ImageAnalysis.builder 时出错。 谁曾经遇到过这种情况?解决方案是什么? 请帮助我。

android kotlin face-detection firebase-mlkit google-mlkit
© www.soinside.com 2019 - 2024. All rights reserved.