Method: files.asyncBatchAnnotate

針對一般檔案清單 (例如 PDF 檔案) 執行非同步圖片偵測和註解,這些檔案可能包含多個頁面,且每個頁面可能包含多個圖片。您可以透過 google.longrunning.Operations 介面擷取進度和結果。Operation.metadata 包含 OperationMetadata (中繼資料)。Operation.response 包含 AsyncBatchAnnotateFilesResponse (結果)。

HTTP 要求

POST https://vision.googleapis.com/v1p3beta1/files:asyncBatchAnnotate

這個網址使用 gRPC 轉碼語法。

要求主體

要求主體包含下列結構的資料:

JSON 表示法
{
  "requests": [
    {
      object(AsyncAnnotateFileRequest)
    }
  ]
}
欄位
requests[]

object(AsyncAnnotateFileRequest)

此批次的個別非同步檔案註解要求。

回應主體

如果成功,回應主體會包含 Operation 的執行個體。

授權範圍

需要下列其中一種 OAuth 範圍:

  • https://www.googleapis.com/auth/cloud-platform
  • https://www.googleapis.com/auth/cloud-vision

詳情請參閱驗證總覽一文。

AsyncAnnotateFileRequest

離線檔案註解要求。

JSON 表示法
{
  "inputConfig": {
    object(InputConfig)
  },
  "features": [
    {
      object(Feature)
    }
  ],
  "imageContext": {
    object(ImageContext)
  },
  "outputConfig": {
    object(OutputConfig)
  }
}
欄位
inputConfig

object(InputConfig)

這是必要旗標,輸入檔案的相關資訊。

features[]

object(Feature)

這是必要旗標,要求的功能。

imageContext

object(ImageContext)

檔案中可能隨附的其他背景資訊。

outputConfig

object(OutputConfig)

這是必要旗標,所需的輸出位置和中繼資料 (例如格式)。

InputConfig

所需的輸入位置和中繼資料。

JSON 表示法
{
  "gcsSource": {
    object(GcsSource)
  },
  "mimeType": string
}
欄位
gcsSource

object(GcsSource)

要讀取輸入內容的 Google Cloud Storage 位置。

mimeType

string

檔案類型。目前僅支援「application/pdf」和「image/tiff」。而且不支援萬用字元。

GcsSource

系統讀取輸入內容的 Google Cloud Storage 位置。

JSON 表示法
{
  "uri": string
}
欄位
uri

string

輸入檔案的 Google Cloud Storage URI。這必須是 Google Cloud Storage 物件。目前不支援萬用字元。

OutputConfig

所需的輸出位置和中繼資料。

JSON 表示法
{
  "gcsDestination": {
    object(GcsDestination)
  },
  "batchSize": number
}
欄位
gcsDestination

object(GcsDestination)

要寫入輸出內容的 Google Cloud Storage 位置。

batchSize

number

在 Google Cloud Storage 的每個輸出 JSON 檔案中,回應 proto 的數量上限。有效範圍為 [1, 100]。如未指定,則預設值為 20。

舉例來說,如果 PDF 檔案有 100 頁,系統就會產生 100 個回應原型。如果 batchSize = 20,則會在前置字串 gcsDestination.uri 下寫入 5 個 JSON 檔案,每個檔案都包含 20 個回應原型。

目前 batchSize 只適用於 GcsDestination,日後可能會支援其他輸出設定。

GcsDestination

輸出內容的寫入位置 (Google Cloud Storage)。

JSON 表示法
{
  "uri": string
}
欄位
uri

string

結果的儲存位置 (Google Cloud Storage URI)。結果會以 JSON 格式顯示,並在前方加上對應的輸入 URI。這個欄位可代表單一檔案,或多個輸出項目的前置字串。前置字串結尾必須為 /

範例:

如果有多個輸出項目,每個回應仍為 AnnotateFileResponse,且每個回應都包含 AnnotateImageResponse 完整清單的某些子集。舉例來說,如果輸出 JSON 過大,並溢位至多個分割檔案,就可能會產生多個輸出內容。