(3)seetaface6 JNI之人脸年龄评估

项目地址

seetaface6SDK地址

前期准备

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

人脸年龄评估代码

package com.seeta.sdk.proxy;

import com.seeta.pool.SeetaConfSetting;
import com.seeta.proxy.AgePredictorProxy;
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 AgePredictorProxyTest {

	//模型文件夹路径
	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[] age_predictor_cstas = {CSTA_PATH + "/age_predictor.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 agePredictorPoolSetting = new SeetaConfSetting(new SeetaModelSetting(0, age_predictor_cstas, SeetaDevice.SEETA_DEVICE_AUTO));
		//人脸年龄检测器对象池代理 , spring boot可以用AgePredictorProxy来配置Bean
		AgePredictorProxy agePredictorProxy = new AgePredictorProxy(agePredictorPoolSetting);

		try {
			//图片
			SeetaImageData image = SeetafaceUtil.toSeetaImageData(fileName);
			//检测人脸,识别到人脸
			SeetaRect[] detects = faceDetectorProxy.detect(image);
			for (SeetaRect seetaRect : detects) {
				//人脸关键点定位
				SeetaPointF[] pointFS = faceLandmarkerProxy.mark(image, seetaRect);
				//识别年龄
				int age = agePredictorProxy.predictAgeWithCrop(image, pointFS);
				System.out.println(age);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

输出结果

  1. int类型年龄
结果:30

总结

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

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

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值