我自认为不想做curd程序员,但是免不了的会对数据基本原子操作进行处理,项目开发过程中的增删改查少不了的,但是又不甘心于curd下去,所以想要在掌握现有知识的基础上,甚至逼迫自己去学习一些东西,去接触新的技术,足够的深度做不到,最起码广度要有所保证,每天进步一点点。
开篇写的算是自己的程序员生涯的一丢丢想法,言归正传,本篇介绍如何对接阿里云新版SDK。
首先开通阿里云人脸服务:
人脸人体-阿里云视觉智能开放平台
点击开通之后就能在控制台看到下图
点击人脸人体以后就会看到下图的具体服务列表,下面所有的服务都会有对应的文档以及在线调试方式。唯一一个要注意的就是上传人脸图片的时候目前只支持上海的Region。
具体可以参考一下文档:使用阿里云视觉智能开放平台时访问域名设置_视觉智能开放平台-阿里云帮助中心
还一个坑就是老版SDK与新版SDK的区别:
老版SDK不支持非上海节点OSS图片地址
新版SDK支持非上海节点OSS图片地址,甚至本地的文件都支持。
老版本文档地址:视觉智能开放平台老版本JavaSDK(不推荐)_视觉智能开放平台-阿里云帮助中心
新版本文档地址:
视觉智能开放平台JavaSDK_视觉智能开放平台-阿里云帮助中心
接下来就直接上代码咯!
pom依赖
com.aliyun
facebody20191230
3.0.7
com.aliyun
ocr20191230
1.0.26
cn.hutool
hutool-all
5.5.8
工具类
package com.qz.biz.modular.facebody.utils;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.extra.spring.SpringUtil;
import com.aliyun.facebody20191230.models.*;
import com.aliyun.tea.TeaException;
import com.aliyun.tea.TeaModel;
import com.aliyuncs.exceptions.ClientException;
import com.aliyuncs.exceptions.ServerException;
import com.google.gson.Gson;
import com.qz.biz.modular.facebody.result.GetFaceResult;
import com.qz.biz.modular.facebody.result.SearchFaceResult;
import com.qz.dev.api.DevConfigApi;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.multipart.MultipartFile;
import sun.misc.BASE64Decoder;
import java.io.IOException;
import java.util.List;
/**
* @author lihao
* @create 2023-04-13 13:44
* @desc
**/
@Slf4j
public class FaceRecognitionUtil {
/**
* 阿里云控制台获取 access key
*/
private static final String ACCESSKEY="";
/**
* 阿里云控制台获取 access secret
*/
private static final String SECRET="";
private static com.aliyun.facebody20191230.Client client;
private static com.aliyun.ocr20191230.Client ocrClient;
/**
* 使用AK&SK初始化账号Client
* @return Client
* @throws Exception
*/
private static void createClient(){
DevConfigApi devConfigApi = SpringUtil.getBean(DevConfigApi.class);
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// 您的 AccessKey ID
.setAccessKeyId(ACCESSKEY)
// 您的 AccessKey Secret
.setAccessKeySecret(SECRET);
// 2、访问的域名。注意:这个地方需要求改为相应类目的域名,参考:https://help.aliyun.com/document_detail/143103.html
config.endpoint = "facebody.cn-shanghai.aliyuncs.com";
// 3、这里只是以ocr为例,其他能力请使用相应类目的包下面的Client类
try {
client=new com.aliyun.facebody20191230.Client(config);
} catch (Exception e) {
e.printStackTrace();
log.info("初始化人脸识别client失败!");
}
}
/**
* 使用AK&SK初始化账号ocrClient
* @return Client
* @throws Exception
*/
private static void createOcrClient(){
DevConfigApi devConfigApi = SpringUtil.getBean(DevConfigApi.class);
com.aliyun.teaopenapi.models.Config config = new com.aliyun.teaopenapi.models.Config()
// 您的 AccessKey ID
.setAccessKeyId()
// 您的 AccessKey Secret
.setAccessKeySecret();
// 2、访问的域名。注意:这个地方需要求改为相应类目的域名,参考:https://help.aliyun.com/document_detail/143103.html
config.endpoint = "ocr.cn-shanghai.aliyuncs.com";
// 3、这里只是以ocr为例,其他能力请使用相应类目的包下面的Client类
try {
ocrClient=new com.aliyun.ocr20191230.Client(config);
} catch (Exception e) {
e.printStackTrace();
log.info("初始化图像识别client失败!");
}
}
/**
* 创建人脸数据库
* @param dbName 数据库名称
*/
public static void createFaceDb(String dbName) {
createClient();
com.aliyun.facebody20191230.models.CreateFaceDbRequest createFaceDbRequest = new com.aliyun.facebody20191230.models.CreateFaceDbRequest()
.setName(dbName);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
// 复制代码运行请自行打印 API 的返回值
CreateFaceDbResponse createFaceDbResponse = client.createFaceDbWithOptions(createFaceDbRequest, runtime);
// 获取整体结果
log.info(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(createFaceDbResponse)));
} catch (TeaException teaException) {
teaException.printStackTrace();
// 获取整体报错信息
System.out.println(com.aliyun.teautil.Common.toJSONString(teaException));
// 获取单个字段
System.out.println(teaException.getCode());
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 添加人脸样本
* @param dbName 数据库名称
* @param entityId 实体ID
* @param labels 标签
*/
public static void addFaceEntity(String dbName, String entityId,String labels){
createClient();
com.aliyun.facebody20191230.models.AddFaceEntityRequest addFaceEntityRequest = new com.aliyun.facebody20191230.models.AddFaceEntityRequest()
.setDbName(dbName)
.setEntityId(entityId)
.setLabels(labels);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
AddFaceEntityResponse addFaceEntityResponse = client.addFaceEntityWithOptions(addFaceEntityRequest, runtime);
// 获取整体结果
log.info("添加人脸样本返回结果===>{}",com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(addFaceEntityResponse)));
} catch (TeaException teaException) {
teaException.printStackTrace();
// 获取整体报错信息
System.out.println(com.aliyun.teautil.Common.toJSONString(teaException));
// 获取单个字段
System.out.println(teaException.getCode());
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 查询人脸样本
* @param dbName 数据库名称
* @param entityId 实体ID
*/
public static GetFaceResult getFaceEntity(String dbName, String entityId)
{
createClient();
com.aliyun.facebody20191230.models.GetFaceEntityRequest getFaceEntityRequest = new com.aliyun.facebody20191230.models.GetFaceEntityRequest()
.setDbName(dbName)
.setEntityId(entityId);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try{
GetFaceEntityResponse getFaceEntityResponse = client.getFaceEntityWithOptions(getFaceEntityRequest, runtime);
log.info("查询人脸样本:");
log.info(new Gson().toJson(getFaceEntityResponse));
return BeanUtil.copyProperties(getFaceEntityResponse.getBody().getData(),GetFaceResult.class);
} catch (ServerException e) {
e.printStackTrace();
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 查询人脸样本列表
* @param dbName 数据库名称
* @param Offset 起始记录
*/
public static void listFaceEntities(String dbName, Integer Offset) throws Exception {
createClient();
com.aliyun.facebody20191230.models.ListFaceEntitiesRequest listFaceEntitiesRequest = new com.aliyun.facebody20191230.models.ListFaceEntitiesRequest()
.setDbName(dbName)
.setOffset(Offset);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try{
ListFaceEntitiesResponse listFaceEntitiesResponse = client.listFaceEntitiesWithOptions(listFaceEntitiesRequest, runtime);
log.info("查询人脸样本列表:");
log.info(new Gson().toJson(listFaceEntitiesResponse));
} catch (ServerException e) {
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
}
}
/**
* 更新人脸样本
* @param dbName 数据库名称
* @param entityId 实体ID
* @param labels 标签名称
*/
public static void updateFaceEntity(String dbName, String entityId, String labels){
createClient();
com.aliyun.facebody20191230.models.UpdateFaceEntityRequest updateFaceEntityRequest = new com.aliyun.facebody20191230.models.UpdateFaceEntityRequest()
.setDbName(dbName)
.setEntityId(entityId)
.setLabels(labels);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try{
UpdateFaceEntityResponse updateFaceEntityResponse = client.updateFaceEntityWithOptions(updateFaceEntityRequest, runtime);
log.info("更新人脸样本:");
log.info(new Gson().toJson(updateFaceEntityResponse));
} catch (ServerException e) {
e.printStackTrace();
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 删除人脸样本
* @param dbName 数据库名称
* @param entityId 实体ID
*/
public static void deleteFaceEntity(String dbName, String entityId)
{
createClient();
com.aliyun.facebody20191230.models.DeleteFaceEntityRequest deleteFaceEntityRequest = new com.aliyun.facebody20191230.models.DeleteFaceEntityRequest()
.setDbName(dbName)
.setEntityId(entityId);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try{
DeleteFaceEntityResponse deleteFaceEntityResponse = client.deleteFaceEntityWithOptions(deleteFaceEntityRequest, runtime);
log.info("删除人脸样本:");
log.info(new Gson().toJson(deleteFaceEntityResponse));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 查看数据库列表
*/
public static void listFaceDbs()
{
createClient();
com.aliyun.facebody20191230.models.ListFaceDbsRequest listFaceDbsRequest = new com.aliyun.facebody20191230.models.
ListFaceDbsRequest();
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try {
ListFaceDbsResponse response = client.listFaceDbsWithOptions(listFaceDbsRequest, runtime);
log.info("查看数据库列表: ");
log.info(new Gson().toJson(response));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 添加人脸数据 file 格式
* @param dbName 数据库名称
* @param entityId 实体ID
* @param file 人脸图片
*/
public static void addFace(String dbName, String entityId, MultipartFile file) {
createClient();
try{
com.aliyun.facebody20191230.models.AddFaceAdvanceRequest addFaceRequest = new com.aliyun.facebody20191230.models.AddFaceAdvanceRequest()
.setDbName(dbName)
.setEntityId(entityId)
.setImageUrlObject(file.getInputStream());
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
AddFaceResponse addFaceResponse = client.addFaceAdvance(addFaceRequest, runtime);
log.info("添加人脸数据:");
log.info(new Gson().toJson(addFaceResponse));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
}
catch (IOException e) {
e.printStackTrace();
}catch (Exception e) {
e.printStackTrace();
}
}
/**
* base64转MultipartFile
* @param base64
* @return
*/
public static MultipartFile base64ToMultipart(String base64) {
try {
String[] baseStrs = base64.split(",");
BASE64Decoder decoder = new BASE64Decoder();
byte[] b;
b = decoder.decodeBuffer(baseStrs[1]);
for(int i = 0; i < b.length; ++i) {
if (b[i] < 0) {
b[i] += 256;
}
}
return new BASE64DecodedMultipartFile(b, baseStrs[0]);
} catch (IOException e) {
e.printStackTrace();
return null;
}
}
/**
* 搜索人脸
* @param dbName 数据库名称
* @param file 图片
*/
public static SearchFaceResult searchFace(String dbName, MultipartFile file)
{
createClient();
try{
com.aliyun.facebody20191230.models.SearchFaceAdvanceRequest searchFaceRequest = new com.aliyun.facebody20191230.models.SearchFaceAdvanceRequest()
.setDbName(dbName).setImageUrlObject(file.getInputStream()).setLimit(1);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
SearchFaceResponse searchFaceResponse = client.searchFaceAdvance(searchFaceRequest, runtime);
log.info("搜索人脸:");
log.info(new Gson().toJson(searchFaceResponse));
if(searchFaceResponse.statusCode ==200){
//请求成功以后映射返回值
List list =searchFaceResponse.getBody().getData().getMatchList();
SearchFaceResult searchFaceResult = null;
for (SearchFaceResponseBody.SearchFaceResponseBodyDataMatchList dataMatchList :list){
searchFaceResult = BeanUtil.copyProperties(dataMatchList.getFaceItems().get(0),SearchFaceResult.class);
}
//判断相识度千分之一 三个参考阈值为0.35,0.45和0.6,分别对应千分之一,万分之一和十万分之一的误识率
if(searchFaceResult.getScore() >0.35){
return searchFaceResult;
}
return null;
}
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
/**
* 删除人脸
* @param dbName 数据库名称
* @param faceId 人脸数据ID
*/
public static void deleteFace(String dbName, String faceId)
{
createClient();
com.aliyun.facebody20191230.models.DeleteFaceRequest deleteFaceRequest = new com.aliyun.facebody20191230.models.DeleteFaceRequest()
.setDbName(dbName).setFaceId(faceId);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try{
DeleteFaceResponse deleteFaceResponse = client.deleteFaceWithOptions(deleteFaceRequest, runtime);
log.info("删除人脸:");
log.info(new Gson().toJson(deleteFaceResponse));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 删除人脸数据库
* @param dbName 数据库名称
*/
public static void deleteFaceDb(String dbName)
{
createClient();
com.aliyun.facebody20191230.models.DeleteFaceDbRequest deleteFaceDbRequest = new com.aliyun.facebody20191230.models.DeleteFaceDbRequest()
.setName(dbName);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try{
DeleteFaceDbResponse deleteFaceDbResponse = client.deleteFaceDbWithOptions(deleteFaceDbRequest, runtime);
log.info("删除数据库:");
log.info(new Gson().toJson(deleteFaceDbResponse));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 人脸对比
* @param imageURLA 待对比图片URL地址A
* @param imageURLB 待对比图片URL地址B
*/
public static void compareFace(String imageURLA, String imageURLB)
{
createClient();
com.aliyun.facebody20191230.models.CompareFaceRequest compareFaceRequest = new com.aliyun.facebody20191230.models.CompareFaceRequest()
.setImageDataA(imageURLA)
.setImageDataB(imageURLB);
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
try{
CompareFaceResponse compareFaceResponse = client.compareFaceWithOptions(compareFaceRequest, runtime);
log.info("人脸对比:");
log.info(new Gson().toJson(compareFaceResponse));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 人脸对比 通过文件比对
* @param fileA 待对比图片A
* @param fileB 待对比图片B
*/
public static void compareFace(MultipartFile fileA, MultipartFile fileB)
{
createClient();
try{
com.aliyun.facebody20191230.models.CompareFaceAdvanceRequest compareFaceRequest = new com.aliyun.facebody20191230.models.CompareFaceAdvanceRequest()
.setImageURLAObject(fileA.getInputStream())
.setImageURLBObject(fileB.getInputStream());
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
CompareFaceResponse compareFaceResponse = client.compareFaceAdvance(compareFaceRequest, runtime);
log.info("人脸对比:");
log.info(new Gson().toJson(compareFaceResponse));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* 人脸活体检测
* @param file
*/
public static Boolean detectLivingFace(MultipartFile file){
createClient();
try{
com.aliyun.facebody20191230.models.DetectLivingFaceAdvanceRequest.DetectLivingFaceAdvanceRequestTasks tasks0 = new com.aliyun.facebody20191230.models.DetectLivingFaceAdvanceRequest.DetectLivingFaceAdvanceRequestTasks()
.setImageURLObject(file.getInputStream());
com.aliyun.facebody20191230.models.DetectLivingFaceAdvanceRequest detectLivingFaceRequest = new com.aliyun.facebody20191230.models.DetectLivingFaceAdvanceRequest()
.setTasks(java.util.Arrays.asList(
tasks0
));
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
DetectLivingFaceResponse response = client.detectLivingFaceAdvance(detectLivingFaceRequest, runtime);
if(response.getStatusCode()==200){
if("normal".equals(response.getBody().getData().getElements().get(0).getResults().get(0).getLabel())){
return true;
}
}
log.info("人脸活体检测:");
log.info(new Gson().toJson(response));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
/**
* 人体计数
* @param file
* @return 人体的个数
*/
public static Integer detectBodyCount(MultipartFile file){
createClient();
try{
com.aliyun.facebody20191230.models.DetectBodyCountAdvanceRequest detectBodyCountAdvanceRequest = new com.aliyun.facebody20191230.models.DetectBodyCountAdvanceRequest()
.setImageURLObject(file.getInputStream());
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
DetectBodyCountResponse detectBodyCountResponse = client.detectBodyCountAdvance(detectBodyCountAdvanceRequest, runtime);
if(detectBodyCountResponse.getStatusCode()==200){
return detectBodyCountResponse.getBody().getData().getPersonNumber();
}
log.info("人体计数:");
log.info(new Gson().toJson(detectBodyCountResponse));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
/**
* 人脸检测与五官定位
* @param file
* @return 检测出的人脸个数
*/
public static Integer detectFace(MultipartFile file){
createClient();
try{
com.aliyun.facebody20191230.models.DetectFaceAdvanceRequest detectFaceRequest = new com.aliyun.facebody20191230.models.DetectFaceAdvanceRequest()
.setImageURLObject(file.getInputStream());
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
DetectFaceResponse detectFaceResponse = client.detectFaceAdvance(detectFaceRequest, runtime);
if(detectFaceResponse.getStatusCode()==200){
return detectFaceResponse.getBody().getData().getFaceCount();
}
log.info("人脸检测与五官定位:");
log.info(new Gson().toJson(detectFaceResponse));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
} catch (Exception e) {
e.printStackTrace();
}
return 0;
}
/**
* 扫描二维码
* @param file
* @return 扫描二维码
*/
public static void recognizeQrCode(MultipartFile file){
createOcrClient();
try{
com.aliyun.ocr20191230.models.RecognizeQrCodeAdvanceRequest.RecognizeQrCodeAdvanceRequestTasks tasks0 = new com.aliyun.ocr20191230.models.RecognizeQrCodeAdvanceRequest.RecognizeQrCodeAdvanceRequestTasks()
.setImageURLObject(file.getInputStream());
com.aliyun.ocr20191230.models.RecognizeQrCodeAdvanceRequest recognizeQrCodeAdvanceRequest = new com.aliyun.ocr20191230.models.RecognizeQrCodeAdvanceRequest()
.setTasks(java.util.Arrays.asList(tasks0));
com.aliyun.teautil.models.RuntimeOptions runtime = new com.aliyun.teautil.models.RuntimeOptions();
RecognizeQrCodeResponse response = ocrClient.recognizeQrCodeAdvance(recognizeQrCodeAdvanceRequest, runtime);
System.out.println(com.aliyun.teautil.Common.toJSONString(TeaModel.buildMap(response)));
log.info("扫描二维码:");
log.info(new Gson().toJson(response));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
log.info("ErrCode:" + e.getErrCode());
log.info("ErrMsg:" + e.getErrMsg());
log.info("RequestId:" + e.getRequestId());
} catch (Exception e) {
e.printStackTrace();
}
}
}
返回结果实体类
package com.qz.biz.modular.facebody.result;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author lihao
* @create 2023-04-13 18:07
* @desc 查询人脸识别样本返回值
**/
@Data
public class GetFaceResult {
@ApiModelProperty(value = "数据库名称")
private String dbName;
@ApiModelProperty(value = "实体ID")
private String entityId;
@ApiModelProperty(value = "查询到的人脸标签")
private String labels;
}
package com.qz.biz.modular.facebody.result;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author lihao
* @create 2023-04-13 15:10
* @desc
**/
@Data
public class SearchFaceResult {
@ApiModelProperty(value = "人脸图片数据ID")
private String faceId;
@ApiModelProperty(value = "人脸的相似度")
private Float score;
@ApiModelProperty(value = "自定义信息(字符串)")
private String extraData;
@ApiModelProperty(value = "数据库名称")
private String dbName;
@ApiModelProperty(value = "转换后的置信度")
private Float confidence;
}