|
|
@@ -1,7 +1,10 @@
|
|
|
package com.fs.common.utils.txocr;
|
|
|
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import com.fasterxml.jackson.databind.JsonNode;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.google.gson.Gson;
|
|
|
+import com.google.gson.JsonObject;
|
|
|
import com.tencentcloudapi.common.AbstractModel;
|
|
|
import com.tencentcloudapi.common.CommonClient;
|
|
|
import com.tencentcloudapi.common.Credential;
|
|
|
@@ -14,6 +17,8 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import java.util.Arrays;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
import java.util.Optional;
|
|
|
import java.util.concurrent.atomic.AtomicReference;
|
|
|
|
|
|
@@ -27,6 +32,28 @@ public class TxOcrClient {
|
|
|
|
|
|
private static final String YPLS = "药品零售";
|
|
|
|
|
|
+ public static IdCardVerificationResponse IdCardVerification(String name, String idNumber) {
|
|
|
+ IdCardVerificationResponse map = new IdCardVerificationResponse();
|
|
|
+ try {
|
|
|
+ Credential cred = new Credential("AKIDviPyMZbRp24udCcpqjQxHOK4cx88ze6N", "97tVwEJE81sY0StDPPGukQ2ZvkU3QceY");
|
|
|
+ HttpProfile httpProfile = new HttpProfile();
|
|
|
+ httpProfile.setEndpoint("faceid.tencentcloudapi.com");
|
|
|
+ ClientProfile clientProfile = new ClientProfile();
|
|
|
+ clientProfile.setHttpProfile(httpProfile);
|
|
|
+ CommonClient client = new CommonClient("faceid", "2018-03-01", cred, "", clientProfile);
|
|
|
+ String params = "{\"IdCard\":\""+idNumber+"\",\"Name\":\""+name+"\"}";
|
|
|
+ String resp = client.call("IdCardVerification", params);
|
|
|
+ JSONObject jsonObject = new JSONObject(resp);
|
|
|
+ JSONObject response = (JSONObject)jsonObject.get("Response");
|
|
|
+ map.setDescription(response.get("Description").toString());
|
|
|
+ map.setResult(Integer.parseInt(response.get("Result").toString()));
|
|
|
+ } catch (TencentCloudSDKException e) {
|
|
|
+ log.error("身份证识别请求异常:{}",e.getMessage());
|
|
|
+ map.setDescription("识别失败");
|
|
|
+ map.setResult(-8);
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
/**
|
|
|
* 医疗器械url识别
|
|
|
* @return
|
|
|
@@ -258,9 +285,13 @@ public class TxOcrClient {
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- ExtractDocBasic("https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/fs/20251118/d175ed9771324c56a126779ef89bb1e3.jpg");
|
|
|
+// ExtractDocBasic("https://bjyjb-1362704775.cos.ap-chongqing.myqcloud.com/fs/20251118/d175ed9771324c56a126779ef89bb1e3.jpg");
|
|
|
+ IdCardVerification("郭顺", "111");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* ClassifyDetectOCR
|
|
|
* 支持身份证、护照、名片、银行卡、行驶证、驾驶证、港澳台通行证、户口本、港澳台来往内地通行证、港澳台居住证、不动产证、营业执照的智能分类。
|