(6)seetaface6 JNI之活体检测,攻击人脸检测

项目地址

seetaface6SDK地址

前期准备

  1. 下载项目
  2. 下载seetaface6 模型文件: 模型文件1 (code:ngne),模型文件2 (code: t6j0)
  3. 配置模型文件到项目中,运行Test

攻击人脸判断也叫活体判断

  1. 在介绍人脸识别很关键的人脸跟踪和质量评估之前,先看一个对应用很重要的活体检测模块。
  2. 关于活体检测模块的重要程度和原因,这里不做过多赘述,这里直接给出SeetaFace的活体检测方案。
  3. 活体检测结合了两个方法,全局活体检测和局部活体检测。
  4. 全局活体检测就是对图片整体做检测,主要是判断是否出现了活体检测潜在的攻击介质,如手机、平板、照片等等。
  5. 局部活体检测是对具体人脸的成像细节通过算法分析,区别是一次成像和二次成像,如果是二次成像则认为是出现了攻击。

攻击人脸检测代码

package com.seeta.sdk.proxy;

import com.seeta.pool.SeetaConfSetting;
import com.seeta.proxy.AgePredictorProxy;
import com.seeta.proxy.FaceAntiSpoofingProxy;
import com.seeta.proxy.FaceDetectorProxy;
import com.seeta.proxy.FaceLandmarkerProxy;
import com.seeta.sdk.*;
import com.seeta.sdk.util.LoadNativeCore;
import com.seeta.sdk.util.SeetafaceUtil;
/**
 * 活体检测,攻击人脸检测
 */
public class FaceAntiSpoofingProxyTest {
    
	//模型文件夹路径
	public static String CSTA_PATH = "E:\\models";

	//图片路径
	public static String fileName = "E:\\111.jpg";

	// 拼接模型路径
	public static String[] detector_cstas = {CSTA_PATH + "/face_detector.csta"};

	// 人脸关键点定位模型路径拼接
	public static String[] landmarker_cstas = {CSTA_PATH + "/face_landmarker_pts5.csta"};

	//活体检测模型,两个
	public static  String[] fas = {CSTA_PATH + "/fas_first.csta",CSTA_PATH + "/fas_second.csta"};

	//加载dll
	static {
		LoadNativeCore.LOAD_NATIVE(SeetaDevice.SEETA_DEVICE_AUTO);
	}

	public static void main(String[] args) {

		//人脸识别检测器对象池配置,可以配置对象的个数哦
		SeetaConfSetting detectorPoolSetting = new SeetaConfSetting(new SeetaModelSetting(0, detector_cstas, SeetaDevice.SEETA_DEVICE_AUTO));
		//人脸检测器对象池代理 , spring boot可以用FaceDetectorProxy来配置Bean
		FaceDetectorProxy faceDetectorProxy = new FaceDetectorProxy(detectorPoolSetting);

		//人脸关键点定位器对象池配置
		SeetaConfSetting faceLandmarkerPoolSetting = new SeetaConfSetting(new SeetaModelSetting(0, landmarker_cstas, SeetaDevice.SEETA_DEVICE_AUTO));
		//人脸关键点定位器对象池代理 , spring boot可以用FaceLandmarkerProxy来配置Bean
		FaceLandmarkerProxy faceLandmarkerProxy = new FaceLandmarkerProxy(faceLandmarkerPoolSetting);

		SeetaConfSetting faceAntiSpoofingSetting = new SeetaConfSetting(new SeetaModelSetting(0, fas, SeetaDevice.SEETA_DEVICE_AUTO));
		FaceAntiSpoofingProxy faceAntiSpoofingProxy = new FaceAntiSpoofingProxy(faceAntiSpoofingSetting);

		try {
			SeetaImageData image = SeetafaceUtil.toSeetaImageData(fileName);
			SeetaRect[] detects = faceDetectorProxy.detect(image);
			for (SeetaRect seetaRect : detects) {
				SeetaPointF[] pointFS = faceLandmarkerProxy.mark(image, seetaRect);
				FaceAntiSpoofing.Status predict = faceAntiSpoofingProxy.predict(image,seetaRect, pointFS);
				//输出
				System.out.println(predict);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

输出结果

  1. FaceAntiSpoofing.Status:
    REAL, //< 真实人脸
    SPOOF, //< 攻击人脸(假人脸)
    FUZZY, //< 无法判断(人脸成像质量不好)
    DETECTING, //< 正在检测
结果:REAL

总结

1. 人脸识别过程复杂,但这个代码简单。
2. 精度高,这边的模型都是中科院商业开源的,比起社区的模型,用到的训练集多很多。
3. 功能齐全 :
人脸检测和关键点定位
人脸特征提取和对比
人脸特征提取
人脸特征对比
活体检测
人脸跟踪
质量评估
年龄识别
性别识别
口罩检测
口罩人脸识别
眼睛状态检测

不懂seetaface6SDK的可以先看gitee项目哦

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值