离线人脸识别SeetaFace2

SeetaFace2Demo

离线人脸识别升级版SeetaFace2
GitHub地址:https://github.com/shuguoli68/LiSeetaFace2

效果截图
  1. 人脸检测识别
离线人脸识别SeetaFace2_第1张图片 离线人脸识别SeetaFace2_第2张图片 离线人脸识别SeetaFace2_第3张图片
2. 人脸相似度:
离线人脸识别SeetaFace2_第4张图片 离线人脸识别SeetaFace2_第5张图片 离线人脸识别SeetaFace2_第6张图片

使用

  • 一、How to use ?

Step 1. Add it in your root build.gradle at the end of repositories:

allprojects {
		repositories {
			...
			maven { url 'https://jitpack.io' }
		}
	}

Step 2. Add the dependency

dependencies {
	        implementation 'com.github.shuguoli68:LiSeetaFace2:1.0'
	}
  • 二、添加so文件、将模型文件复制到SD卡
  1. so文件下载:https://pan.baidu.com/s/1lG56H7GXuQDfC6ybhrXbNA
    armeabi-v7a: libSeetaFaceDetector2.so 、 libSeetaFaceLandmarker2.so 、 libSeetaFaceRecognizer2.so 、 libseetanet2.so
    将SO文件放置在jniLibs下的armeabi-v7a的文件夹下,并且在主module下(一般为app):
defaultConfig {
        ...
        ndk {
            abiFilters 'armeabi-v7a'
        }
    }
离线人脸识别SeetaFace2_第7张图片
  1. 模型文件下载: https://pan.baidu.com/s/1s4OWPnVFj3_xLNoQM1mdqA
    dat模型文件seetaface :SeetaFaceDetector2.0.ats 、 SeetaFaceRecognizer2.0.ats 、 SeetaPointDetector2.0.pts5.ats
    将三个ats文件放置在SD卡,根目录下的seetaface目录下,可以放在assets资源目录下,然后复制到SD卡,或者去服务器下载
离线人脸识别SeetaFace2_第8张图片
  • 二、初始化代码
Thread{
            if (SeetaHelper.copyAts(this))//将assets目录中的模型文件拷贝到SD卡
                SeetaHelper.getInstance().init()
        }.start()
  • 三、关键代码
val seetaImageData = SeetaUtil.ConvertToSeetaImageData(bitmap)//转化SeetaImageData
val seetaRects = SeetaHelper.getInstance().faceDetector2.Detect(seetaImageData)//人脸框的位置
val seetaPoints = SeetaHelper.getInstance().pointDetector2.Detect(seetaImageData, seetaRects[i])//脸部5个特征点
//得出两张人脸的相似度
val sim = SeetaHelper.getInstance().faceRecognizer2.Compare(
                    seetaImageData,
                    seetaPoints,
                    seetaImageData2,
                    seetaPoints2
                )

GitHub地址:https://github.com/shuguoli68/LiSeetaFace2

参考:

https://github.com/seetafaceengine/SeetaFace2
https://github.com/seetaface/SeetaFaceEngine2/blob/master/example/android/README.md

你可能感兴趣的:(Android,人脸识别,Kotlin)