예제 #1
0
        private void SendRequest(object state)
        {
            mServerResult = string.Empty;
            try
            {
#if TENCENT
                ClientProfile clientProfile = new ClientProfile();
                HttpProfile   httpProfile   = new HttpProfile();
                httpProfile.Endpoint      = ("iai.tencentcloudapi.com");
                clientProfile.HttpProfile = httpProfile;
                IaiClient          client = new IaiClient(mCredential, "", clientProfile);
                DetectFaceRequest  req    = DetectFaceRequest.FromJsonString <DetectFaceRequest>(state.ToString());
                DetectFaceResponse resp   = client.DetectFace(req).ConfigureAwait(false).GetAwaiter().GetResult();
                mServerResult = AbstractModel.ToJsonString(resp);
                mResult       = JsonUtility.FromJson <DFServerResult>(mServerResult);
#endif
                mIsDone = true;
            }
            catch (System.Exception ex)
            {
                mServerResult = ex.Message;
                string[]       sf = mServerResult.Split(' ');
                DFServerResult rs = new DFServerResult();

                rs.Error         = new DFError();
                rs.Error.Code    = sf[0].Split(':')[1];
                rs.Error.Message = sf[1].Split(':')[1];
                mResult          = rs;
                mIsDone          = true;
            }
        }
        public void cloudCheck()
        {
            String aaaa = path + "aaa.png";

            Console.WriteLine(aaaa);
            String ImagBase64 = ImgToBase64String(aaaa);

            //String ImagBase64 = "";
            //StreamWriter sw = new StreamWriter(Application.StartupPath + "\\Log.txt", true, Encoding.Default);
            //sw.WriteLine(ImagBase64);
            //sw.Close();
            //  Console.WriteLine(ImagBase64);


            try
            {
                Credential cred = new Credential
                {
                    SecretId  = "XXXX",
                    SecretKey = "yyyy"
                };

                ClientProfile clientProfile = new ClientProfile();
                HttpProfile   httpProfile   = new HttpProfile();
                httpProfile.Endpoint      = ("iai.tencentcloudapi.com");
                clientProfile.HttpProfile = httpProfile;

                IaiClient          client    = new IaiClient(cred, "ap-seoul", clientProfile);
                SearchFacesRequest req       = new SearchFacesRequest();
                string             strParams = "{\"GroupIds\":[\"hjtest\"],\"Image\":\"" + ImagBase64 + "\"}";
                req = SearchFacesRequest.FromJsonString <SearchFacesRequest>(strParams);
                SearchFacesResponse resp = client.SearchFacesSync(req);
                String tt = AbstractModel.ToJsonString(resp);
                //   Console.WriteLine(tt);
                String temp = GetPerson(tt);
                if (temp.Equals("error"))
                {
                    //MessageBox.Show("존재하지 않는 Person");
                }
                else
                {
                }
                // Console.WriteLine(temp);
                ListBoxItemAdd(this, this.listBox1, temp);
            }
            catch (Exception e)
            {
                ListBoxItemAdd(this, this.listBox1, "존재하지 않는 Person");
                Console.WriteLine(e.ToString());
            }
            Console.Read();
        }