Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# google vision-在c中从google.cloud.vision.v1.entity anotation转换为json#_C#_Json_Ocr_Google Cloud Vision_Google Vision - Fatal编程技术网

C# google vision-在c中从google.cloud.vision.v1.entity anotation转换为json#

C# google vision-在c中从google.cloud.vision.v1.entity anotation转换为json#,c#,json,ocr,google-cloud-vision,google-vision,C#,Json,Ocr,Google Cloud Vision,Google Vision,我正在尝试将google.cloud.vision响应转换为C#中的JSON。 我将图片发送到我的webapi,然后我将其发送到谷歌的ocr- 返回的响应是google vision对象,如何将其转换为JSON 我的代码: [Route("getPrice")] public int GetPrice() { // Specify a Google Cloud Storage uri for the im

我正在尝试将google.cloud.vision响应转换为C#中的JSON。 我将图片发送到我的webapi,然后我将其发送到谷歌的ocr-

返回的响应是google vision对象,如何将其转换为JSON

我的代码:

        [Route("getPrice")]
        public int GetPrice()
        {
            // Specify a Google Cloud Storage uri for the image
            // or a publicly accessible HTTP or HTTPS uri.
            var image = Image.FromUri("gs://tasmi/11.png");
            var client = ImageAnnotatorClient.Create();
            var response = client.DetectText(image);
            // I tried It ,but It's not work well
            //BatchAnnotateImagesResponse.Parser.ToString();
            BatchAnnotateImagesResponse.Parser.ParseJson(response)
            using (StreamWriter writer = new StreamWriter(fullPath))
            {
                writer.Write(response);
            }
            foreach (var annotation in response)
            {
                if (annotation.Description != null)
                    Console.WriteLine(annotation.Description);
            }
            return 0;
        }


如果我正确理解了您的问题,您希望保存响应

为什么不把它保存在一个列表中呢

如:

        var listResponse = new List<--type of annotation-->();
        foreach (var annotation in response)
        {
            if (annotation.Description != null)
                listResponse.Add(annotation.Description);
        }
var listResponse=new List();
foreach(响应中的var注释)
{
if(annotation.Description!=null)
添加(annotation.Description);
}
另一种方法是使用
Newtonsoft.JSON.Linq

有关详细信息,请参见,

如果我正确理解了您的问题,您希望保存答复

为什么不把它保存在一个列表中呢

如:

        var listResponse = new List<--type of annotation-->();
        foreach (var annotation in response)
        {
            if (annotation.Description != null)
                listResponse.Add(annotation.Description);
        }
var listResponse=new List();
foreach(响应中的var注释)
{
if(annotation.Description!=null)
添加(annotation.Description);
}
另一种方法是使用
Newtonsoft.JSON.Linq

有关更多详细信息,

在@sari有类似的东西是的,那是链接在@sari有类似的东西是的,那是链接