Пример #1
0
        /// <summary>
        /// 本接口支持中国大陆居民二代身份证正反面所有字段的识别,包括姓名、性别、民族、出生日期、住址、公民身份证号、签发机关、有效期限;具备身份证照片、人像照片的裁剪功能和翻拍、PS、复印件告警功能,以及边框和框内遮挡告警、临时身份证告警和身份证有效期不合法告警等扩展功能。
        /// </summary>
        /// <param name="req">参考<see cref="IDCardOCRRequest"/></param>
        /// <returns>参考<see cref="IDCardOCRResponse"/>实例</returns>
        public async Task <IDCardOCRResponse> IDCardOCR(IDCardOCRRequest req)
        {
            JsonResponseModel <IDCardOCRResponse> rsp = null;

            try
            {
                var strResp = await this.InternalRequest(req, "IDCardOCR");

                rsp = JsonConvert.DeserializeObject <JsonResponseModel <IDCardOCRResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
Пример #2
0
        /// <summary>
        /// 身份证识别
        /// </summary>
        /// <param name="inputParm">输入参数</param>
        /// <returns></returns>
        public async Task <IdCard> GetIdCard(InputParm inputParm)
        {
            var credential = new Credential();
            var config     = Ioc.GetService <IConfiguration>();

            credential.SecretId  = config.GetSection("Tencent:SecretId").Value ?? "";
            credential.SecretKey = config.GetSection("Tencent:SecretKey").Value ?? "";
            ClientProfile clientProfile = new ClientProfile();
            HttpProfile   httpProfile   = new HttpProfile();

            httpProfile.Endpoint      = ("ocr.tencentcloudapi.com");
            clientProfile.HttpProfile = httpProfile;
            OcrClient        client = new OcrClient(credential, "ap-guangzhou", clientProfile);
            IDCardOCRRequest req    = new IDCardOCRRequest();

            req = IDCardOCRRequest.FromJsonString <IDCardOCRRequest>(Json.ToJson(inputParm));
            IDCardOCRResponse resp = await client.IDCardOCR(req);

            return(resp.MapTo <IdCard>());
        }