Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
h3clikejava opened this issue Apr 2, 2021 · 0 comments
Open

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

h3clikejava opened this issue Apr 2, 2021 · 0 comments

Comments

@h3clikejava
Copy link

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
}

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant