public class FaceUtil extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
private static String |
apiKey |
private static String |
apiSecret |
private static String |
compare |
private static String |
detect |
private static FaceService |
faceService |
private static FaceUtil |
faceUtil |
private static String |
getdetail |
private static String |
ocridcard |
private static String |
search |
private static String |
setuserid |
| 限定符 | 构造器和说明 |
|---|---|
private |
FaceUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
Compare |
compare(String face_token1,
String image_url1,
File image_file1,
String image_base64_1,
String face_token2,
String image_url2,
File image_file2,
String image_base64_2,
String face_rectangle1,
String face_rectangle2)
描述
将两个人脸进行比对,来判断是否为同一个人,返回比对结果置信度和不同误识率下的阈值。
|
Detect |
detect(File file,
String image_base64,
String image_url,
Integer return_landmark,
String return_attributes,
Integer calculate_all,
String face_rectangle,
Integer beauty_score_min,
Integer beauty_score_max)
传入图片进行人脸检测和人脸分析。
|
Detail |
getdetail(String face_token)
通过传入在Detect API检测出的人脸标识face_token,获取一个人脸的关联信息,包括源图片ID、归属的FaceSet。
|
static FaceUtil |
getInstance() |
static FaceUtil |
getInstance(String key,
String secret) |
IdCard |
ocridcard(File file,
String image_base64,
String file_url)
获取身份证详细信息
|
Search |
search(String face_token,
String image_url,
File image_file,
String image_base64,
String outer_id,
int return_result_count,
String face_rectangle)
在一个已有的 FaceSet 中找出与目标人脸最相似的一张或多张人脸,返回置信度和不同误识率下的阈值。
|
Detail |
setuserid(String face_token,
String user_id)
为检测出的某一个人脸添加标识信息,该信息会在Search接口结果中返回,用来确定用户身份。
|
private static String apiKey
private static String apiSecret
private static String ocridcard
private static String detect
private static String compare
private static String search
private static String setuserid
private static String getdetail
private static volatile FaceUtil faceUtil
private static FaceService faceService
public static FaceUtil getInstance()
public IdCard ocridcard(File file, String image_base64, String file_url)
file - file文件 file_url:图片网络地址 image_base64:图片base64编码 选其一public Detect detect(File file, String image_base64, String image_url, Integer return_landmark, String return_attributes, Integer calculate_all, String face_rectangle, Integer beauty_score_min, Integer beauty_score_max)
file, - image_base64, image_url 选其一return_landmark - 是否检测并返回人脸关键点。合法值为 2:检测。返回 106 个人脸关键点。 1:检测。返回 83 个人脸关键点。 0:不检测return_attributes - 是否检测并返回根据人脸特征判断出的年龄、性别、情绪等属性。合法值为:
希望检测并返回的属性。
需要将属性组成一个用逗号分隔的字符串,属性之间的顺序没有要求。
关于各属性的详细描述,"gender,age,smile,headpose,blur,eyestatus,emotion,facequality,ethnicity,beauty,mouthstatus,eyegaze,skinstatus"calculate_all(仅正式key可用) - 是否检测并返回所有人脸的人脸关键点和人脸属性。如果不使用此功能,则本 API 只会对人脸面积最大的五个人脸分析人脸关键点和人脸属性。合法值为:
1:是
0:否face_rectangle(仅正式key可用) - 是否指定人脸框位置进行人脸检测。
如果此参数传入值为空,或不传入此参数,则不使用此功能。本 API 会自动检测图片内所有区域的所有人脸。
如果使用正式 API Key 对此参数传入符合格式要求的值,则使用此功能。需要传入一个字符串代表人脸框位置,系统会根据此坐标对框内的图像进行人脸检测,以及人脸关键点和人脸属性等后续操作。系统返回的人脸矩形框位置会与传入的 face_rectangle 完全一致。对于此人脸框之外的区域,系统不会进行人脸检测,也不会返回任何其他的人脸信息。
参数规格:四个正整数,用逗号分隔,依次代表人脸框左上角纵坐标(top),左上角横坐标(left),人脸框宽度(width),人脸框高度(height)。例如:70,80,100,100beauty_score_min - 颜值评分分数区间的最小值。默认为0
注:默认颜值评分分数区间为0-100.可通过beauty_score_min和beauty_score_max来调节分数区间,满足您的场景需求。beauty_score_max - 颜值评分分数区间的最大值。默认为100public Compare compare(String face_token1, String image_url1, File image_file1, String image_base64_1, String face_token2, String image_url2, File image_file2, String image_base64_2, String face_rectangle1, String face_rectangle2)
face_token1 - 第一个人脸标识 face_token,优先使用该参数face_token2 - 第二个人脸标识 face_token,优先使用该参数face_rectangle1 - 当传入图片进行人脸检测时,是否指定人脸框位置进行检测。
如果此参数传入值为空,或不传入此参数,则不使用此功能。本 API 会自动检测图片内所有区域的所有人脸。
如果使用正式 API Key 对此参数传入符合格式要求的值,则使用此功能。需要传入一个字符串代表人脸框位置,系统会根据此坐标对框内的图像进行人脸检测,以及人脸关键点和人脸属性等后续操作。系统返回的人脸矩形框位置会与传入的 face_rectangle 完全一致。对于此人脸框之外的区域,系统不会进行人脸检测,也不会返回任何其他的人脸信息。
参数规格:四个正整数,用逗号分隔,依次代表人脸框左上角纵坐标(top),左上角横坐标(left),人脸框宽度(width),人脸框高度(height)。例如:70,80,100,100
注:只有在传入 image_url1、image_file1 和 image_base64_1 三个参数中任意一个时,本参数才生效。face_rectangle2 - 当传入图片进行人脸检测时,是否指定人脸框位置进行检测。
如果此参数传入值为空,或不传入此参数,则不使用此功能。本 API 会自动检测图片内所有区域的所有人脸。
如果使用正式 API Key 对此参数传入符合格式要求的值,则使用此功能。需要传入一个字符串代表人脸框位置,系统会根据此坐标对框内的图像进行人脸检测,以及人脸关键点和人脸属性等后续操作。系统返回的人脸矩形框位置会与传入的 face_rectangle 完全一致。对于此人脸框之外的区域,系统不会进行人脸检测,也不会返回任何其他的人脸信息。
参数规格:四个正整数,用逗号分隔,依次代表人脸框左上角纵坐标(top),左上角横坐标(left),人脸框宽度(width),人脸框高度(height)。例如:70,80,100,100
注:只有在传入image_url2、image_file2 和image_base64_2 三个参数中任意一个后本参数才生效。public Search search(String face_token, String image_url, File image_file, String image_base64, String outer_id, int return_result_count, String face_rectangle)
face_token - 进行搜索的目标人脸的 face_token,优先使用该参数image_url - 目标人脸所在的图片的 URLimage_file - 目标人脸所在的图片,二进制文件,需要用 post multipart/form-data 的方式上传。image_base64 - base64 编码的二进制图片数据 如果同时传入了 image_url、image_file 和 image_base64 参数,本 API 使用顺序为 image_file 优先,image_url 最低。outer_id - 用户自定义的 FaceSet 标识return_result_count - 控制返回比对置信度最高的结果的数量。合法值为一个范围 [1,5] 的整数。默认值为 1face_rectangle(正式key可用) - 当传入图片进行人脸检测时,是否指定人脸框位置进行检测。
如果此参数传入值为空,或不传入此参数,则不使用此功能。本 API 会自动检测图片内所有区域的所有人脸。
如果使用正式 API Key 对此参数传入符合格式要求的值,则使用此功能。需要传入一个字符串代表人脸框位置,系统会根据此坐标对框内的图像进行人脸检测,以及人脸关键点和人脸属性等后续操作。系统返回的人脸矩形框位置会与传入的 face_rectangle 完全一致。对于此人脸框之外的区域,系统不会进行人脸检测,也不会返回任何其他的人脸信息。
参数规格:四个正整数,用逗号分隔,依次代表人脸框左上角纵坐标(top),左上角横坐标(left),人脸框宽度(width),人脸框高度(height)。例如:70,80,100,100
注:只有在传入 image_url、image_file 和 image_base64 三个参数中任意一个时,本参数才生效。public Detail getdetail(String face_token)
face_token - Copyright © 2020. All rights reserved.