腾讯云卡证识别

腾讯云卡证识别

  点关注不迷路,欢迎再访!

精简博客内容,尽量已专业术语来分享。
努力做到对每一位认可自己的读者负责。
帮助别人的同时更是丰富自己的良机。

腾讯云卡证识别:https://cloud.tencent.com/document/product/866/33524

现在是公测阶段,正式收费2020/01/01

1.首先去注册账号,新建密钥,生成APPID,SecretId,SecretKey,在调用接口是需要绑定参数。
在这里插入图片描述

调用官方接口有API/SDK两种方式,本章我们采用SDK 3.0来实现:

github源码地址:https://github.com/TencentCloud/tencentcloud-sdk-java

2.首先引入依赖

<dependency>
	        <groupId>com.tencentcloudapi</groupId>
	        <artifactId>tencentcloud-sdk-java</artifactId>   
	        <version>3.0.67</version>
        </dependency>

3.编写身份证测试类

/**
	 * imageData :图片
	 * type :0正面,反面
*/
public String idcardDetect(byte[] imageData, int type) throws Exception {
		 String result="";
	     try{
	    	String cardSide = "";
	    	if(type==0) {
	    		cardSide="FRONT";
	    	}else {
	    		cardSide="BACK";
	    	}
            Credential cred = new Credential(secretId, secretKey);	            
            HttpProfile httpProfile = new HttpProfile();
            httpProfile.setEndpoint("ocr.tencentcloudapi.com");
            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setHttpProfile(httpProfile);            	            
            OcrClient client = new OcrClient(cred, "ap-shanghai", clientProfile);
            String params = "{\"ImageBase64\":\""+Base64Util.encode(imageData)+"\",\"CardSide\":\""+cardSide+"\"}";
            IDCardOCRRequest req = IDCardOCRRequest.fromJsonString(params, IDCardOCRRequest.class);	            
            IDCardOCRResponse resp = client.IDCardOCR(req);
            result = IDCardOCRRequest.toJsonString(resp);
        } catch (TencentCloudSDKException e) {
        	return e.getMessage();
        }
		return result;
	}

4.需要去开通对应服务才可以访问:

{“code”:3,“message”:“服务未开通,请在控制台开通服务。”,“seq”:“0b49f66f-cccc-4fe5-b6cc-20f4cea4ac58”,“data”:{}
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值