public class FaceApiThriftClient extends java.lang.Object implements FaceApi
FaceApi接口的RPC实现(线程安全)FaceApi接口方法到delegate()指定的实例RuntimeException异常被封装到ServiceRuntimeException中抛出
FaceApiThriftClient thriftInstance = ClientFactory
.builder()
.setHostAndPort("127.0.0.1",26413)
.build(FaceApi.class, FaceApiThriftClient.class);
计算机生成代码(generated by automated tools ThriftServiceDecoratorGenerator @author guyadong)| Constructor and Description |
|---|
FaceApiThriftClient(net.gdface.thrift.ClientFactory factory) |
FaceApiThriftClient(com.google.common.net.HostAndPort hostAndPort) |
FaceApiThriftClient(java.lang.String host,
int port) |
| 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
|
protected FaceApi |
delegate() |
double |
detectAndCompare2Face(byte[] imgData1,
FRect detectRect1,
byte[] imgData2,
FRect detectRect2)
对两个图像指定范围(
FRect)进行人脸检测,找到并提取唯一的人脸特征码,然后比较相似度,返回相似度结果imgData1和imgData2相等或imgData2为 null时,
即比较同一张图像中的两张人脸的相似度,这种情况下detectRect1和detectRect2都不能为nullimgData1和imgData2不相等且都不为 null时,detectRect1和detectRect2被忽略 |
CodeInfo[] |
detectAndGetCodeInfo(byte[] imgData,
int faceNum)
先对图像数据
imgData进行人脸检测,然后提取人脸特征码返回所有成功提取特征码的 CodeInfo数组,
与FaceApi.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图像中提取特征码与 FaceApi.detectAndGetCodeInfo(byte[], int)不同, 本方法不对图像数据imgData进行人脸检测,假设 facePos是 FaceApi.detectFace(byte[])或 #detectFaceAgain(byte[], FRect[]) 的返回结果返回facePos,如果没有提取到特征码,则对应元素 CodeInfo.getCode()返回null |
net.gdface.thrift.ClientFactory |
getFactory() |
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()获取 |
boolean |
testConnect()
test if connectable for RPC service
|
java.lang.String |
toString() |
java.lang.Boolean |
wearMask(byte[] imgData,
CodeInfo faceInfo)
检测指定的人脸是否戴口罩
返回值有三种状态: true 戴口罩返回
false 未戴口罩返回
null 不知道
|
public FaceApiThriftClient(net.gdface.thrift.ClientFactory factory)
public FaceApiThriftClient(java.lang.String host, int port)
host - RPC service hostport - RPC service portpublic FaceApiThriftClient(com.google.common.net.HostAndPort hostAndPort)
hostAndPort - RPC service host and portpublic net.gdface.thrift.ClientFactory getFactory()
public boolean testConnect()
true if connectable ,otherwise falsepublic java.lang.String toString()
toString in class java.lang.Objectpublic double compare2Face(byte[] imgData1, CodeInfo facePos1, byte[] imgData2, CodeInfo facePos2) throws net.gdface.image.ImageErrorException, NotFaceDetectedException
FaceApinull时,即比较同一张图像中的两张人脸的相似度
调用该方法时假设图像(imgData1和imgData2)能正常解码,ImageErrorException异常对象封装到RuntimeException抛出null则抛出IllegalArgumentExceptioncompare2Face in interface FaceApiimgData1 - 图像1数据(jpg,png...)字节数组facePos1 - 检测到的人脸/眼睛位置imgData2 - 图像1数据(jpg,png...)字节数组facePos2 - 检测到的人脸/眼睛位置net.gdface.image.ImageErrorExceptionNotFaceDetectedExceptionFaceApi.getCodeInfo(byte[], int, CodeInfo[]),
FaceApi.compareCode(byte[], byte[])public double compareCode(byte[] code1, byte[] code2)
FaceApinull或长度不一致则抛出IllegalArgumentException异常,返回两个特征码之间的相似度(0.0~1)compareCode in interface FaceApicode1 - 待比对的特征码code2 - 待比对的特征码public double[] compareCodes(byte[] code1, CodeInfo[] codes)
FaceApicompareCodes in interface FaceApicode1 - 待比对的特征码codes - 包含人脸特征的CodeInfo数组public CompareResult compareFaces(byte[] code, byte[] imgData, int faceNum) throws net.gdface.image.ImageErrorException, NotFaceDetectedException
FaceApicompareFaces in interface FaceApicode - 人脸特征数据imgData - 待比对的图像(jpg,png...)(可能有多张人脸)faceNum - 参见 FaceApi.getCodeInfo(byte[], int, CodeInfo[])CompareResult实例net.gdface.image.ImageErrorExceptionNotFaceDetectedException - 没有检测到人脸FaceApi.compareCodes(byte[], CodeInfo[]),
FaceApi.detectAndGetCodeInfo(byte[], int)public java.util.List<java.lang.Double> compareFeatures(byte[] code1, java.util.List<byte[]> codes)
FaceApicompareFeatures in interface FaceApicode1 - 人脸特征数据codes - 一组人脸特征public double detectAndCompare2Face(byte[] imgData1, FRect detectRect1, byte[] imgData2, FRect detectRect2) throws net.gdface.image.ImageErrorException, NotFaceDetectedException
FaceApiFRect)进行人脸检测,找到并提取唯一的人脸特征码,然后比较相似度,返回相似度结果null时,
即比较同一张图像中的两张人脸的相似度,这种情况下detectRect1和detectRect2都不能为nullnull时,detectRect1和detectRect2被忽略detectAndCompare2Face in interface FaceApiimgData1 - 图像1数据(jpg,png...)字节数组,为null则抛出IllegalArgumentExceptiondetectRect1 - 图片检测范围,为null时全图检测imgData2 - 图像2数据(jpg,png...)字节数组detectRect2 - 图片检测范围,为null时全图检测net.gdface.image.ImageErrorExceptionNotFaceDetectedExceptionFaceApi.detectAndGetCodeInfo(byte[], int),
FaceApi.compareCode(byte[], byte[])public CodeInfo[] detectAndGetCodeInfo(byte[] imgData, int faceNum) throws net.gdface.image.ImageErrorException, NotFaceDetectedException
FaceApiimgData进行人脸检测,然后提取人脸特征码CodeInfo数组,
与FaceApi.getCodeInfo(byte[], int, CodeInfo[])的返回结果有差别,返回结果中不包含检测到人脸但提取特征码失败的对象detectAndGetCodeInfo in interface FaceApiimgData - 图像数据(jpg,png...)字节数组,为null则抛出IllegalArgumentExceptionfaceNum - 参见 FaceApi.getCodeInfo(byte[], int, CodeInfo[])CodeInfo数组net.gdface.image.ImageErrorExceptionNotFaceDetectedException - 没有检测人脸或提取到特征码的人脸数目不是要求的人脸数目(faceNum>0)public CodeInfo detectCenterFace(byte[] imgData) throws net.gdface.image.ImageErrorException, NotFaceDetectedException
FaceApiCodeInfodetectCenterFace in interface FaceApiimgData - 图像数据(jpg,png...)字节数组,为null则抛出IllegalArgumentExceptionCodeInfonet.gdface.image.ImageErrorExceptionNotFaceDetectedExceptionpublic CodeInfo[] detectFace(byte[] imgData) throws net.gdface.image.ImageErrorException
FaceApidetectFace in interface FaceApiimgData - 图像数据(jpg,png...)字节数组,为null则抛出IllegalArgumentExceptionCodeInfo数组net.gdface.image.ImageErrorException - 图像读取错误public CodeInfo detectMaxFace(byte[] imgData) throws net.gdface.image.ImageErrorException, NotFaceDetectedException
FaceApiCodeInfodetectMaxFace in interface FaceApiimgData - 图像数据(jpg,png...)字节数组,为null则抛出IllegalArgumentExceptionCodeInfonet.gdface.image.ImageErrorExceptionNotFaceDetectedExceptionpublic CodeInfo[] getCodeInfo(byte[] imgData, int faceNum, CodeInfo[] facePos) throws NotFaceDetectedException
FaceApifacePos提供的人脸信息位置, 在imgData图像中提取特征码FaceApi.detectAndGetCodeInfo(byte[], int)不同, 本方法不对图像数据imgData进行人脸检测,facePos是 FaceApi.detectFace(byte[])或 #detectFaceAgain(byte[], FRect[]) 的返回结果CodeInfo.getCode()返回nullgetCodeInfo in interface FaceApiimgData - 图像数据(jpg,png...)字节数组,为null则抛出 IllegalArgumentExceptionfaceNum - 要求返回的人脸特征码数目faceNum,则抛出NotFaceDetectedExceptionfacePos - 检测到的人脸位置对象列表null或数组长度为0时抛出IllegalArgumentExceptionnull,则跳过NotFaceDetectedException - 提取特征码的人脸数目为0或没有提取到指定数目(faceNum大于0时)的特征码public CodeInfo getCodeInfo(byte[] imgData, CodeInfo facePos)
FaceApigetCodeInfo in interface FaceApiimgData - 图像数据(jpg,png...)字节数组,为null则抛出 IllegalArgumentExceptionfacePos - 人脸位置信息对象,为null则抛出异常CodeInfo or nullpublic byte[] getFeature(java.util.Map<java.nio.ByteBuffer,CodeInfo> faces) throws NotFaceDetectedException
FaceApi#multiFaceFeature()返回false时代表此方法未被实现,执行会抛出异常getFeature in interface FaceApifaces - 人脸图像数据(jpg,png...)与人脸位置信息对象的映射NotFaceDetectedExceptionpublic boolean hasFace(byte[] imgData) throws net.gdface.image.ImageErrorException
FaceApitrue则能检测到人脸并能提取特征码hasFace in interface FaceApiimgData - 图像数据(jpg,png...)字节数组,为null则抛出IllegalArgumentExceptiontrue则能检测到人脸并能提取特征码net.gdface.image.ImageErrorExceptionFaceApi.detectAndGetCodeInfo(byte[], int)public boolean isLocal()
FaceApipublic CodeInfo[] matDetectAndGetCodeInfo(net.gdface.image.MatType matType, byte[] matData, int width, int height, int faceNum) throws NotFaceDetectedException
FaceApiimgData进行人脸检测,然后提取人脸特征码CodeInfo数组matDetectAndGetCodeInfo in interface FaceApimatType - 图像矩阵类型matData - 图像矩阵width - 图像宽度height - 图像高度faceNum - 参见 FaceApi.getCodeInfo(byte[], int, CodeInfo[])CodeInfo数组NotFaceDetectedExceptionpublic CodeInfo[] matDetectFace(net.gdface.image.MatType matType, byte[] matData, int width, int height)
FaceApimatDetectFace in interface FaceApimatType - 图像矩阵类型matData - 图像矩阵width - 图像宽度height - 图像高度public CodeInfo matDetectMaxFace(net.gdface.image.MatType matType, byte[] matData, int width, int height) throws NotFaceDetectedException
FaceApiCodeInfomatDetectMaxFace in interface FaceApiCodeInfoNotFaceDetectedExceptionpublic CodeInfo[] matGetCodeInfo(net.gdface.image.MatType matType, byte[] matData, int width, int height, int facenum, CodeInfo[] facePos) throws NotFaceDetectedException
FaceApimatGetCodeInfo in interface FaceApimatType - 图像矩阵类型matData - 图像矩阵width - 图像宽度height - 图像高度facenum - 要求返回的人脸特征码数目faceNum,则抛出NotFaceDetectedExceptionfacePos - 人脸位置信息对象,不可为nullNotFaceDetectedException - 提取特征码的人脸数目为0或没有提取到指定数目(faceNum大于0时)的特征码public CodeInfo matGetCodeInfo(net.gdface.image.MatType matType, byte[] matData, int width, int height, CodeInfo facePos)
FaceApimatGetCodeInfo in interface FaceApimatType - 图像矩阵类型matData - 图像矩阵width - 图像宽度height - 图像高度facePos - 人脸位置信息对象,为null则抛出异常CodeInfo or nullpublic boolean matHasFace(net.gdface.image.MatType matType, byte[] matData, int width, int height)
FaceApitrue则能检测到人脸并能提取特征码matHasFace in interface FaceApimatType - 图像矩阵类型matData - 图像矩阵,为null则抛出IllegalArgumentExceptionwidth - 图像宽度height - 图像高度true则能检测到人脸并能提取特征码public FseResult[] matSearchFaces(net.gdface.image.MatType matType, byte[] matData, int width, int height, CodeInfo facePos, double similarty, int rows) throws net.gdface.image.ImageErrorException, NotFaceDetectedException
FaceApifacePos指定的人脸位置提取特征码,然后在数据库中搜索相似的人脸返回搜索结果。matSearchFaces in interface FaceApimatType - 图像矩阵类型matData - 图像矩阵width - 图像宽度facePos - 人脸位置对象null时,先做人脸检测再提取特征码null时,直接在指定的位置提取特征码similarty - 相似度阀值rows - 最多返回的记录数目FseResult数组net.gdface.image.ImageErrorException - -NotFaceDetectedException - -FaceApi.getCodeInfo(byte[], int, CodeInfo[]),
FaceApi.searchFeatures(byte[], double, int)public java.lang.Boolean matWearMask(net.gdface.image.MatType matType, byte[] matData, int width, int height, CodeInfo faceInfo)
FaceApitrue 戴口罩返回false 未戴口罩返回null 不知道matWearMask in interface FaceApimatType - 图像矩阵类型matData - 图像矩阵width - 图像宽度height - 图像高度faceInfo - 人脸位置信息public java.util.Map<java.lang.String,java.lang.String> sdkCapacity()
FaceApiCapacityFieldConstantsdkCapacity in interface FaceApipublic FseResult[] searchFaces(byte[] imgData, CodeInfo facePos, double similarty, int rows) throws net.gdface.image.ImageErrorException, NotFaceDetectedException
FaceApifacePos指定的人脸位置提取特征码,然后在数据库中搜索相似的人脸返回搜索结果。searchFaces in interface FaceApiimgData - 图片字节数组facePos - 人脸位置对象null时,先做人脸检测再提取特征码null时,直接在指定的位置提取特征码similarty - 相似度阀值rows - 最多返回的记录数目FseResult数组net.gdface.image.ImageErrorException - -NotFaceDetectedException - -FaceApi.getCodeInfo(byte[], int, CodeInfo[]),
FaceApi.searchFeatures(byte[], double, int)public FseResult[] searchFeatures(byte[] feature, double similarty, int rows)
FaceApicode相似度大于similarty的记录(最多返回前rows个结果)FseResult数组,返回结果以相似度降序排列FseResult#getSimilartys() 获取FseResult#getFeatureIds()获取searchFeatures in interface FaceApifeature - 要搜索的特征码similarty - 相似度阀值rows - 最多返回的记录数目FseResult数组Copyright © 2020. All rights reserved.