Ver Fonte

fix key

ChingYi há 1 ano atrás
pai
commit
7fafbe0462
1 ficheiros alterados com 10 adições e 4 exclusões
  1. 10 4
      GoogleCloud/GoogleCloud.cs

+ 10 - 4
GoogleCloud/GoogleCloud.cs

@@ -16,7 +16,7 @@ namespace KdanCommon.GoogleCloud
 {
     public class GoogleCloud
     {
-        public static string VisionDomain = "https://cms.kdanmobile.com";
+        public static string VisionDomain = "https://vision.googleapis.com";
         private Uri _visionImagesUri = null;
 
         private HttpClient _httpClient = null;
@@ -26,7 +26,7 @@ namespace KdanCommon.GoogleCloud
         {
             _key = key;
             _httpClient = new HttpClient();
-            _visionImagesUri = new Uri($"{VisionDomain}/v1/images:annotate");
+            _visionImagesUri = new Uri($"{VisionDomain}/v1/images:annotate?key={_key}");
         }
 
         ~GoogleCloud()
@@ -34,13 +34,19 @@ namespace KdanCommon.GoogleCloud
             _httpClient.Dispose();
         }
 
-        private async Task<ImagesResponse> GetVisionImages(List<StorageFile> images)
+        // Document : https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate
+        // Image files sent to the Vision API should not exceed 20MB.
+        // Files exceeding 20MB generate an error.
+        // The Vision API does not resize files of this size. Reducing your file size can significantly improve throughput;
+        // however, be careful not to reduce image quality in the process.
+        // Note that the Vision API imposes a 10MB JSON request size limit;
+        // larger files should be hosted on Cloud Storage or on the web, rather than being passed as base64-encoded content in the JSON itself.
+        public async Task<ImagesResponse> GetVisionImages(List<StorageFile> images)
         {
             ImagesResponse response = null;
             var base64Contents = new List<string>();
             foreach (var image in images)
             {
-                // 最多16張圖
                 var base64Content = await Base64Helper.StorageFileToBase64(image);
                 base64Contents.Add(base64Content);
             }