成人午夜视频全免费观看高清-秋霞福利视频一区二区三区-国产精品久久久久电影小说-亚洲不卡区三一区三区一区

百度人臉識(shí)別之人臉識(shí)別FaceIdentify(簽到考勤)-創(chuàng)新互聯(lián)

本文實(shí)例為大家分享了百度人臉識(shí)別之人臉識(shí)別FaceIdentify,供大家參考,具體內(nèi)容如下

創(chuàng)新互聯(lián)公司專(zhuān)業(yè)為企業(yè)提供晉城網(wǎng)站建設(shè)、晉城做網(wǎng)站、晉城網(wǎng)站設(shè)計(jì)、晉城網(wǎng)站制作等企業(yè)網(wǎng)站建設(shè)、網(wǎng)頁(yè)設(shè)計(jì)與制作、晉城企業(yè)網(wǎng)站模板建站服務(wù),10余年晉城做網(wǎng)站經(jīng)驗(yàn),不只是建網(wǎng)站,更提供有價(jià)值的思路和整體網(wǎng)絡(luò)服務(wù)。

百度人臉識(shí)別之人臉識(shí)別FaceIdentify(簽到考勤)

百度人臉識(shí)別之人臉識(shí)別FaceIdentify(簽到考勤)

百度人臉識(shí)別之人臉識(shí)別FaceIdentify(簽到考勤)

using System.Collections.Generic;
using UnityEngine;
using Baidu.Aip.Face;
using Newtonsoft.Json.Linq;
using UnityEngine.UI;
using System.IO;
 
//識(shí)別,(用于簽到考勤)
public class FaceIdentify : MonoBehaviour {
 
  private Face client;//百度API接口
  private JObject result;//識(shí)別數(shù)據(jù)的返回結(jié)果
  private byte[] image;//圖片字節(jié)數(shù)
  private Dictionary<string, object> options = new Dictionary<string, object>();//多參數(shù)
  private double scores;//返回的分?jǐn)?shù),用來(lái)判定識(shí)別是否達(dá)標(biāo)
  private string group_id;//用戶(hù)所在的用戶(hù)組,或者說(shuō)部門(mén)
  private int error_code;//返回得錯(cuò)誤代碼
  private string error_msg;//返回得錯(cuò)誤提示信息
  public Text DebugText;
  public Text DebugText1;
  public Text DebugText2;
  private string result_group_id;//result返回的用戶(hù)組數(shù)據(jù)
  private string result_uid;//result返回的用戶(hù)id數(shù)據(jù)
  private string result_user_info;//result 返回的用戶(hù)信息數(shù)據(jù)
  public bool isSuccess = false;
 
  private void Awake()
  {
    client = new Face(AccessToken.client_id, AccessToken.client_secret);
    AccessToken.ClientCallback();//獲取證書(shū)
  }
 
  private void Start()
  {
    DebugText.text = "";
    DebugText1.text = "";
    DebugText2.text = "";
  }
  public void faceIdentify()
  {
    Invoke("Identify", 5.0f);
  }
 
  void Identify()
  {
    group_id = "U3D1";
    string path = Application.dataPath + "/ScreenShot/" + WebCamera.ScreenShotTexture2D + ".jpg";
    image = File.ReadAllBytes(path);
    options = new Dictionary<string, object>()
    {
      {"ext_fileds","faceliveness" },
      {"user_top_num",1 }//大返回5個(gè)識(shí)別數(shù)
    };
    try//避免出現(xiàn)網(wǎng)絡(luò)異常導(dǎo)致錯(cuò)誤
    {
      result = client.Identify(group_id, image, options);
      Debug.Log(result);
      
      error_code = int.Parse(result["error_code"].ToString());//先把json數(shù)據(jù)轉(zhuǎn)成字符串,再轉(zhuǎn)成int類(lèi)型
      error_msg = result["error_msg"].ToString();//把返回的json錯(cuò)誤信息轉(zhuǎn)成字符串
      switch (error_code)
      {
        case 216100:
          DebugText.text = "invalid param 參數(shù)異常,請(qǐng)重新填寫(xiě)注冊(cè)信息";
          break;
        case 216611:
          DebugText.text = "user not exist 用戶(hù)id不存在,請(qǐng)確認(rèn)該用戶(hù)是否注冊(cè)或注冊(cè)已經(jīng)生效(需要已經(jīng)注冊(cè)超過(guò)5s)";
          break;
        case 216401:
          DebugText.text = "internal error 內(nèi)部錯(cuò)誤";
          break;
        case 216402:
          DebugText.text = "face not found 未找到人臉,請(qǐng)檢查圖片是否含有人臉";
          break;
        case 216500:
          DebugText.text = "unknown error 未知錯(cuò)誤";
          break;
        case 216615:
          DebugText.text = "fail to process images 服務(wù)處理該圖片失敗,發(fā)生后重試即可";
          break;
        case 216618:
          DebugText.text = "no user in group 組內(nèi)用戶(hù)為空,確認(rèn)該group是否存在或已經(jīng)生效(需要已經(jīng)注冊(cè)超過(guò)5s)";
          break;
        default:
          DebugText.text = error_msg;
          break;
      }
      if (error_code != 216100 || error_code != 216101|| error_code != 216401
        || error_code != 216402 || error_code != 216500 || error_code != 216615 || error_code != 216618)
      {
        DebugText1.text = result.ToString();//顯示返回的數(shù)據(jù)信息
       
 
      }
    }
    catch
    {
      if (error_code != 216100 || error_code != 216101 || error_code != 216401
         || error_code != 216402 || error_code != 216500 || error_code != 216615 || error_code != 216618)
      {
        JToken res = result["result"];
        scores = double.Parse(res[0]["scores"][0].ToString());
        if (scores > 80.0f)
        {
          result_uid = res[0]["uid"].ToString();
          result_group_id = res[0]["group_id"].ToString();
          result_user_info = res[0]["user_info"].ToString();
 
          DebugText1.text = "識(shí)別成功,今日已簽到!";
          DebugText2.text = result_uid+"\n"+ result_group_id+"\n" + result_user_info;
          Debug.Log(result_uid.ToString() + result_group_id.ToString() + result_user_info.ToString());
        }
        else
        {
          DebugText1.text = "失敗,請(qǐng)重新識(shí)別!";
        }
      }
    }
  }
}

另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)scvps.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。

網(wǎng)站欄目:百度人臉識(shí)別之人臉識(shí)別FaceIdentify(簽到考勤)-創(chuàng)新互聯(lián)
鏈接分享:http://jinyejixie.com/article28/dedjjp.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供靜態(tài)網(wǎng)站、網(wǎng)站設(shè)計(jì)、標(biāo)簽優(yōu)化、微信小程序、App設(shè)計(jì)、品牌網(wǎng)站建設(shè)

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

h5響應(yīng)式網(wǎng)站建設(shè)
黑山县| 丹江口市| 曲水县| 沿河| 莱阳市| 寻乌县| 赤峰市| 新疆| 安义县| 成安县| 梧州市| 尚义县| 那坡县| 吉木萨尔县| 大庆市| 永胜县| 喀什市| 清水河县| 连平县| 府谷县| 五寨县| 屏山县| 景洪市| 盐津县| 江川县| 兴文县| 旺苍县| 北海市| 平南县| 嘉祥县| 饶平县| 咸阳市| 永州市| 绩溪县| 临城县| 武清区| 留坝县| 渑池县| 扎赉特旗| 宜兰市| 怀集县|