|
@@ -11,8 +11,7 @@ import com.tencentcloudapi.faceid.v20180301.FaceidClient;
|
|
|
import com.tencentcloudapi.faceid.v20180301.models.ImageRecognitionRequest;
|
|
|
import com.tencentcloudapi.faceid.v20180301.models.ImageRecognitionResponse;
|
|
|
import com.tencentcloudapi.iai.v20200303.IaiClient;
|
|
|
-import com.tencentcloudapi.iai.v20200303.models.CompareFaceRequest;
|
|
|
-import com.tencentcloudapi.iai.v20200303.models.CompareFaceResponse;
|
|
|
+import com.tencentcloudapi.iai.v20200303.models.*;
|
|
|
import com.tencentcloudapi.ocr.v20181119.OcrClient;
|
|
|
import com.tencentcloudapi.ocr.v20181119.models.*;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
@@ -85,21 +84,50 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
|
|
|
// String oneInchPhotos = JSONObject.parseObject(String.valueOf(maps.get("recent_photos")), UserProfileFit.class).getValue(); //审核资料一寸照片
|
|
|
|
|
|
- String oneInchPhotos =ossHost+"/"+userVo.getOneInchPhotos();
|
|
|
+ if(DetectFace(bo)){
|
|
|
+ String oneInchPhotos =ossHost+"/"+userVo.getOneInchPhotos();
|
|
|
+ Credential cred = new Credential(SecretId, SecretKey);
|
|
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
+ clientProfile.setSignMethod(clientProfile.SIGN_TC3_256);
|
|
|
+ IaiClient iaiClient = new IaiClient(cred,"ap-guangzhou");
|
|
|
+ CompareFaceRequest faceRequest = new CompareFaceRequest();
|
|
|
+ faceRequest.setImageA(bo.getImageA()); //学习拍照
|
|
|
+ faceRequest.setUrlB(oneInchPhotos); //一寸近照
|
|
|
+ faceRequest.setQualityControl(2L);
|
|
|
+ CompareFaceResponse response = iaiClient.CompareFace(faceRequest);
|
|
|
+ return response.getScore().intValue();
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+ }catch (TencentCloudSDKException e){
|
|
|
+ System.out.println("错误"+e.getMessage());
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Boolean DetectFace(FaceQueryBo bo) {
|
|
|
+ try{
|
|
|
Credential cred = new Credential(SecretId, SecretKey);
|
|
|
ClientProfile clientProfile = new ClientProfile();
|
|
|
clientProfile.setSignMethod(clientProfile.SIGN_TC3_256);
|
|
|
IaiClient iaiClient = new IaiClient(cred,"ap-guangzhou");
|
|
|
- CompareFaceRequest faceRequest = new CompareFaceRequest();
|
|
|
- faceRequest.setImageA(bo.getImageA()); //学习拍照
|
|
|
- faceRequest.setUrlB(oneInchPhotos); //一寸近照
|
|
|
- faceRequest.setQualityControl(2L);
|
|
|
- CompareFaceResponse response = iaiClient.CompareFace(faceRequest);
|
|
|
- return response.getScore().intValue();
|
|
|
+ DetectFaceRequest faceRequest = new DetectFaceRequest();
|
|
|
+ faceRequest.setImage(bo.getImageA()); //学习拍照
|
|
|
+ DetectFaceResponse response = iaiClient.DetectFace(faceRequest);
|
|
|
+ FaceInfo[] face = response.getFaceInfos();
|
|
|
+ if(face[0].getFaceQualityInfo().getBrightness().intValue()<30){
|
|
|
+ throw new CustomException("照片光照不达标"+face[0].getFaceQualityInfo().getBrightness().intValue());
|
|
|
+ }
|
|
|
+ if(face[0].getFaceQualityInfo().getScore().intValue()<40){
|
|
|
+ throw new CustomException("照片质量不达标"+face[0].getFaceQualityInfo().getScore().intValue());
|
|
|
+ }
|
|
|
+ if(Validator.isEmpty(face[0].getFaceQualityInfo().getCompleteness())){
|
|
|
+ throw new CustomException("照片五官不达标");
|
|
|
+ }
|
|
|
}catch (TencentCloudSDKException e){
|
|
|
- System.out.println("错误"+e.getMessage());
|
|
|
- return 0;
|
|
|
+ throw new CustomException("人脸检测错误"+e.getMessage());
|
|
|
}
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Override
|