From 17308f6494c81fb5a5ee035724a414ec7da11936 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期四, 22 八月 2024 08:38:45 +0800
Subject: [PATCH] Merge branch 'master' of http://47.108.235.38:8080/r/cylsg

---
 cylsg/EzTencentCloud/TencentCloudService.cs |  213 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 209 insertions(+), 4 deletions(-)

diff --git a/cylsg/EzTencentCloud/TencentCloudService.cs b/cylsg/EzTencentCloud/TencentCloudService.cs
index 5d2919d..ceafd97 100644
--- a/cylsg/EzTencentCloud/TencentCloudService.cs
+++ b/cylsg/EzTencentCloud/TencentCloudService.cs
@@ -12,11 +12,25 @@
 using TencentCloud.Common.Profile;
 using Furion.DependencyInjection;
 using Furion;
+using TencentCloud.Iai.V20200303;
+using TencentCloud.Iai.V20200303.Models;
+
+
+
 
 namespace EzTencentCloud
 {
     public class TencentCloudService: ITencentCloudService, IScoped
     {
+
+       
+
+
+        public   TencentCloudService()
+        {
+           
+        }
+        #region orc 鍥炬枃璇嗗埆
         /// <summary>
         /// 鍓鍚庣殑韬唤璇佸浘鐗�
         /// </summary>
@@ -31,13 +45,14 @@
 
         }
 
-        public   IDCardOCRResponse IdCord(string ImageBase64, bool isFRONT)
+        public IDCardOCRResponse IdCord(string ImageBase64, bool isFRONT)
         {
             try
             {
+
                 Credential cred = new Credential
                 {
-                    SecretId = App.Configuration["TencentCloud:SecretId"] ??"AKIDIPFp9CyThfMmvoQlpeCl34pKYVBahY9T",
+                    SecretId = App.Configuration["TencentCloud:SecretId"] ?? "AKIDIPFp9CyThfMmvoQlpeCl34pKYVBahY9T",
                     SecretKey = App.Configuration["TencentCloud:SecretKey"] ?? "4rNcaHhrkMhmb9QQ9bmgKipfFZcOt86n"
                 };
 
@@ -48,7 +63,8 @@
                 httpProfile.Endpoint = ("ocr.tencentcloudapi.com");
                 clientProfile.HttpProfile = httpProfile;
 
-                OcrClient client = new OcrClient(cred, "ap-beijing", clientProfile);
+                var _ocrClient = new OcrClient(cred, "ap-shanghai", clientProfile);
+
                 IDCardOCRRequest req = new IDCardOCRRequest();
                 if (isFRONT)
                     req.CardSide = "FRONT";
@@ -73,7 +89,7 @@
                     Quality = true,
 
                 });
-                IDCardOCRResponse resp =  client.IDCardOCRSync(req);
+                IDCardOCRResponse resp = _ocrClient.IDCardOCRSync(req);
 
                 if (resp == null)
                     throw new Exception("鍥剧墖鏃犳硶璇嗗埆锛岃閲嶆柊閫夋嫨韬唤璇佸浘鐗�");
@@ -103,6 +119,195 @@
         }
 
 
+
+        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 浜鸿劯璇嗗埆
+        public void  IaiCreatGroup()
+        {
+
+            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 = ("iai.tencentcloudapi.com");
+            clientProfile.HttpProfile = httpProfile;
+
+            var iaiClient = new IaiClient(cred, "ap-shanghai", clientProfile);
+            try
+            {
+                var retinfo = iaiClient.GetGroupInfoSync(new GetGroupInfoRequest
+                {
+                    GroupId = App.Configuration["IAIGroupSet:ID"] ?? "",
+                });
+            }
+            catch (TencentCloudSDKException e)
+            {
+                if (e.ErrorCode == "InvalidParameterValue.GroupIdNotExist")
+
+                {
+                    CreateGroupRequest request = new CreateGroupRequest()
+                    {
+                        GroupId = App.Configuration["IAIGroupSet:ID"],
+                        GroupName= App.Configuration["IAIGroupSet:Name"],
+                       
+
+                    };
+                    var aia = iaiClient.CreateGroupSync(request);
+                }
+            }
+       
+          
+       
+        }
+
+
+        public bool IaiAddPerso( string img64,string PersonNameId,string PersonName,  int PersonGender)
+        {
+
+            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 = ("iai.tencentcloudapi.com");
+            clientProfile.HttpProfile = httpProfile;
+
+            var iaiClient = new IaiClient(cred, "ap-shanghai", clientProfile);
+           var ret=  iaiClient.CreatePerson(new TencentCloud.Iai.V20200303.Models.CreatePersonRequest
+            {
+                GroupId = App.Configuration["IAIGroupSet:ID"],
+                Image = img64,
+                 PersonId= PersonNameId,
+                PersonName= PersonName,
+                Gender=PersonGender,
+
+            });
+
+            if(ret.IsFaulted)
+            return false;
+            else
+            return true;
+
+
+
+        }
+
+
+        public bool IaiAddPersoImg(string img64, string PersonNameId, string PersonName, int PersonGender)
+        {
+
+            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 = ("iai.tencentcloudapi.com");
+            clientProfile.HttpProfile = httpProfile;
+            var iaiClient = new IaiClient(cred, "ap-chengdu", clientProfile);
+            var ret = iaiClient.CreateFace( new TencentCloud.Iai.V20200303.Models.CreateFaceRequest
+            {
+              
+                PersonId = PersonNameId,
+                Images = [img64],
+                 
+        
+
+            });
+
+            if (ret.IsFaulted)
+                return false;
+            else
+                return true;
+
+
+
+        }
+
+
+        public VerifyFaceResponse VerifyFace(string img64, string PersonNameId)
+        {
+            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 = ("iai.tencentcloudapi.com");
+            clientProfile.HttpProfile = httpProfile;
+            var iaiClient = new IaiClient(cred, "ap-chengdu", clientProfile);
+            var ret = iaiClient.VerifyFaceSync(new  TencentCloud.Iai.V20200303.Models.VerifyFaceRequest
+            {
+
+                PersonId = PersonNameId,
+                 Image= img64
+
+
+
+            });
+            return ret;
+
+
+
+        }
+        #endregion
+
     }
 
     //杩斿洖鎵╁睍鍙傛暟

--
Gitblit v1.9.1