net.gdface.sdk.FaceApiDecorator Maven / Gradle / Ivy
package net.gdface.sdk;
import java.util.List;
import java.util.Map;
import net.gdface.image.ImageErrorException;
/**
* decorator pattern 装饰者模式实现{@link FaceApi}接口
* 转发所有{@link FaceApi}接口方法到{@link #delegate()}指定的实例,
* unchecked后缀的方法将所有显式申明的异常封装到{@link RuntimeException}抛出
* 计算机生成代码(generated by automated tools DecoratorGenerator @author guyadong)
* @author guyadong
*
*/
public class FaceApiDecorator implements FaceApi{
private final FaceApi delegate;
public FaceApiDecorator(FaceApi delegate) {
super();
if(null == delegate){
throw new NullPointerException("delegate is null");
}
this.delegate = delegate;
}
/**
* 返回被装饰的{@link FaceApi}实例
* @return
*/
public FaceApi delegate() {
return delegate;
}
@Override
public double compare2Face (byte[] imgData1,CodeInfo facePos1,byte[] imgData2,CodeInfo facePos2) throws ImageErrorException,NotFaceDetectedException{
return delegate().compare2Face(imgData1,facePos1,imgData2,facePos2);
}
/**
* {@link FaceApi#compare2Face(byte[],CodeInfo,byte[],CodeInfo)}对应的unchecked方法,
* 所有显式申明的异常都被封装到{@link RuntimeException}抛出
* @param imgData1
* @param facePos1
* @param imgData2
* @param facePos2
* @return double
*/
public double compare2FaceUnchecked (byte[] imgData1,CodeInfo facePos1,byte[] imgData2,CodeInfo facePos2) {
try{
return delegate().compare2Face(imgData1,facePos1,imgData2,facePos2);
} catch(RuntimeException e){
throw e;
} catch(Exception e){
throw new RuntimeException(e);
}
}
@Override
public double compareCode (byte[] code1,byte[] code2) {
return delegate().compareCode(code1,code2);
}
@Override
public double[] compareCodes (byte[] code1,CodeInfo[] codes) {
return delegate().compareCodes(code1,codes);
}
@Override
public List compareFeatures (byte[] code1,List codes) {
return delegate().compareFeatures(code1,codes);
}
@Override
public double detectAndCompare2Face (byte[] imgData1,FRect detectRect1,byte[] imgData2,FRect detectRect2) throws ImageErrorException,NotFaceDetectedException{
return delegate().detectAndCompare2Face(imgData1,detectRect1,imgData2,detectRect2);
}
/**
* {@link FaceApi#detectAndCompare2Face(byte[],FRect,byte[],FRect)}对应的unchecked方法,
* 所有显式申明的异常都被封装到{@link RuntimeException}抛出
* @param imgData1
* @param detectRect1
* @param imgData2
* @param detectRect2
* @return double
*/
public double detectAndCompare2FaceUnchecked (byte[] imgData1,FRect detectRect1,byte[] imgData2,FRect detectRect2) {
try{
return delegate().detectAndCompare2Face(imgData1,detectRect1,imgData2,detectRect2);
} catch(RuntimeException e){
throw e;
} catch(Exception e){
throw new RuntimeException(e);
}
}
@Override
public CodeInfo[] detectAndGetCodeInfo (byte[] imgData,int faceNum,FRect detectRectangle) throws ImageErrorException,NotFaceDetectedException{
return delegate().detectAndGetCodeInfo(imgData,faceNum,detectRectangle);
}
/**
* {@link FaceApi#detectAndGetCodeInfo(byte[],int,FRect)}对应的unchecked方法,
* 所有显式申明的异常都被封装到{@link RuntimeException}抛出
* @param imgData
* @param faceNum
* @param detectRectangle
* @return CodeInfo[]
*/
public CodeInfo[] detectAndGetCodeInfoUnchecked (byte[] imgData,int faceNum,FRect detectRectangle) {
try{
return delegate().detectAndGetCodeInfo(imgData,faceNum,detectRectangle);
} catch(RuntimeException e){
throw e;
} catch(Exception e){
throw new RuntimeException(e);
}
}
@Override
public CodeInfo detectCenterFace (byte[] imgData) throws ImageErrorException,NotFaceDetectedException{
return delegate().detectCenterFace(imgData);
}
/**
* {@link FaceApi#detectCenterFace(byte[])}对应的unchecked方法,
* 所有显式申明的异常都被封装到{@link RuntimeException}抛出
* @param imgData
* @return CodeInfo
*/
public CodeInfo detectCenterFaceUnchecked (byte[] imgData) {
try{
return delegate().detectCenterFace(imgData);
} catch(RuntimeException e){
throw e;
} catch(Exception e){
throw new RuntimeException(e);
}
}
@Override
public CodeInfo[] detectFace (byte[] imgData,FRect detectRectangle) throws ImageErrorException{
return delegate().detectFace(imgData,detectRectangle);
}
/**
* {@link FaceApi#detectFace(byte[],FRect)}对应的unchecked方法,
* 所有显式申明的异常都被封装到{@link RuntimeException}抛出
* @param imgData
* @param detectRectangle
* @return CodeInfo[]
*/
public CodeInfo[] detectFaceUnchecked (byte[] imgData,FRect detectRectangle) {
try{
return delegate().detectFace(imgData,detectRectangle);
} catch(RuntimeException e){
throw e;
} catch(Exception e){
throw new RuntimeException(e);
}
}
@Override
public CodeInfo[] detectFaceAgain (byte[] imgData,FRect[] detectRects) {
return delegate().detectFaceAgain(imgData,detectRects);
}
@Override
public CodeInfo[] getCodeInfo (byte[] imgData,int faceNum,CodeInfo[] facePos) throws NotFaceDetectedException{
return delegate().getCodeInfo(imgData,faceNum,facePos);
}
/**
* {@link FaceApi#getCodeInfo(byte[],int,net.gdface.sdk.CodeInfo[])}对应的unchecked方法,
* 所有显式申明的异常都被封装到{@link RuntimeException}抛出
* @param imgData
* @param faceNum
* @param facePos
* @return CodeInfo[]
*/
public CodeInfo[] getCodeInfoUnchecked (byte[] imgData,int faceNum,CodeInfo[] facePos) {
try{
return delegate().getCodeInfo(imgData,faceNum,facePos);
} catch(RuntimeException e){
throw e;
} catch(Exception e){
throw new RuntimeException(e);
}
}
@Override
public byte[] getFeature (Map faces) throws NotFaceDetectedException{
return delegate().getFeature(faces);
}
/**
* {@link FaceApi#getFeature(Map)}对应的unchecked方法,
* 所有显式申明的异常都被封装到{@link RuntimeException}抛出
* @param faces
* @return byte[]
*/
public byte[] getFeatureUnchecked (Map faces) {
try{
return delegate().getFeature(faces);
} catch(RuntimeException e){
throw e;
} catch(Exception e){
throw new RuntimeException(e);
}
}
@Override
public boolean hasFace (byte[] imgData,FRect detectRectangle) throws ImageErrorException{
return delegate().hasFace(imgData,detectRectangle);
}
/**
* {@link FaceApi#hasFace(byte[],FRect)}对应的unchecked方法,
* 所有显式申明的异常都被封装到{@link RuntimeException}抛出
* @param imgData
* @param detectRectangle
* @return boolean
*/
public boolean hasFaceUnchecked (byte[] imgData,FRect detectRectangle) {
try{
return delegate().hasFace(imgData,detectRectangle);
} catch(RuntimeException e){
throw e;
} catch(Exception e){
throw new RuntimeException(e);
}
}
@Override
public boolean isLocal () {
return delegate().isLocal();
}
@Override
public boolean multiFaceFeature () {
return delegate().multiFaceFeature();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy