|
@@ -134,20 +134,18 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
faceRequest.setMinFaceSize(40L);
|
|
|
faceRequest.setMaxFaceNum(1L);
|
|
|
FaceInfo[] face = response.getFaceInfos();
|
|
|
+ Long imageWidth = response.getImageWidth();
|
|
|
+ Long imageHeight = response.getImageHeight();
|
|
|
if(face[0].getFaceQualityInfo().getBrightness().intValue()<25){
|
|
|
- log.info("照片光照不达标"+face[0].getFaceQualityInfo().getBrightness().intValue());
|
|
|
- throw new CustomException("照片光照不达标"+face[0].getFaceQualityInfo().getBrightness().intValue());
|
|
|
+ throw new CustomException("照片光照不合格,请重新拍照!");
|
|
|
}
|
|
|
if(face[0].getFaceQualityInfo().getBrightness().intValue()>95){
|
|
|
- log.info("照片光照不达标"+face[0].getFaceQualityInfo().getBrightness().intValue());
|
|
|
- throw new CustomException("照片光照曝光"+face[0].getFaceQualityInfo().getBrightness().intValue());
|
|
|
+ throw new CustomException("照片光照曝光,请重新拍照!");
|
|
|
}
|
|
|
if(face[0].getFaceQualityInfo().getScore().intValue()<30){
|
|
|
- log.info("照片质量不达标"+face[0].getFaceQualityInfo().getScore().intValue());
|
|
|
- throw new CustomException("照片质量不达标"+face[0].getFaceQualityInfo().getScore().intValue());
|
|
|
+ throw new CustomException("照片质量不合格,请重新拍照!");
|
|
|
}
|
|
|
if(Validator.isEmpty(face[0].getFaceQualityInfo().getCompleteness())){
|
|
|
- log.info("照片五官不达标");
|
|
|
throw new CustomException("照片五官不达标");
|
|
|
}
|
|
|
FaceQualityCompleteness completeness = face[0].getFaceQualityInfo().getCompleteness();
|
|
@@ -169,6 +167,17 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
if (ObjectUtils.isNull(completeness.getChin()) || completeness.getChin() < 60){
|
|
|
throw new CustomException("请勿遮挡下巴");
|
|
|
}
|
|
|
+ if (imageWidth * 0.55 < face[0].getWidth()){
|
|
|
+ throw new CustomException("人脸与摄像头距离太近,请把摄像头或手机离脸远一些再拍照!");
|
|
|
+ }
|
|
|
+ if (imageHeight * 0.85 < (face[0].getY()+face[0].getHeight())){
|
|
|
+ throw new CustomException("照片的人脸太下,请拍照时把两肩拍出来!");
|
|
|
+ }
|
|
|
+ if(face[0].getX()<0|| face[0].getY()<0
|
|
|
+ || (face[0].getX() + face[0].getWidth()) > imageWidth)
|
|
|
+ {
|
|
|
+ throw new CustomException("请保证人脸全部在照片范围内!");
|
|
|
+ }
|
|
|
}catch (TencentCloudSDKException e){
|
|
|
log.info("人脸检测错误"+e.getMessage());
|
|
|
throw new CustomException("人脸检测错误"+e.getMessage());
|