文章标题

来源:互联网 发布:ubuntu jira 编辑:程序博客网 时间:2024/05/21 13:54

こんにちは、今回中国の旷视というメーカーから提供しているFace++というサービスを利用して写真中での「簡体字」を認識するアプリを作ってみました!
https://www.faceplusplus.com.cn

機能としては、先ず簡体字がある写真を撮るかスマホの
アルバムから取ってFace++のサーバーにアップロードして「テキスト認識」というサービスを使って認識される文字列がjsonで返されてクライアントで解析します。

Face++のインタフェースを呼び出すところ:

    public void TestHttpSend(string path)    {        WWWForm form = new WWWForm();        form.AddField("api_key", "4ve3GloQbtbArqjKacQsIEoqlcVoT2Od");        form.AddField("api_secret", "Aiwt7vPwoBvyZfcoY3jt6A_LXEGgSRni");        //form.AddField("image_url", path);        form.AddField("image_base64", path);        StartCoroutine(SendPost("https://api-cn.faceplusplus.com/imagepp/v1/recognizetext", form));IEnumerator SendPost(string _url, WWWForm _wForm)    {        WWW postData = new WWW(_url, _wForm);        yield return postData;        if (postData.error != null)        {            Debug.Log(postData.error);            //ShowResult.SetActive(true);            //Btn_ShibieText.text = "認識";            //ShowResult.transform.Find("Text").GetComponent<Text>().text = "認識失敗!";            GameObject.Find("DebugText").GetComponent<Text>().text = postData.error;            //myTimer = 2.0f;        }        else        {            //Btn_ShibieText.text = "認識";            Debug.Log(postData.text);            //GameObject.Find("DebugText").GetComponent<Text>().text = postData.text;            JsonJieXi(postData.text);            //show.text = postData.text.ToString ();        }    }    }//Jsonの解析    void JsonJieXi(string str)    {           show.text = "";        JsonData jd = JsonMapper.ToObject(str);        Debug.Log(jd["result"].Count);        for (int i = 0; i < jd["result"].Count; i++)        {["child-objects"].Count; j++)                Debug.Log(jd["result"][i]["type"].ToString());                Debug.Log(jd["result"][i]["value"].ToString());            show.text = show.text + jd ["result"] [i] ["value"].ToString ();        }    }

//iosカメラのバイナリデータを取得してTestHttpSend関数に渡しますね。

    void callback_PickImage_With_Base64(string base64)    {           Texture2D tex = IOSAlbumCamera.Base64StringToTexture2D (base64);        rawImage.texture = tex;        ri.TestHttpSend (base64);    }