public abstract class BaseFaceApi extends java.lang.Object implements FaceApi
FaceApi
抽象实现,SDK接口类必须从此类派生Modifier | Constructor and Description |
---|---|
protected |
BaseFaceApi() |
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[] |
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 |
detectCenterFace(byte[] imgData)
检测最中心的人脸
返回人脸位置数据对象 CodeInfo |
CodeInfo |
detectMaxFace(byte[] imgData)
检测最大的人脸
返回人脸位置数据对象 CodeInfo |
protected CodeInfo |
findMaxFace(CodeInfo[] facePos) |
byte[] |
getFeature(java.util.Map<java.nio.ByteBuffer,CodeInfo> faces)
多张人脸提取特征(用于多张人脸合成一个特征的算法)
返回人脸特征数据 #multiFaceFeature() 返回false 时代表此方法未被实现,执行会抛出异常 |
static FeatureSe |
getFeatureSeInstance(FaceApi faceapi)
|
protected abstract net.gdface.image.MatType |
getNativeMatrixType()
返回用于图像检测和建模的图像矩阵的(色彩空间)类型
不可返回 null |
boolean |
hasFace(byte[] imgData)
判断图像是否能提取到人脸特征码
为 true 则能检测到人脸并能提取特征码 |
protected net.gdface.image.BaseLazyImage |
makeOpenedLazyImage(byte[] imgData)
通过图像数据字节流(byte[])创建FaceImage对象
调用 BaseLazyImage.setAutoClose(boolean) 设置 autClose为false 如果有特殊要求,子类可以重写此方法 |
CodeInfo |
matDetectMaxFace(net.gdface.image.MatType matType,
byte[] matData,
int width,
int height)
检测最大的人脸
返回人脸位置数据对象 CodeInfo |
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()获取 |
FseResult[] |
searchFaces(byte[] imgData,
CodeInfo facePos,
double similarty,
int rows)
1:N 人脸图像搜索
对 facePos 指定的人脸位置提取特征码,然后在数据库中搜索相似的人脸返回搜索结果。返回包含相似度计算结果的FseResult数组 相似度值通过 FseResult.getSimilartys() 获取 对应的人脸特征ID由 FseResult.getFeatureIds()获取 |
protected abstract byte[] |
toNativeMatrix(net.gdface.image.MatType matType,
byte[] matData,
int width,
int height)
将指定的图像矩阵转为图像检测和建模的图像矩阵的(色彩空间)类型(参见
getNativeMatrixType() ) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
compareCode, detectAndGetCodeInfo, detectFace, getCodeInfo, getCodeInfo, isLocal, matDetectAndGetCodeInfo, matDetectFace, matGetCodeInfo, matGetCodeInfo, matWearMask, sdkCapacity, searchFeatures, wearMask
protected BaseFaceApi()
public double compare2Face(byte[] imgData1, CodeInfo facePos1, byte[] imgData2, CodeInfo facePos2) throws NotFaceDetectedException
FaceApi
null
时,即比较同一张图像中的两张人脸的相似度
调用该方法时假设图像(imgData1
和imgData2
)能正常解码,ImageErrorException
异常对象封装到RuntimeException
抛出null
则抛出IllegalArgumentException
compare2Face
in interface FaceApi
imgData1
- 图像1数据(jpg,png...)字节数组facePos1
- 检测到的人脸/眼睛位置imgData2
- 图像1数据(jpg,png...)字节数组facePos2
- 检测到的人脸/眼睛位置NotFaceDetectedException
FaceApi.getCodeInfo(byte[], int, CodeInfo[])
,
FaceApi.compareCode(byte[], byte[])
public CompareResult compareFaces(byte[] code, byte[] imgData, int faceNum) throws NotFaceDetectedException, net.gdface.image.ImageErrorException
FaceApi
compareFaces
in interface FaceApi
code
- 人脸特征数据imgData
- 待比对的图像(jpg,png...)(可能有多张人脸)faceNum
- 参见 FaceApi.getCodeInfo(byte[], int, CodeInfo[])
CompareResult
实例NotFaceDetectedException
- 没有检测到人脸net.gdface.image.ImageErrorException
FaceApi.compareCodes(byte[], CodeInfo[])
,
FaceApi.detectAndGetCodeInfo(byte[], int)
public double detectAndCompare2Face(byte[] imgData1, FRect detectRect1, byte[] imgData2, FRect detectRect2) throws net.gdface.image.ImageErrorException, NotFaceDetectedException
FaceApi
FRect
)进行人脸检测,找到并提取唯一的人脸特征码,然后比较相似度,返回相似度结果null
时,
即比较同一张图像中的两张人脸的相似度,这种情况下detectRect1和detectRect2都不能为null
null
时,detectRect1和detectRect2被忽略detectAndCompare2Face
in interface FaceApi
imgData1
- 图像1数据(jpg,png...)字节数组,为null
则抛出IllegalArgumentException
detectRect1
- 图片检测范围,为null时全图检测imgData2
- 图像2数据(jpg,png...)字节数组detectRect2
- 图片检测范围,为null时全图检测net.gdface.image.ImageErrorException
NotFaceDetectedException
FaceApi.detectAndGetCodeInfo(byte[], int)
,
FaceApi.compareCode(byte[], byte[])
public java.util.List<java.lang.Double> compareFeatures(byte[] code1, java.util.List<byte[]> codes)
FaceApi
compareFeatures
in interface FaceApi
code1
- 人脸特征数据codes
- 一组人脸特征public double[] compareCodes(byte[] code1, CodeInfo[] codes)
FaceApi
compareCodes
in interface FaceApi
code1
- 待比对的特征码codes
- 包含人脸特征的CodeInfo
数组protected net.gdface.image.BaseLazyImage makeOpenedLazyImage(byte[] imgData) throws net.gdface.image.UnsupportedFormatException, net.gdface.image.NotImageException
BaseLazyImage.setAutoClose(boolean)
设置 autClose为false
imgData
- net.gdface.image.UnsupportedFormatException
net.gdface.image.NotImageException
BaseLazyImage.open()
,
BaseLazyImage.setAutoClose(boolean)
public CodeInfo detectCenterFace(byte[] imgData) throws NotFaceDetectedException, net.gdface.image.ImageErrorException
FaceApi
CodeInfo
detectCenterFace
in interface FaceApi
imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出IllegalArgumentException
CodeInfo
NotFaceDetectedException
net.gdface.image.ImageErrorException
protected CodeInfo findMaxFace(CodeInfo[] facePos)
public CodeInfo detectMaxFace(byte[] imgData) throws NotFaceDetectedException, net.gdface.image.ImageErrorException
FaceApi
CodeInfo
detectMaxFace
in interface FaceApi
imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出IllegalArgumentException
CodeInfo
NotFaceDetectedException
net.gdface.image.ImageErrorException
public boolean hasFace(byte[] imgData) throws net.gdface.image.ImageErrorException
FaceApi
true
则能检测到人脸并能提取特征码hasFace
in interface FaceApi
imgData
- 图像数据(jpg,png...)字节数组,为null
则抛出IllegalArgumentException
true
则能检测到人脸并能提取特征码net.gdface.image.ImageErrorException
FaceApi.detectAndGetCodeInfo(byte[], int)
public boolean matHasFace(net.gdface.image.MatType matType, byte[] matData, int width, int height)
FaceApi
true
则能检测到人脸并能提取特征码matHasFace
in interface FaceApi
matType
- 图像矩阵类型matData
- 图像矩阵,为null
则抛出IllegalArgumentException
width
- 图像宽度height
- 图像高度true
则能检测到人脸并能提取特征码public CodeInfo matDetectMaxFace(net.gdface.image.MatType matType, byte[] matData, int width, int height) throws NotFaceDetectedException
FaceApi
CodeInfo
matDetectMaxFace
in interface FaceApi
CodeInfo
NotFaceDetectedException
public byte[] getFeature(java.util.Map<java.nio.ByteBuffer,CodeInfo> faces) throws NotFaceDetectedException
FaceApi
#multiFaceFeature()
返回false
时代表此方法未被实现,执行会抛出异常getFeature
in interface FaceApi
faces
- 人脸图像数据(jpg,png...)与人脸位置信息对象的映射NotFaceDetectedException
public FseResult[] searchFaces(byte[] imgData, CodeInfo facePos, double similarty, int rows) throws NotFaceDetectedException, net.gdface.image.ImageErrorException
FaceApi
facePos
指定的人脸位置提取特征码,然后在数据库中搜索相似的人脸返回搜索结果。searchFaces
in interface FaceApi
imgData
- 图片字节数组facePos
- 人脸位置对象null
时,先做人脸检测再提取特征码null
时,直接在指定的位置提取特征码similarty
- 相似度阀值rows
- 最多返回的记录数目FseResult
数组NotFaceDetectedException
- -net.gdface.image.ImageErrorException
- -FaceApi.getCodeInfo(byte[], int, CodeInfo[])
,
FaceApi.searchFeatures(byte[], double, int)
public 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
FaceApi
facePos
指定的人脸位置提取特征码,然后在数据库中搜索相似的人脸返回搜索结果。matSearchFaces
in interface FaceApi
matType
- 图像矩阵类型matData
- 图像矩阵width
- 图像宽度facePos
- 人脸位置对象null
时,先做人脸检测再提取特征码null
时,直接在指定的位置提取特征码similarty
- 相似度阀值rows
- 最多返回的记录数目FseResult
数组NotFaceDetectedException
- -net.gdface.image.ImageErrorException
- -FaceApi.getCodeInfo(byte[], int, CodeInfo[])
,
FaceApi.searchFeatures(byte[], double, int)
protected abstract net.gdface.image.MatType getNativeMatrixType()
null
protected abstract byte[] toNativeMatrix(net.gdface.image.MatType matType, byte[] matData, int width, int height)
getNativeMatrixType()
)matType
- 输入矩阵类型matData
- 矩阵数据width
- 矩阵宽度height
- 矩阵高度public static final FeatureSe getFeatureSeInstance(FaceApi faceapi)
faceapi
- Copyright © 2020. All rights reserved.