コード例 #1
0
ファイル: VisionRequestBody.cs プロジェクト: DiUS/3DiUS
    public static VisionRequestBody Default(byte[] content = null)
    {
        VisionImage image = new VisionImage();
        if (content != null)
        {
            image.EncodeContent(content);
        }

        VisionFeature feature = new VisionFeature();
        feature.type = Enum.GetName(typeof(VisionFeature.FeatureType), 0);

        VisionRequest request = new VisionRequest();
        request.features = new VisionFeature[] { feature };
        request.image = image;

        VisionRequestBody body = new VisionRequestBody();
        body.requests = new VisionRequest[] { request};

        return body;
    }
コード例 #2
0
ファイル: TakePicture.cs プロジェクト: DiUS/3DiUS
    void CallGoogleVisionApi(VisionRequestBody request, System.Action callback)
    {
        Dictionary<string, string> headers = new Dictionary<string, string>();
        headers.Add("Content-Type", "application/json; charset=UTF-8");

        string jsonData = JsonUtility.ToJson(request, false);
        if (jsonData != string.Empty)
        {
            string key = "AIzaSyCEBl4MaJWO_-0ROar1pfyyhC7V3tizuNA";
            string url = "https://vision.googleapis.com/v1/images:annotate?key=" + key;

            byte[] postData = System.Text.Encoding.Default.GetBytes(jsonData);
            Debug.Log(jsonData.ToString());
            WWW www = new WWW(url, postData, headers);
            StartCoroutine(SendPicture(www, callback));
        }
    }