接入騰訊雲的OCR識別身份證信息


在公司用到這個功能在這里進行總結一下

1 導入Pom

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

2 測試類

public class CertificationTest {

    @Test
    public void  CertificationTest(){
        String tsecretId="xxxxx";
        String tsecretKey="xxxx";
        String image="xxxx";
        try{
            Credential cred = new Credential(tsecretId, tsecretKey);
            HttpProfile httpProfile = new HttpProfile();
            httpProfile.setEndpoint("ocr.tencentcloudapi.com");
            ClientProfile clientProfile = new ClientProfile();
            clientProfile.setHttpProfile(httpProfile);
            OcrClient client = new OcrClient(cred, "ap-beijing", clientProfile);
            IDCardOCRRequest req = new IDCardOCRRequest();
            req.setImageUrl(image);
            IDCardOCRResponse resp = client.IDCardOCR(req);

            System.out.println(IDCardOCRResponse.toJsonString(resp));
        } catch (TencentCloudSDKException e) {
            System.out.println(e.toString());
        }
    }
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM