1 Star 0 Fork 0

Qiansou / Android-Face-SDK-V6

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

Android-Face-SDK-V6

介绍

Android Face SDK 接口说明文档

SDK API 概览

public class FaceAPI  {

    /**
     * 初始化人脸引擎
     * 返回true 正确,返回其它值错误
     * */
    public boolean initial();

    /**
     * 人脸检测(包含检测、特征提取、人脸防伪【可选,返回face.spoofingScore】)
     * 返回结果中包含人脸框的位置,人脸的特征feature,用来与其它人脸照片的feature进行比对,即可得出两张脸的相似度。
     * 将多个人脸的feature及对应的faceid存储到sdcard中,就完成了人脸的注册功能,即1:N中的N。
     *
     * 如果购买的是带有人脸防伪的SDK,在运行完face_detect后,人脸真伪的值存储于 Face.spoofingScore中。
     * if face.spoofingScore > 0.95
     *      System.out.println("假脸");
     * else
     *      System.out.println("真脸");
     * */
    public Face face_detect(byte[] NV21_data , int width, int height);

    /**
     * 比对人脸特征
     * 对face_detect返回结果中的feature进行比对,得到两个feature(即两张人脸)的相似度。
     *
     * 对已经注册的人脸特征进行循环比对,选择最高分数的人脸,if score > Threshold((0,1)根据场景选择该值,推荐0.9) 即可认为是识别到了目标脸
     * */
    public float compare2feature(byte[] fea1, byte[] fea2);


    /**
     * 计算两个照片的相似度
     * 返回两个照片的相似度(0,1)
     * */
    public float compare2Image(String file1, String file2);


    /**
     * 人脸License检测接口
     * @return true or false
     */
    public static native boolean check();

    /**
     * 获取Android硬件指纹码接口
     * @return 32位的string 码
     */
    public static native String  getCode();
}

调用Demo

        //初始化人脸引擎
        com.face.faceantispoofing.FaceAPI  faceapi = new com.face.faceantispoofing.FaceAPI();
		
        boolean ret  = faceapi.initial();
        if (!ret){
            Log.e("error"," initial failed.");
        }

        //人脸检测 + 特征提取
        Bitmap bmp = BitmapFactory.decodeFile("/sdcard/1.png");
        //ImageFormat.NV21
        byte[] mImageNV21 =getNV21(bmp.getWidth() , bmp.getHeight(),bmp);
        int width  = bmp.getWidth();
        int height = bmp.getHeight();

        com.face.faceantispoofing.Face face = faceapi.face_detect(data,width,height);
        
        if (face == null) {
            Log.i("okface", "noface");
			return 
        }
        
        //选购了带防伪的SDK具备一下人脸真伪的检测功能
        float hackerScore = face.spoofingScore;
        Log.i("okface", "" + hackerScore);
        if (hackerScore > 0.95F) {
            Log.e("okface", "假脸");
        }
        
        byte[] feature = face.feature;
		//将提取的人脸特征 feature 保存下来(存储到sdcard上),关联业务系统的人脸ID, 
        //再利用 api.compare2feature(byte[] fea1, byte[] fea2) 对两个人脸的特征进行比对,即可获取两个照片的相似度
		// for( i =0; i < features.length(); i++){
		//	 score = api.compare2feature(features[i],feature)  //保留最高的相似度,如果相似度大于0.9(这个值可以根据场景选择合适的阈值)就可以推测两个脸非常的像。
		//	}

        //比对两张照片的相似度
        String file1 = "/sdcard/okface/1.jpg";
        String file2 = "/sdcard/okface/2.jpg";
        float score = faceapi.compare2Image(file1,file2);
        Log.i("score", "socre is "+ score);

空文件

简介

Android 人脸识别SDK 展开 收起
Java
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/qiansou_group/Android-Face-SDK-V6.git
git@gitee.com:qiansou_group/Android-Face-SDK-V6.git
qiansou_group
Android-Face-SDK-V6
Android-Face-SDK-V6
master

搜索帮助