Android 一句话集成ArcFace虹软人脸识别

基于虹软人脸识别增值版Android SDK V3.1,封装人脸识别方法。

增值版Android SDK V3.1文档
虹软人脸识别4.0封装-支持口罩识别

效果展示

限制识别区域
限制识别区域
不限制识别区域
不限制识别区域

引入

仅支持AndroidX### Gradle:
最新版本

//必选,默认仅支持armeabi-v7a
implementation 'com.shencoder:arc-face:1.0.1'
//可选,支持arm64-v8a
implementation 'com.shencoder:arc-face-arm64-v8a:1.0.1'
如果Gradle出现implementation失败的情况,可以在Project的build.gradle里面添加如下:
allprojects {
    repositories {
        //...
        maven { url 'https://dl.bintray.com/shencoder/android-lib' }
    }
}

项目内依赖CameraView用于摄像头预览,默认使用TextureView用于实现预览镜像。

使用事例

布局示例

<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <com.shencoder.arcface.view.FaceCameraView
        android:id="@+id/faceCameraView"
        android:layout_width="match_parent"
        android:layout_height="450dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

代码示例

基本使用

    val faceCameraView: FaceCameraView = findViewById(R.id.faceCameraView)
    val configuration = FaceConfiguration.Builder(this, object : OnRecognizeCallback {
   
        /**
         * 检测到的人脸数量
         * <p>运行在子线程</p>
         *
         * @param num 人脸数量
         * @param faceIds faceId
         */
        override fun detectFaceNum(num: Int, faceIds: List<Int>) {
   

        }

        /**
         * 有人,仅在有变化时调用一次
         * <p>运行在子线程</p>
         */
        override fun someone() {
   

        }

        /**
         * 无人,仅在有变化时调用一次
         * <p>运行在子线程</p>
         */
        override fun nobody() {
   

        }

        /**
         * 如果不想自动比对的话,可以通过此接口返回识别到的人脸特征码,仅在[FaceConfiguration.enableCompareFace] 为false时才会回调
         * <p>运行在子线程</p>
         *
         * @param faceId 人脸Id
         * @param feature 人脸特征码
         * @param recognizeInfo 识别到的其他信息,包含活体值、年龄、性别、人脸角度等信息
         * @param camera 预览数据
         * @param width 预览数据宽度
         * @param height 预览数据高度
         */
         override fun onGetFaceFeature(
             faceId: Int,
             feature: ByteArray,
             recognizeInfo: RecognizeInfo,
             nv21: ByteArray,
             width: Int,
             height: Int
         ) {
   
             Log.
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

冬季穿短裤

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值