|
@@ -6,6 +6,9 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.tencentcloudapi.common.Credential;
|
|
|
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
|
|
|
import com.tencentcloudapi.common.profile.ClientProfile;
|
|
|
+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;
|
|
@@ -115,6 +118,7 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
req.setConfig("{\"CropIdCard\":true}");
|
|
|
IDCardOCRResponse resp = client.IDCardOCR(req);
|
|
|
String IdNum = resp.getIdNum();
|
|
|
+ String IdName = resp.getName();
|
|
|
String AdvancedInfo = resp.getAdvancedInfo();
|
|
|
String IdCard = JSONObject.parseObject(AdvancedInfo).getString("IdCard");
|
|
|
if(Validator.isEmpty(IdCard)){
|
|
@@ -126,6 +130,7 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
ossRequest.setImageStatus(5);
|
|
|
String ossPath = ossService.uploadBase64(IdCard,ossRequest);
|
|
|
rs.put("IdNum",IdNum);
|
|
|
+ rs.put("IdName",IdName);
|
|
|
rs.put("IdImgPath",ossPath);
|
|
|
return rs;
|
|
|
}catch (TencentCloudSDKException e){
|
|
@@ -162,4 +167,26 @@ public class FaceOcrServiceImpl implements IFaceOcrService {
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Map<String, Object> ImageRecognition(FaceQueryBo bo) {
|
|
|
+ try{
|
|
|
+ if(Validator.isEmpty(bo.getOneInchPhotos())||Validator.isEmpty(bo.getIdNum())||Validator.isEmpty(bo.getIdName())){
|
|
|
+ throw new CustomException("缺少参数");
|
|
|
+ }
|
|
|
+ Credential cred = new Credential(SecretId, SecretKey);
|
|
|
+ FaceidClient client = new FaceidClient(cred, "ap-guangzhou");
|
|
|
+ ImageRecognitionRequest req = new ImageRecognitionRequest();
|
|
|
+ req.setImageBase64(bo.getOneInchPhotos());
|
|
|
+ req.setIdCard(bo.getIdNum());
|
|
|
+ req.setName(bo.getIdName());
|
|
|
+ ImageRecognitionResponse resp = client.ImageRecognition(req);
|
|
|
+ Map<String,Object> rs = new HashMap<>();
|
|
|
+ rs.put("sim",resp.getSim());
|
|
|
+ return rs;
|
|
|
+ }catch (TencentCloudSDKException e){
|
|
|
+ System.out.println("错误"+e.getMessage());
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
}
|