OAID / TengineKit

TengineKit - Free, Fast, Easy, Real-Time Face Detection & Face Landmarks & Face Attributes & Hand Detection & Hand Landmarks & Body Detection & Body Landmarks & Iris Landmarks & Yolov5 SDK On Mobile.
Other
2.38k stars 318 forks source link

为啥android上检查图片拿到的人脸都是0? #33

Open h3clikejava opened 3 years ago

h3clikejava commented 3 years ago
object THTengineKit: BaseScanCore() {
    init {
        KitCore.init(BaseApplication.application, AndroidConfig
            .create()
            .setDefaultFunc()
            .setNormalMode()
            .setInputImageFormat(AndroidConfig.ImageFormat.RGBA)
        )

        val state = KitCore.getInit()
    }

    override fun doAI(filePath: String): Int {
        val bmp = BitmapFactory.decodeFile(filePath)
        if(bmp != null && !bmp.isRecycled) {
            val faceDetect = Face.detect(getPixelsRGBA(bmp))
//            bmp.recycle()
            val faceDetectInfos = faceDetect.detectInfos
            // 这里一直返回0
            return faceDetectInfos.size
        }
        return 0
    }

    override fun release() {
    }
}

getInit()方法拿到了true,应该是初始化成功的。 getPixelsRGBA方法是closed issue里面的那个方法

fun getPixelsRGBA(image: Bitmap): ByteArray {
        // calculate how many bytes our image consists of
        val bytes = image.byteCount
        val buffer: ByteBuffer = ByteBuffer.allocate(bytes) // Create a new buffer
        image.copyPixelsToBuffer(buffer) // Move the byte data to the buffer
        return buffer.array() // Get the underlying array containing the
}

是哪里出了问题呢???感谢解答