public interface FaceApi
Modifier and Type | Method and Description |
---|---|
double |
compare2Face(byte[] imgData1,
CodeInfo facePos1,
byte[] imgData2,
CodeInfo facePos2)
对人脸图像提取特征码,返回比较相似度结果
imgData1和imgData2相等或imgData2为 null 时,即比较同一张图像中的两张人脸的相似度
调用该方法时假设图像(imgData1 和imgData2 )能正常解码,所以当对图像解码出现异常时,将 ImageErrorException 异常对象封装到RuntimeException 抛出任何参数为 null 则抛出IllegalArgumentException |
double |
compareCode(byte[] code1,
byte[] code2)
特征码比对
参数为 null 或长度不一致则抛出IllegalArgumentException 异常,返回两个特征码之间的相似度(0.0~1) |
double[] |
compareCodes(byte[] code1,
CodeInfo[] codes)
特征码比对1:N
返回对应的特征码相似度数组 |
CompareResult |
compareFaces(byte[] code,
byte[] imgData,
int faceNum)
|
java.util.List<java.lang.Double> |
compareFeatures(byte[] code1,
java.util.List<byte[]> codes)
特征码比对1:N
|
double |
detectAndCompare2Face(byte[] imgData1,
FRect detectRect1,
byte[] imgData2,
FRect detectRect2)
对两个图像指定范围(
FRect )进行人脸检测,找到并提取唯一的人脸特征码,然后比较相似度,返回相似度结果imgData1和imgData2相等或imgData2为 null 时,
即比较同一张图像中的两张人脸的相似度,这种情况下detectRect1和detectRect2都不能为null imgData1和imgData2不相等且都不为 null 时,detectRect1和detectRect2被忽略 |
CodeInfo[] |
detectAndGetCodeInfo(byte[] imgData,
int faceNum)
先对图像数据
imgData 进行人脸检测,然后提取人脸特征码返回所有成功提取特征码的 CodeInfo 数组,
与getCodeInfo(byte[], int, CodeInfo[]) 的返回结果有差别,返回结果中不包含检测到人脸但提取特征码失败的对象 |
CodeInfo |
detectCenterFace(byte[] imgData)
检测最中心的人脸
返回人脸位置数据对象 CodeInfo |
CodeInfo[] |
detectFace(byte[] imgData)
|
CodeInfo |
detectMaxFace(byte[] imgData)
检测最大的人脸
返回人脸位置数据对象 CodeInfo |
CodeInfo |
getCodeInfo(byte[] imgData,
CodeInfo facePos)
|
CodeInfo[] |
getCodeInfo(byte[] imgData,
int faceNum,
CodeInfo[] facePos)
根据
facePos 提供的人脸信息位置, 在imgData 图像中提取特征码与 detectAndGetCodeInfo(byte[], int) 不同, 本方法不对图像数据imgData 进行人脸检测,假设 facePos 是 detectFace(byte[]) 或 #detectFaceAgain(byte[], FRect[]) 的返回结果返回facePos,如果没有提取到特征码,则对应元素 CodeInfo.getCode() 返回null |
byte[] |
getFeature(java.util.Map<java.nio.ByteBuffer,CodeInfo> faces)
多张人脸提取特征(用于多张人脸合成一个特征的算法)
返回人脸特征数据 #multiFaceFeature() 返回false 时代表此方法未被实现,执行会抛出异常 |
boolean |
hasFace(byte[] imgData)
判断图像是否能提取到人脸特征码
为 true 则能检测到人脸并能提取特征码 |
boolean |
isLocal()
返回当前接口实现方式
false WebService类型 true 本地实现 |
CodeInfo[] |
matDetectAndGetCodeInfo(net.gdface.image.MatType matType,
byte[] matData,
int width,
int height,
int faceNum)
先对图像矩阵数据
imgData 进行人脸检测,然后提取人脸特征码返回包含人脸特征数据的 CodeInfo 数组 |
CodeInfo[] |
matDetectFace(net.gdface.image.MatType matType,
byte[] matData,
int width,
int height)
对图像矩阵进行人脸检测
返回人脸信息对象列表,没有检测到人脸返回空表 |
CodeInfo |
matDetectMaxFace(net.gdface.image.MatType matType,
byte[] matData,
int width,
int height)
检测最大的人脸
返回人脸位置数据对象 CodeInfo |
CodeInfo |
matGetCodeInfo(net.gdface.image.MatType matType,
byte[] matData,
int width,
int height,
CodeInfo facePos)
|
CodeInfo[] |
matGetCodeInfo(net.gdface.image.MatType matType,
byte[] matData,
int width,
int height,
int facenum,
CodeInfo[] facePos)
根据facePos提供的人脸信息位置, 在图像矩阵中提取特征码
包含人脸特征数据的facePos |
boolean |
matHasFace(net.gdface.image.MatType matType,
byte[] matData,
int width,
int height)
判断图像矩阵是否能提取到人脸特征码
返回为 true 则能检测到人脸并能提取特征码 |
FseResult[] |
matSearchFaces(net.gdface.image.MatType matType,
byte[] matData,
int width,
int height,
CodeInfo facePos,
double similarty,
int rows)
1:N 人脸图像搜索
对 facePos 指定的人脸位置提取特征码,然后在数据库中搜索相似的人脸返回搜索结果。返回包含相似度计算结果的FseResult数组 相似度值通过 FseResult.getSimilartys() 获取 对应的人脸特征ID由 FseResult.getFeatureIds()获取 |
java.lang.Boolean |
matWearMask(net.gdface.image.MatType matType,
byte[] matData,
int width,
int height,
CodeInfo faceInfo)
检测指定的人脸是否戴口罩
返回值有三种状态: true 戴口罩返回
false 未戴口罩返回
null 不知道
|
java.util.Map<java.lang.String,java.lang.String> |
sdkCapacity()
返回当前SDK特性(能力)描述,已定义字段:
SDK_VERSION [string]SDK版本号 MULTI_FACE_FEATURE [boolean]算法是否支持多人脸合成特征 FACE_LIVE [boolean]是否支持活体检测 WEAR_MASK [boolean]是否支持口罩检测 FDDATA_SIZE [int]人脸检测数据的(byte)长度 FEATURE_SIZE [int]人脸特征数据(byte)长度 MAX_FACE_COUNT [int]最大检测人脸数目 FSE_ENABLE [boolean]是否支持特征内存搜索引擎 CODEINFO_RELOCATE [boolean]是否支持CodeInfo对象重定位 LOCAL_DETECT [boolean] 人脸检测是否为本地实现,未定义则为false 以上字段名常量定义参见 CapacityFieldConstant |
FseResult[] |
searchFaces(byte[] imgData,
CodeInfo facePos,
double similarty,
int rows)
1:N 人脸图像搜索
对 facePos 指定的人脸位置提取特征码,然后在数据库中搜索相似的人脸返回搜索结果。返回包含相似度计算结果的FseResult数组 相似度值通过 FseResult.getSimilartys() 获取 对应的人脸特征ID由 FseResult.getFeatureIds()获取 |
FseResult[] |
searchFeatures(byte[] feature,
double similarty,
int rows)
1:N 人脸特征搜索
搜索与 code 相似度大于similarty 的记录(最多返回前rows 个结果)返回包含相似度计算结果的 FseResult 数组,返回结果以相似度降序排列相似度值通过 FseResult#getSimilartys() 获取对应的人脸特征ID由 FseResult#getFeatureIds() 获取 |
java.lang.Boolean |
wearMask(byte[] imgData,
CodeInfo faceInfo)
检测指定的人脸是否戴口罩
返回值有三种状态: true 戴口罩返回
false 未戴口罩返回
null 不知道
|
double compare2Face(byte[] imgData1, CodeInfo facePos1, byte[] imgData2, CodeInfo facePos2) throws NotFaceDetectedException, net.gdface.image.ImageErrorException
null
时,即比较同一张图像中的两张人脸的相似度
调用该方法时假设图像(imgData1
和imgData2
)能正常解码,ImageErrorException
异常对象封装到RuntimeException
抛出null
则抛出IllegalArgumentException
imgData1
- 图像1数据(jpg,png...)字节数组facePos1
- 检测到的人脸/眼睛位置imgData2
- 图像1数据(jpg,png...)字节数组facePos2
- 检测到的人脸/眼睛位置NotFaceDetectedException
net.gdface.image.ImageErrorException
getCodeInfo(byte[], int, CodeInfo[])
,
compareCode(byte[], byte[])
double detectAndCompare2Face(byte[] imgData1, FRect detectRect1, byte[] imgData2, FRect detectRect2) throws net.gdface.image.ImageErrorException, NotFaceDetectedException
FRect
)进行人脸检测,找到并提取唯一的人脸特征码,然后比较相似度,返回相似度结果null
时,
即比较同一张图像中的两张人脸的相似度,这种情况下detectRect1和detectRect2都不能为null
null
时,detectRect1和detectRect2被忽略imgData1
- 图像1数据(jpg,png...)字节数组,为null
则抛出IllegalArgumentException
detectRect1
- 图片检测范围,为null时全图检测imgData2
- 图像2数据(jpg,png...)字节数组detectRect2
- 图片检测范围,为null时全图检测net.gdface.image.ImageErrorException
NotFaceDetectedException
detectAndGetCodeInfo(byte[], int)
,
compareCode(byte[], byte[])
double compareCode(byte[] code1, byte[] code2)
null
或长度不一致则抛出IllegalArgumentException
异常,返回两个特征码之间的相似度(0.0~1)code1
- 待比对的特征码code2
- 待比对的特征码double[] compareCodes(byte[] code1, CodeInfo[] codes)
code1
- 待比对的特征码codes
- 包含人脸特征的CodeInfo
数组CompareResult compareFaces(byte[] code, byte[] imgData, int faceNum) throws NotFaceDetectedException, net.gdface.image.ImageErrorException
code
- 人脸特征数据imgData
- 待比对的图像(jpg,png...)(可能有多张人脸)faceNum
- 参见 getCodeInfo(byte[], int, CodeInfo[])
CompareResult
实例NotFaceDetectedException
- 没有检测到人脸net.gdface.image.ImageErrorException
compareCodes(byte[], CodeInfo[])
,
detectAndGetCodeInfo(byte[], int)
java.util.List<java.lang.Double> compareFeatures(byte[] code1, java.util.List<byte[]> codes)
code1
- 人脸特征数据codes
- 一组人脸特征CodeInfo[] detectAndGetCodeInfo(byte[] imgData, int faceNum) throws net.gdface.image.ImageErrorException, NotFaceDetectedException
imgData
进行人脸检测,然后提取人脸特征码CodeInfo
数组,
与getCodeInfo(byte[], int, CodeInfo[])
的返回结果有差别,返回结果中不包含检测到人脸但提取特征码失败的对象imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出IllegalArgumentException
faceNum
- 参见 getCodeInfo(byte[], int, CodeInfo[])
CodeInfo
数组net.gdface.image.ImageErrorException
NotFaceDetectedException
- 没有检测人脸或提取到特征码的人脸数目不是要求的人脸数目(faceNum>0)java.lang.Boolean wearMask(byte[] imgData, CodeInfo faceInfo) throws net.gdface.image.ImageErrorException
true
戴口罩返回false
未戴口罩返回null
不知道imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出 IllegalArgumentException
faceInfo
- 可见光图像人脸信息net.gdface.image.ImageErrorException
CodeInfo[] detectFace(byte[] imgData) throws net.gdface.image.ImageErrorException
imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出IllegalArgumentException
CodeInfo
数组net.gdface.image.ImageErrorException
- 图像读取错误CodeInfo detectCenterFace(byte[] imgData) throws NotFaceDetectedException, net.gdface.image.ImageErrorException
CodeInfo
imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出IllegalArgumentException
CodeInfo
NotFaceDetected
- 没有检测到人脸ImageError
- 图像读取错误NotFaceDetectedException
net.gdface.image.ImageErrorException
CodeInfo detectMaxFace(byte[] imgData) throws NotFaceDetectedException, net.gdface.image.ImageErrorException
CodeInfo
imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出IllegalArgumentException
CodeInfo
NotFaceDetected
- 没有检测到人脸ImageError
- 图像读取错误NotFaceDetectedException
net.gdface.image.ImageErrorException
CodeInfo[] getCodeInfo(byte[] imgData, int faceNum, CodeInfo[] facePos) throws NotFaceDetectedException
facePos
提供的人脸信息位置, 在imgData
图像中提取特征码detectAndGetCodeInfo(byte[], int)
不同, 本方法不对图像数据imgData
进行人脸检测,facePos
是 detectFace(byte[])
或 #detectFaceAgain(byte[], FRect[])
的返回结果CodeInfo.getCode()
返回null
imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出 IllegalArgumentException
faceNum
- 要求返回的人脸特征码数目faceNum
,则抛出NotFaceDetectedException
facePos
- 检测到的人脸位置对象列表null
或数组长度为0时抛出IllegalArgumentException
null
,则跳过NotFaceDetectedException
- 提取特征码的人脸数目为0或没有提取到指定数目(faceNum大于0时)的特征码CodeInfo getCodeInfo(byte[] imgData, CodeInfo facePos)
imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出 IllegalArgumentException
facePos
- 人脸位置信息对象,为null
则抛出异常CodeInfo
or null
byte[] getFeature(java.util.Map<java.nio.ByteBuffer,CodeInfo> faces) throws NotFaceDetectedException
#multiFaceFeature()
返回false
时代表此方法未被实现,执行会抛出异常faces
- 人脸图像数据(jpg,png...)与人脸位置信息对象的映射NotFaceDetectedException
boolean hasFace(byte[] imgData) throws net.gdface.image.ImageErrorException
true
则能检测到人脸并能提取特征码imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出IllegalArgumentException
true
则能检测到人脸并能提取特征码net.gdface.image.ImageErrorException
detectAndGetCodeInfo(byte[], int)
FseResult[] searchFeatures(byte[] feature, double similarty, int rows)
code
相似度大于similarty
的记录(最多返回前rows
个结果)FseResult
数组,返回结果以相似度降序排列FseResult#getSimilartys()
获取FseResult#getFeatureIds()
获取feature
- 要搜索的特征码similarty
- 相似度阀值rows
- 最多返回的记录数目FseResult
数组java.lang.UnsupportedOperationException
- 没有人脸识别算法(FaceApi实例)支持FseResult[] searchFaces(byte[] imgData, CodeInfo facePos, double similarty, int rows) throws NotFaceDetectedException, net.gdface.image.ImageErrorException
facePos
指定的人脸位置提取特征码,然后在数据库中搜索相似的人脸返回搜索结果。imgData
- 图片字节数组facePos
- 人脸位置对象null
时,先做人脸检测再提取特征码null
时,直接在指定的位置提取特征码similarty
- 相似度阀值rows
- 最多返回的记录数目FseResult
数组NotFaceDetectedException
- -net.gdface.image.ImageErrorException
- -java.lang.UnsupportedOperationException
- 没有人脸识别算法(FaceApi实例)支持getCodeInfo(byte[], int, CodeInfo[])
,
searchFeatures(byte[], double, int)
CodeInfo[] matDetectFace(net.gdface.image.MatType matType, byte[] matData, int width, int height)
matType
- 图像矩阵类型matData
- 图像矩阵width
- 图像宽度height
- 图像高度CodeInfo matDetectMaxFace(net.gdface.image.MatType matType, byte[] matData, int width, int height) throws NotFaceDetectedException
CodeInfo
imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出IllegalArgumentException
CodeInfo
NotFaceDetected
- 没有检测到人脸NotFaceDetectedException
CodeInfo matGetCodeInfo(net.gdface.image.MatType matType, byte[] matData, int width, int height, CodeInfo facePos)
matType
- 图像矩阵类型matData
- 图像矩阵width
- 图像宽度height
- 图像高度facePos
- 人脸位置信息对象,为null
则抛出异常CodeInfo
or null
CodeInfo[] matGetCodeInfo(net.gdface.image.MatType matType, byte[] matData, int width, int height, int facenum, CodeInfo[] facePos) throws NotFaceDetectedException
matType
- 图像矩阵类型matData
- 图像矩阵width
- 图像宽度height
- 图像高度facenum
- 要求返回的人脸特征码数目faceNum
,则抛出NotFaceDetectedException
facePos
- 人脸位置信息对象,不可为null
NotFaceDetectedException
- 提取特征码的人脸数目为0或没有提取到指定数目(faceNum大于0时)的特征码CodeInfo[] matDetectAndGetCodeInfo(net.gdface.image.MatType matType, byte[] matData, int width, int height, int faceNum) throws NotFaceDetectedException
imgData
进行人脸检测,然后提取人脸特征码CodeInfo
数组matType
- 图像矩阵类型matData
- 图像矩阵width
- 图像宽度height
- 图像高度faceNum
- 参见 getCodeInfo(byte[], int, CodeInfo[])
CodeInfo
数组NotFaceDetectedException
java.lang.Boolean matWearMask(net.gdface.image.MatType matType, byte[] matData, int width, int height, CodeInfo faceInfo)
true
戴口罩返回false
未戴口罩返回null
不知道matType
- 图像矩阵类型matData
- 图像矩阵width
- 图像宽度height
- 图像高度faceInfo
- 人脸位置信息boolean matHasFace(net.gdface.image.MatType matType, byte[] matData, int width, int height)
true
则能检测到人脸并能提取特征码matType
- 图像矩阵类型matData
- 图像矩阵,为null
则抛出IllegalArgumentException
width
- 图像宽度height
- 图像高度true
则能检测到人脸并能提取特征码FseResult[] matSearchFaces(net.gdface.image.MatType matType, byte[] matData, int width, int height, CodeInfo facePos, double similarty, int rows) throws NotFaceDetectedException, net.gdface.image.ImageErrorException
facePos
指定的人脸位置提取特征码,然后在数据库中搜索相似的人脸返回搜索结果。matType
- 图像矩阵类型matData
- 图像矩阵width
- 图像宽度facePos
- 人脸位置对象null
时,先做人脸检测再提取特征码null
时,直接在指定的位置提取特征码similarty
- 相似度阀值rows
- 最多返回的记录数目FseResult
数组NotFaceDetectedException
- -net.gdface.image.ImageErrorException
- -java.lang.UnsupportedOperationException
- 没有人脸识别算法(FaceApi实例)支持getCodeInfo(byte[], int, CodeInfo[])
,
searchFeatures(byte[], double, int)
java.util.Map<java.lang.String,java.lang.String> sdkCapacity()
CapacityFieldConstant
boolean isLocal()
Copyright © 2020. All rights reserved.