public abstract class BaseFaceApiLocal extends BaseFaceApi implements CapacityFieldConstant
Modifier and Type | Field and Description |
---|---|
protected static IAuxTool |
auxTool |
protected java.util.Map<java.lang.String,java.lang.String> |
capacity |
protected static net.gdface.utils.ShareLock |
concurrentLock
并发锁,限制建模的并发线程数,默认为CPU核数
|
C_CODEINFO_RELOCATE, C_FDDATA_SIZE, C_FDMAX_FACE_COUNT, C_FEATURE_SIZE, C_FSE_ENABLE, C_LOCAL_DETECT, C_MULTI_FACE_FEATURE, C_SDK_VERSION, C_WEAR_MASK
Modifier | Constructor and Description |
---|---|
protected |
BaseFaceApiLocal() |
Modifier and Type | Method and Description |
---|---|
double |
compareCode(byte[] code1,
byte[] code2)
特征码比对
参数为 null 或长度不一致则抛出IllegalArgumentException 异常,返回两个特征码之间的相似度(0.0~1) |
CodeInfo[] |
detectAndGetCodeInfo(net.gdface.image.BaseLazyImage lazyImg,
int faceNum)
先对图像数据
imgData 进行人脸检测,然后提取人脸特征码 |
CodeInfo[] |
detectAndGetCodeInfo(byte[] imgData,
int faceNum)
先对图像数据
imgData 进行人脸检测,然后提取人脸特征码返回所有成功提取特征码的 CodeInfo 数组,
与FaceApi.getCodeInfo(byte[], int, CodeInfo[]) 的返回结果有差别,返回结果中不包含检测到人脸但提取特征码失败的对象 |
java.util.List<CodeInfo> |
detectFace(net.gdface.image.BaseLazyImage lazyImg)
|
CodeInfo[] |
detectFace(byte[] imgData)
|
protected static byte[] |
fromNv21(net.gdface.image.MatType matType,
byte[] nv21,
int width,
int height) |
CodeInfo |
getCodeInfo(net.gdface.image.BaseLazyImage lazyImg,
CodeInfo facePos)
提取单个人脸特征
|
java.util.List<CodeInfo> |
getCodeInfo(net.gdface.image.BaseLazyImage lazyImg,
int faceNum,
java.util.List<CodeInfo> facePos)
对图像(
lazyImg )中指定的人脸位置facePos 并提取特征码,返回生成人脸特征码数据数组对象(人脸可能不止一个)调用该方法时假设图像( lazyImage )能正常解码,所以当对图像解码出现异常时,将异常对象封装到RuntimeException 抛出 |
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 |
FeatureSe |
getFeatureSe()
返回当前
FaceApi 接口实例对应的搜索引擎接口实例,如果没有则返回null |
protected net.gdface.image.MatType |
getNativeMatrixType()
返回用于图像检测和建模的图像矩阵的(色彩空间)类型
不可返回 null |
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 |
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 |
java.lang.Boolean |
matWearMask(net.gdface.image.MatType matType,
byte[] matData,
int width,
int height,
CodeInfo faceInfo)
检测指定的人脸是否戴口罩
返回值有三种状态: true 戴口罩返回
false 未戴口罩返回
null 不知道
|
protected abstract double |
nativeCompareCode(byte[] code1,
byte[] code2)
|
CodeInfo[] |
nativeDetectAndGetFeatures(byte[] imgMatrix,
int width,
int height)
检测并提取特征
|
abstract void |
nativeDetectFace(byte[] imgMatrix,
int width,
int height,
java.util.List<CodeInfo> faceInfo)
检测人脸
|
abstract byte[] |
nativeGetFaceFeature(byte[] imgMatrix,
int width,
int height,
CodeInfo faceInfo)
对faceinfo指定的人脸位置提取特征
|
java.util.List<CodeInfo> |
nativeGetFaceFeatures(byte[] imgMatrix,
int width,
int height,
int faceNum,
java.util.List<CodeInfo> facePos)
对图像矩阵中指定的人脸位置
facePos 并提取特征码,返回生成人脸特征码数据数组对象(人脸可能不止一个) |
byte[][] |
nativeGetFaceFeatures(byte[] imgMatrix,
int width,
int height,
java.util.List<CodeInfo> facePos)
根据检测到的人脸位置
facePos ,提取一组特征 |
CodeInfo[] |
nativeNv21DetectAndGetFeatures(byte[] nv21,
int width,
int height)
检测并提取特征
|
void |
nativeNv21DetectFace(byte[] nv21,
int width,
int height,
java.util.List<CodeInfo> faceInfo)
对从视频流中直接获取的NV21图像进行人脸检测
|
byte[] |
nativeNv21GetFaceFeature(byte[] nv21,
int width,
int height,
CodeInfo facePos)
根据facePos提供的人脸信息位置, 在NV21格式图像中提取特征码
|
byte[][] |
nativeNv21GetFaceFeatures(byte[] nv21,
int width,
int height,
java.util.List<CodeInfo> facePos)
根据facePos提供的人脸信息位置, 在NV21格式图像中提取特征码
|
java.lang.Boolean |
nativeNv21WearMask(byte[] nv21,
int width,
int height,
CodeInfo faceInfo)
戴口罩检测检测方法
|
java.lang.Boolean |
nativeWearMask(byte[] imgMatrix,
int width,
int height,
CodeInfo faceInfo)
戴口罩检测检测方法
|
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[] |
searchFeatures(byte[] feature,
double similarty,
int rows)
1:N 人脸特征搜索
搜索与 code 相似度大于similarty 的记录(最多返回前rows 个结果)返回包含相似度计算结果的 FseResult 数组,返回结果以相似度降序排列相似度值通过 FseResult#getSimilartys() 获取对应的人脸特征ID由 FseResult#getFeatureIds() 获取 |
static void |
setAuxTool(IAuxTool auxTool) |
protected byte[] |
toNativeMatrix(net.gdface.image.MatType matType,
byte[] matData,
int width,
int height)
将指定的图像矩阵转为图像检测和建模的图像矩阵的(色彩空间)类型(参见
BaseFaceApi.getNativeMatrixType() ) |
protected static byte[] |
toNv21(net.gdface.image.MatType matType,
byte[] matData,
int width,
int height) |
java.lang.Boolean |
wearMask(byte[] imgData,
CodeInfo faceInfo)
检测指定的人脸是否戴口罩
返回值有三种状态: true 戴口罩返回
false 未戴口罩返回
null 不知道
|
compare2Face, compareCodes, compareFaces, compareFeatures, detectAndCompare2Face, detectCenterFace, detectMaxFace, findMaxFace, getFeature, getFeatureSeInstance, hasFace, makeOpenedLazyImage, matDetectMaxFace, matHasFace, matSearchFaces, searchFaces
protected final java.util.Map<java.lang.String,java.lang.String> capacity
protected static net.gdface.utils.ShareLock concurrentLock
protected BaseFaceApiLocal()
public static void setAuxTool(IAuxTool auxTool)
public CodeInfo[] detectAndGetCodeInfo(byte[] imgData, int faceNum) throws net.gdface.image.ImageErrorException, NotFaceDetectedException
FaceApi
imgData
进行人脸检测,然后提取人脸特征码CodeInfo
数组,
与FaceApi.getCodeInfo(byte[], int, CodeInfo[])
的返回结果有差别,返回结果中不包含检测到人脸但提取特征码失败的对象detectAndGetCodeInfo
in interface FaceApi
imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出IllegalArgumentException
faceNum
- 参见 FaceApi.getCodeInfo(byte[], int, CodeInfo[])
CodeInfo
数组net.gdface.image.ImageErrorException
NotFaceDetectedException
- 没有检测人脸或提取到特征码的人脸数目不是要求的人脸数目(faceNum>0)public java.util.List<CodeInfo> getCodeInfo(net.gdface.image.BaseLazyImage lazyImg, int faceNum, java.util.List<CodeInfo> facePos) throws NotFaceDetectedException
lazyImg
)中指定的人脸位置facePos
并提取特征码,返回生成人脸特征码数据数组对象(人脸可能不止一个)lazyImage
)能正常解码,所以当对图像解码出现异常时,将异常对象封装到RuntimeException
抛出lazyImg
- 图像对象,为null
则抛出 IllegalArgumentException
faceNum
- facePos
- CodeInfo
对象列表facePos
中的每个FRect
对象,返回一个CodeInfo
对象(数组下标相同):FRect
对象为null
,则返回一个所有成员都为null
的CodeInfo
对象FRect
指定的范围没有提取到特征码,则CodeInfo.getCode()
,CodeInfo.getEi()
返回null
NotFaceDetectedException
#getCodeFromImageMatrix(byte[], int, int, CodeInfo, AtomicBoolean)
,
FaceApi.getCodeInfo(byte[], int, CodeInfo[])
public CodeInfo getCodeInfo(net.gdface.image.BaseLazyImage lazyImg, CodeInfo facePos)
lazyImg
- facePos
- public CodeInfo getCodeInfo(byte[] imgData, CodeInfo facePos)
FaceApi
getCodeInfo
in interface FaceApi
imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出 IllegalArgumentException
facePos
- 人脸位置信息对象,为null
则抛出异常CodeInfo
or null
public java.lang.Boolean wearMask(byte[] imgData, CodeInfo faceInfo) throws net.gdface.image.ImageErrorException
FaceApi
true
戴口罩返回false
未戴口罩返回null
不知道public CodeInfo[] detectAndGetCodeInfo(net.gdface.image.BaseLazyImage lazyImg, int faceNum) throws net.gdface.image.ImageErrorException, NotFaceDetectedException
imgData
进行人脸检测,然后提取人脸特征码lazyImg
- faceNum
- net.gdface.image.ImageErrorException
NotFaceDetectedException
detectAndGetCodeInfo(byte[], int)
public CodeInfo[] detectFace(byte[] imgData) throws net.gdface.image.ImageErrorException
FaceApi
detectFace
in interface FaceApi
imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出IllegalArgumentException
CodeInfo
数组net.gdface.image.ImageErrorException
- 图像读取错误public CodeInfo[] getCodeInfo(byte[] imgData, int faceNum, CodeInfo[] facePos) throws NotFaceDetectedException
FaceApi
facePos
提供的人脸信息位置, 在imgData
图像中提取特征码FaceApi.detectAndGetCodeInfo(byte[], int)
不同, 本方法不对图像数据imgData
进行人脸检测,facePos
是 FaceApi.detectFace(byte[])
或 #detectFaceAgain(byte[], FRect[])
的返回结果CodeInfo.getCode()
返回null
getCodeInfo
in interface FaceApi
imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出 IllegalArgumentException
faceNum
- 要求返回的人脸特征码数目faceNum
,则抛出NotFaceDetectedException
facePos
- 检测到的人脸位置对象列表null
或数组长度为0时抛出IllegalArgumentException
null
,则跳过NotFaceDetectedException
- 提取特征码的人脸数目为0或没有提取到指定数目(faceNum大于0时)的特征码public final double compareCode(byte[] code1, byte[] code2)
FaceApi
null
或长度不一致则抛出IllegalArgumentException
异常,返回两个特征码之间的相似度(0.0~1)compareCode
in interface FaceApi
code1
- 待比对的特征码code2
- 待比对的特征码public CodeInfo[] matDetectFace(net.gdface.image.MatType matType, byte[] matData, int width, int height)
FaceApi
matDetectFace
in interface FaceApi
matType
- 图像矩阵类型matData
- 图像矩阵width
- 图像宽度height
- 图像高度public CodeInfo[] matGetCodeInfo(net.gdface.image.MatType matType, byte[] matData, int width, int height, int facenum, CodeInfo[] facePos) throws NotFaceDetectedException
FaceApi
matGetCodeInfo
in interface FaceApi
matType
- 图像矩阵类型matData
- 图像矩阵width
- 图像宽度height
- 图像高度facenum
- 要求返回的人脸特征码数目faceNum
,则抛出NotFaceDetectedException
facePos
- 人脸位置信息对象,不可为null
NotFaceDetectedException
- 提取特征码的人脸数目为0或没有提取到指定数目(faceNum大于0时)的特征码public CodeInfo matGetCodeInfo(net.gdface.image.MatType matType, byte[] matData, int width, int height, CodeInfo facePos)
FaceApi
matGetCodeInfo
in interface FaceApi
matType
- 图像矩阵类型matData
- 图像矩阵width
- 图像宽度height
- 图像高度facePos
- 人脸位置信息对象,为null
则抛出异常CodeInfo
or null
public CodeInfo[] matDetectAndGetCodeInfo(net.gdface.image.MatType matType, byte[] matData, int width, int height, int faceNum) throws NotFaceDetectedException
FaceApi
imgData
进行人脸检测,然后提取人脸特征码CodeInfo
数组matDetectAndGetCodeInfo
in interface FaceApi
matType
- 图像矩阵类型matData
- 图像矩阵width
- 图像宽度height
- 图像高度faceNum
- 参见 FaceApi.getCodeInfo(byte[], int, CodeInfo[])
CodeInfo
数组NotFaceDetectedException
public java.lang.Boolean matWearMask(net.gdface.image.MatType matType, byte[] matData, int width, int height, CodeInfo faceInfo)
FaceApi
true
戴口罩返回false
未戴口罩返回null
不知道matWearMask
in interface FaceApi
matType
- 图像矩阵类型matData
- 图像矩阵width
- 图像宽度height
- 图像高度faceInfo
- 人脸位置信息public FeatureSe getFeatureSe()
FaceApi
接口实例对应的搜索引擎接口实例,如果没有则返回null
public boolean isLocal()
FaceApi
public java.util.Map<java.lang.String,java.lang.String> sdkCapacity()
FaceApi
CapacityFieldConstant
sdkCapacity
in interface FaceApi
public java.util.List<CodeInfo> detectFace(net.gdface.image.BaseLazyImage lazyImg) throws net.gdface.image.UnsupportedFormatException
lazyImg
- 图像对象,为null
时抛出IllegalArgumentException
net.gdface.image.UnsupportedFormatException
protected net.gdface.image.MatType getNativeMatrixType()
BaseFaceApi
null
getNativeMatrixType
in class BaseFaceApi
protected byte[] toNativeMatrix(net.gdface.image.MatType matType, byte[] matData, int width, int height)
BaseFaceApi
BaseFaceApi.getNativeMatrixType()
)toNativeMatrix
in class BaseFaceApi
matType
- 输入矩阵类型matData
- 矩阵数据width
- 矩阵宽度height
- 矩阵高度protected abstract double nativeCompareCode(byte[] code1, byte[] code2)
code1
- code2
- public abstract void nativeDetectFace(byte[] imgMatrix, int width, int height, java.util.List<CodeInfo> faceInfo)
imgMatrix
- 图像矩阵数据,数据格式要求与算法相关width
- 图像宽度height
- 图像高度faceInfo
- 保存检测到的人脸位置信息public abstract byte[] nativeGetFaceFeature(byte[] imgMatrix, int width, int height, CodeInfo faceInfo)
imgMatrix
- 图像矩阵数据,数据格式要求与算法相关width
- 图像宽度height
- 图像高度faceInfo
- public java.util.List<CodeInfo> nativeGetFaceFeatures(byte[] imgMatrix, int width, int height, int faceNum, java.util.List<CodeInfo> facePos) throws NotFaceDetectedException
facePos
并提取特征码,返回生成人脸特征码数据数组对象(人脸可能不止一个)imgMatrix
- 图像矩阵数据,数据格式要求与算法相关width
- 图像宽度height
- 图像高度faceNum
- facePos
- CodeInfo
对象列表facePos
中的每个FRect
对象,返回一个CodeInfo
对象(数组下标相同):FRect
对象为null
,则返回一个所有成员都为null
的CodeInfo
对象FRect
指定的范围没有提取到特征码,则CodeInfo.getCode()
,CodeInfo.getEi()
返回null
NotFaceDetectedException
#nativeGetFaceFeatures(byte[], int, int, List)}
public byte[][] nativeGetFaceFeatures(byte[] imgMatrix, int width, int height, java.util.List<CodeInfo> facePos)
facePos
,提取一组特征imgMatrix
- 图像矩阵数据,数据格式要求与算法相关width
- 图像宽度height
- 图像高度facePos
- public CodeInfo[] nativeDetectAndGetFeatures(byte[] imgMatrix, int width, int height)
imgMatrix
- 图像矩阵数据,数据格式要求与算法相关width
- 图像宽度height
- 图像高度CodeInfo
数组public void nativeNv21DetectFace(byte[] nv21, int width, int height, java.util.List<CodeInfo> faceInfo)
nv21
- NV21格式图像width
- 图像宽度height
- 图像高度faceInfo
- 人脸信息对象列表public byte[] nativeNv21GetFaceFeature(byte[] nv21, int width, int height, CodeInfo facePos)
nv21
- NV21格式图像width
- 图像宽度height
- 图像高度facePos
- 人脸位置信息对象,不可为null
CodeInfo
对象public byte[][] nativeNv21GetFaceFeatures(byte[] nv21, int width, int height, java.util.List<CodeInfo> facePos)
nv21
- NV21格式图像width
- 图像宽度height
- 图像高度facePos
- 人脸位置信息对象,不可为null
CodeInfo
对象public CodeInfo[] nativeNv21DetectAndGetFeatures(byte[] nv21, int width, int height)
nv21
- NV21格式图像矩阵数据width
- 图像宽度height
- 图像高度CodeInfo
数组public java.lang.Boolean nativeWearMask(byte[] imgMatrix, int width, int height, CodeInfo faceInfo)
imgMatrix
- 图像矩阵数据,数据格式要求与算法相关width
- 图像宽度height
- 图像高度faceInfo
- 可见光图像人脸信息true
,否则返回false
,null
不知道public java.lang.Boolean nativeNv21WearMask(byte[] nv21, int width, int height, CodeInfo faceInfo)
nv21
- NV21格式图像矩阵数据width
- 图像宽度height
- 图像高度faceInfo
- 可见光图像人脸信息true
,否则返回false
,null
不知道public FseResult[] searchFeatures(byte[] feature, double similarty, int rows)
FaceApi
code
相似度大于similarty
的记录(最多返回前rows
个结果)FseResult
数组,返回结果以相似度降序排列FseResult#getSimilartys()
获取FseResult#getFeatureIds()
获取searchFeatures
in interface FaceApi
feature
- 要搜索的特征码similarty
- 相似度阀值rows
- 最多返回的记录数目FseResult
数组protected static byte[] fromNv21(net.gdface.image.MatType matType, byte[] nv21, int width, int height)
protected static byte[] toNv21(net.gdface.image.MatType matType, byte[] matData, int width, int height)
Copyright © 2020. All rights reserved.