cylsg/EzTencentCloud/ITencentCloudService.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
cylsg/EzTencentCloud/TencentCloudService.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
cylsg/EzUpFile/EzFileUploadService.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
cylsg/EzUpFile/IEzFileUploadService.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
cylsg/EzUpFile/UpFileController.cs | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
cylsg/EzTencentCloud/ITencentCloudService.cs
@@ -17,7 +17,7 @@ /// <summary> /// 身份证识别,并剪裁 /// </summary> /// <param name="ImageBase64"></param> /// <param name="ImageBase64">图片base64</param> /// <param name="isFRONT"></param> /// <returns></returns> IDCardOCRResponse IdCord(string ImageBase64, bool isFRONT); @@ -26,9 +26,16 @@ /// </summary> /// <returns></returns> string GetIdCordImg(); /// <summary> /// 营业执照认证 /// </summary> /// <param name="ImageBase64"> 图片base64</param> /// <returns></returns> BizLicenseOCRResponse BizLicenseOCR(string ImageBase64); #endregion #region iai 人脸识别 public void IaiCreatGroup(); #endregion } cylsg/EzTencentCloud/TencentCloudService.cs
@@ -117,6 +117,45 @@ } public BizLicenseOCRResponse BizLicenseOCR(string ImageBase64) { try { Credential cred = new Credential { SecretId = App.Configuration["TencentCloud:SecretId"] ?? "AKIDIPFp9CyThfMmvoQlpeCl34pKYVBahY9T", SecretKey = App.Configuration["TencentCloud:SecretKey"] ?? "4rNcaHhrkMhmb9QQ9bmgKipfFZcOt86n" }; ClientProfile clientProfile = new ClientProfile(); HttpProfile httpProfile = new HttpProfile(); httpProfile.Endpoint = ("ocr.tencentcloudapi.com"); clientProfile.HttpProfile = httpProfile; var _ocrClient = new OcrClient(cred, "ap-chengdu", clientProfile); var ret = _ocrClient.BizLicenseOCRSync(new BizLicenseOCRRequest() { ImageBase64 = ImageBase64, }); return ret; } catch (Exception) { throw; } } #endregion #region iai 人脸识别 cylsg/EzUpFile/EzFileUploadService.cs
@@ -14,6 +14,8 @@ using System.Globalization; using System.Security.Policy; using TencentCloud.Ocr.V20181119.Models; using TencentCloud.Teo.V20220901.Models; using Task = System.Threading.Tasks.Task; namespace EzUpFile { /// <summary> @@ -349,6 +351,71 @@ } public async Task<(BizLicenseOCRResponse, string)> UpBizLicense() { try { var maxSize = 1024 * 1024 * 5; //上传大小5M var FileData = _request?.Form?.Files["file"]; if (FileData.Length > maxSize) { throw Oops.Oh(" 上传文件不可超出500K"); } //处理图形 // var FileData = Request.Form.Files[0]; Image oimage = Image.FromStream(FileData.OpenReadStream()); if (oimage == null) { throw Oops.Oh(" 上传失败"); } MemoryStream ms = new MemoryStream(); if (oimage.Width > 600) { if (oimage.Width > oimage.Height) oimage.GetThumbnailImage(600, 400, null, IntPtr.Zero).Save(ms, System.Drawing.Imaging.ImageFormat.Png); else oimage.GetThumbnailImage(400, 600, null, IntPtr.Zero).Save(ms, System.Drawing.Imaging.ImageFormat.Png); } else oimage.Save(ms, System.Drawing.Imaging.ImageFormat.Png); ms.Position = 0; var arr = ms.ToArray(); string img64 = Convert.ToBase64String(arr); BizLicenseOCRResponse info = null; string url = ""; try { info = _tcs.BizLicenseOCR(img64); url = await UploadFilesFByBase64(img64); return (info, url); } catch (Exception e) { throw Oops.Oh(e.Message); } } catch (Exception e) { throw Oops.Oh(e.Message); } } #endregion cylsg/EzUpFile/IEzFileUploadService.cs
@@ -34,6 +34,13 @@ /// <returns></returns> Task<(IDCardOCRResponse, string)> UpIdCord(string PageName = "FRONT"); /// <summary> /// 上传营业执照 /// </summary> /// <returns></returns> Task<(BizLicenseOCRResponse, string)> UpBizLicense(); } cylsg/EzUpFile/UpFileController.cs
@@ -35,6 +35,20 @@ return await fileUploadService.UpIdCord(PageName); } /// <summary> /// 上传和识别营业执照 /// </summary> /// <param name="PageName"> 身份证正反面 FRONT 正面 Back 国徽反面 </param> /// <returns></returns> [HttpPost] public async Task<(BizLicenseOCRResponse, string)> UpBizLicense([FromServices] IEzFileUploadService fileUploadService, IFormFile file) { return await fileUploadService.UpBizLicense(); } public async Task test([FromServices] ITencentCloudService fileUploadService) {