快速入门:Azure AI 视觉 v3.2 GA Read

开始使用 Azure AI 视觉 Read REST API 或客户端库。 读取 API 提供 AI 算法,用于从图像中提取文本,并将其作为结构化字符串返回。 请按照以下步骤将包安装到应用程序中并试用基本任务的示例代码。

使用光学字符识别 (OCR) 客户端库读取图像中的印刷体文本和手写文本。 OCR 服务可以读取图像中的可见文本,并将其转换为字符流。 有关文本识别的详细信息,请参阅 OCR 概述。 本部分中的代码使用最新的 Azure AI 视觉包。

提示

还可以从本地图像提取文本。 请参阅 ComputerVisionClient 方法,例如 ReadInStreamAsync。 或者,请参阅 GitHub 上的示例代码,了解涉及本地图像的方案。

参考文档 | 库源代码 | 包 (NuGet) | 示例

先决条件

  • Azure 订阅 - 创建试用订阅

  • Visual Studio IDE 或最新版本的 .NET Core

  • Azure AI 视觉资源。 可以使用免费定价层 (F0) 试用该服务,然后再升级到付费层进行生产。

  • 从创建的资源获取密钥和终结点,以便将应用程序连接到 Azure AI 视觉服务。

    1. 部署 Azure 视觉资源后,选择“转到资源”。
    2. 在左侧导航菜单中,选择“密钥和终结点”。
    3. 复制其中一个密钥和终结点,稍后你将在本快速入门中使用它们。

创建环境变量

在此示例中,将凭据写入运行应用程序的本地计算机上的环境变量。

转到 Azure 门户。 如果在“先决条件”部分创建的资源部署成功,请选择“后续步骤”下的“转到资源”。 在“密钥和终结点”页的“资源管理”下,可以找到密钥和终结点。 你的资源密钥与你的 Azure 订阅 ID 不同。

提示

请不要直接在代码中包含密钥,并且绝不公开发布密钥。 有关 Azure Key Vault 等更多身份验证选项,请参阅 Azure AI 服务安全性一文。

若要为密钥和终结点设置环境变量,请打开控制台窗口,并按照操作系统和开发环境的说明进行操作。

  1. 若要设置 VISION_KEY 环境变量,请将 your-key 替换为资源的其中一个密钥。
  2. 若要设置 VISION_ENDPOINT 环境变量,请将 your-endpoint 替换为资源的终结点。
setx VISION_KEY your-key
setx VISION_ENDPOINT your-endpoint

添加环境变量后,可能需要重启任何正在运行的、将读取环境变量的程序(包括控制台窗口)。

读取印刷体文本和手写文本

  1. 创建一个新的 C# 应用程序。

    使用 Visual Studio,为“C#、Windows、控制台”创建“控制台应用 (.NET Framework)”项目。

    创建新项目后,安装客户端库:

    1. 在“解决方案资源管理器”中右键单击项目解决方案,然后选择“管理解决方案的 NuGet 包”。
    2. 在打开的包管理器中,选择“浏览”。 选择“包括预发行版”。
    3. 搜索并选择 Microsoft.Azure.CognitiveServices.Vision.ComputerVision
    4. 在“详细信息”对话框中,选择项目并选择最新的稳定版本。 然后选择“安装”。
  2. 在首选的编辑器或 IDE 中,从项目目录打开 Program.cs 文件。 将 Program.cs 的内容替换为以下代码。

using System;
using System.Collections.Generic;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision;
using Microsoft.Azure.CognitiveServices.Vision.ComputerVision.Models;
using System.Threading.Tasks;
using System.IO;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.Threading;
using System.Linq;

namespace ComputerVisionQuickstart
{
    class Program
    {
        // Add your Computer Vision key and endpoint
        static string key = Environment.GetEnvironmentVariable("VISION_KEY");
        static string endpoint = Environment.GetEnvironmentVariable("VISION_ENDPOINT");

        private const string READ_TEXT_URL_IMAGE = "https://raw.githubusercontent.com/Azure-Samples/cognitive-services-sample-data-files/master/ComputerVision/Images/printed_text.jpg";

        static void Main(string[] args)
        {
            Console.WriteLine("Azure Cognitive Services Computer Vision - .NET quickstart example");
            Console.WriteLine();

            ComputerVisionClient client = Authenticate(endpoint, key);

            // Extract text (OCR) from a URL image using the Read API
            ReadFileUrl(client, READ_TEXT_URL_IMAGE).Wait();
        }

        public static ComputerVisionClient Authenticate(string endpoint, string key)
        {
            ComputerVisionClient client =
              new ComputerVisionClient(new ApiKeyServiceClientCredentials(key))
              { Endpoint = endpoint };
            return client;
        }

        public static async Task ReadFileUrl(ComputerVisionClient client, string urlFile)
        {
            Console.WriteLine("----------------------------------------------------------");
            Console.WriteLine("READ FILE FROM URL");
            Console.WriteLine();

            // Read text from URL
            var textHeaders = await client.ReadAsync(urlFile);
            // After the request, get the operation location (operation ID)
            string operationLocation = textHeaders.OperationLocation;
            Thread.Sleep(2000);

            // Retrieve the URI where the extracted text will be stored from the Operation-Location header.
            // We only need the ID and not the full URL
            const int numberOfCharsInOperationId = 36;
            string operationId = operationLocation.Substring(operationLocation.Length - numberOfCharsInOperationId);

            // Extract the text
            ReadOperationResult results;
            Console.WriteLine($"Extracting text from URL file {Path.GetFileName(urlFile)}...");
            Console.WriteLine();
            do
            {
                results = await client.GetReadResultAsync(Guid.Parse(operationId));
            }
            while ((results.Status == OperationStatusCodes.Running ||
                results.Status == OperationStatusCodes.NotStarted));

            // Display the found text.
            Console.WriteLine();
            var textUrlFileResults = results.AnalyzeResult.ReadResults;
            foreach (ReadResult page in textUrlFileResults)
            {
                foreach (Line line in page.Lines)
                {
                    Console.WriteLine(line.Text);
                }
            }
            Console.WriteLine();
        }

    }
}
  1. 作为可选步骤,请参阅确定如何处理数据。 例如,若要显式指定最新版本的 GA 模型,请按如下所示编辑 ReadAsync 调用。 跳过参数或使用 "latest" 来利用最新的 GA 模型。

      // Read text from URL with a specific model version
      var textHeaders = await client.ReadAsync(urlFile,null,null,"2022-04-30");
    
  2. 运行该应用程序。

    • 从“调试”菜单中选择“启动调试”

输出

Azure AI Vision - .NET quickstart example

----------------------------------------------------------
READ FILE FROM URL

Extracting text from URL file printed_text.jpg...


Nutrition Facts Amount Per Serving
Serving size: 1 bar (40g)
Serving Per Package: 4
Total Fat 13g
Saturated Fat 1.5g
Amount Per Serving
Trans Fat 0g
Calories 190
Cholesterol 0mg
ories from Fat 110
Sodium 20mg
nt Daily Values are based on Vitamin A 50%
calorie diet.

清理资源

如果想要清理并移除 Azure AI 服务订阅,可以删除资源或资源组。 删除资源组同时也会删除与之相关联的任何其他资源。

后续步骤

本快速入门了解了安装 OCR 客户端库和使用读取 API 的方法。 接下来,详细了解读取 API 功能。

使用光学字符识别 (OCR) 客户端库读取远程图像中的印刷体文本和手写文本。 OCR 服务可以读取图像中的可见文本,并将其转换为字符流。 有关文本识别的详细信息,请参阅 OCR 概述

提示

还可以从本地图像读取文本。 请参阅 ComputerVisionClientOperationsMixin 方法,如 read_in_stream。 或者,请参阅 GitHub 上的示例代码,了解涉及本地图像的方案。

参考文档 | 库源代码 | 包 (PiPy) | 示例

先决条件

  • Azure 订阅 - 创建试用订阅

  • Python 3.x

  • 你的 Python 安装应包含 pip。 可以通过在命令行上运行 pip --version 来检查是否安装了 pip。 通过安装最新版本的 Python 获取 pip。

  • Azure AI 视觉资源。 可以使用免费定价层 (F0) 试用该服务,然后再升级到付费层进行生产。

  • 从创建的资源获取密钥和终结点,以便将应用程序连接到 Azure AI 视觉服务。

    1. 部署 Azure 视觉资源后,选择“转到资源”。
    2. 在左侧导航菜单中,选择“密钥和终结点”。
    3. 复制其中一个密钥和终结点,稍后你将在本快速入门中使用它们。

创建环境变量

在此示例中,将凭据写入运行应用程序的本地计算机上的环境变量。

转到 Azure 门户。 如果在“先决条件”部分创建的资源部署成功,请选择“后续步骤”下的“转到资源”。 在“密钥和终结点”页的“资源管理”下,可以找到密钥和终结点。 你的资源密钥与你的 Azure 订阅 ID 不同。

提示

请不要直接在代码中包含密钥,并且绝不公开发布密钥。 有关 Azure Key Vault 等更多身份验证选项,请参阅 Azure AI 服务安全性一文。

若要为密钥和终结点设置环境变量,请打开控制台窗口,并按照操作系统和开发环境的说明进行操作。

  1. 若要设置 VISION_KEY 环境变量,请将 your-key 替换为资源的其中一个密钥。
  2. 若要设置 VISION_ENDPOINT 环境变量,请将 your-endpoint 替换为资源的终结点。
setx VISION_KEY your-key
setx VISION_ENDPOINT your-endpoint

添加环境变量后,可能需要重启任何正在运行的、将读取环境变量的程序(包括控制台窗口)。

读取印刷体文本和手写文本

  1. 安装客户端库。

    在控制台窗口中,运行以下命令:

    pip install --upgrade azure-cognitiveservices-vision-computervision
    
  2. 安装 Pillow 库。

    pip install pillow
    
  3. 创建新的 Python 应用程序文件 quickstart-file.py。 然后在你喜欢的编辑器或 IDE 中打开该文件。

  4. 将 quickstart-file.py 的内容替换为以下代码。

from azure.cognitiveservices.vision.computervision import ComputerVisionClient
from azure.cognitiveservices.vision.computervision.models import OperationStatusCodes
from azure.cognitiveservices.vision.computervision.models import VisualFeatureTypes
from msrest.authentication import CognitiveServicesCredentials

from array import array
import os
from PIL import Image
import sys
import time

'''
Authenticate
Authenticates your credentials and creates a client.
'''
subscription_key = os.environ["VISION_KEY"]
endpoint = os.environ["VISION_ENDPOINT"]

computervision_client = ComputerVisionClient(endpoint, CognitiveServicesCredentials(subscription_key))
'''
END - Authenticate
'''

'''
OCR: Read File using the Read API, extract text - remote
This example will extract text in an image, then print results, line by line.
This API call can also extract handwriting style text (not shown).
'''
print("===== Read File - remote =====")
# Get an image with text
read_image_url = "https://raw.githubusercontent.com/MicrosoftDocs/azure-docs/master/articles/cognitive-services/Computer-vision/Images/readsample.jpg"

# Call API with URL and raw response (allows you to get the operation location)
read_response = computervision_client.read(read_image_url,  raw=True)

# Get the operation location (URL with an ID at the end) from the response
read_operation_location = read_response.headers["Operation-Location"]
# Grab the ID from the URL
operation_id = read_operation_location.split("/")[-1]

# Call the "GET" API and wait for it to retrieve the results 
while True:
    read_result = computervision_client.get_read_result(operation_id)
    if read_result.status not in ['notStarted', 'running']:
        break
    time.sleep(1)

# Print the detected text, line by line
if read_result.status == OperationStatusCodes.succeeded:
    for text_result in read_result.analyze_result.read_results:
        for line in text_result.lines:
            print(line.text)
            print(line.bounding_box)
print()
'''
END - Read File - remote
'''

print("End of Computer Vision quickstart.")

  1. 作为可选步骤,请参阅确定如何处理数据。 例如,若要显式指定最新版本的 GA 模型,请按如下所示编辑 read 语句。 跳过该参数或使用 "latest" 则会自动使用最新版本的 GA 模型。

       # Call API with URL and raw response (allows you to get the operation location)
       read_response = computervision_client.read(read_image_url,  raw=True, model_version="2022-04-30")
    
  2. 在快速入门文件中使用 python 命令运行应用程序。

    python quickstart-file.py
    

输出

===== Read File - remote =====
The quick brown fox jumps
[38.0, 650.0, 2572.0, 699.0, 2570.0, 854.0, 37.0, 815.0]
Over
[184.0, 1053.0, 508.0, 1044.0, 510.0, 1123.0, 184.0, 1128.0]
the lazy dog!
[639.0, 1011.0, 1976.0, 1026.0, 1974.0, 1158.0, 637.0, 1141.0]

End of Azure AI Vision quickstart.

清理资源

如果想要清理并移除 Azure AI 服务订阅,可以删除资源或资源组。 删除资源组同时也会删除与之相关联的任何其他资源。

后续步骤

本快速入门了解了安装 OCR 客户端库和使用读取 API 的方法。 接下来,详细了解读取 API 功能。

使用光学字符识别 (OCR) 客户端库,通过读取 API 来读取印刷体文本和手写文本。 OCR 服务可以读取图像中的可见文本,并将其转换为字符流。 有关文本识别的详细信息,请参阅 OCR 概述

提示

还可以从本地图像读取文本。 请参阅 ComputerVisionClient 方法,例如 readInStream。 或者,请参阅 GitHub 上的示例代码,了解涉及本地图像的方案。

参考文档 | 库源代码 | 包 (npm) | 示例

先决条件

  • Azure 订阅 - 创建试用订阅

  • 最新版本的 Node.js

  • Azure AI 视觉资源。 可以使用免费定价层 (F0) 试用该服务,然后再升级到付费层进行生产。

  • 从创建的资源获取密钥和终结点,以便将应用程序连接到 Azure AI 视觉服务。

    1. 部署 Azure 视觉资源后,选择“转到资源”。
    2. 在左侧导航菜单中,选择“密钥和终结点”。
    3. 复制其中一个密钥和终结点,稍后你将在本快速入门中使用它们。

创建环境变量

在此示例中,将凭据写入运行应用程序的本地计算机上的环境变量。

转到 Azure 门户。 如果在“先决条件”部分创建的资源部署成功,请选择“后续步骤”下的“转到资源”。 在“密钥和终结点”页的“资源管理”下,可以找到密钥和终结点。 你的资源密钥与你的 Azure 订阅 ID 不同。

提示

请不要直接在代码中包含密钥,并且绝不公开发布密钥。 有关 Azure Key Vault 等更多身份验证选项,请参阅 Azure AI 服务安全性一文。

若要为密钥和终结点设置环境变量,请打开控制台窗口,并按照操作系统和开发环境的说明进行操作。

  1. 若要设置 VISION_KEY 环境变量,请将 your-key 替换为资源的其中一个密钥。
  2. 若要设置 VISION_ENDPOINT 环境变量,请将 your-endpoint 替换为资源的终结点。
setx VISION_KEY your-key
setx VISION_ENDPOINT your-endpoint

添加环境变量后,可能需要重启任何正在运行的、将读取环境变量的程序(包括控制台窗口)。

读取印刷体文本和手写文本

创建新的 Node.js 应用程序。

  1. 在控制台窗口中,为你的应用创建一个新目录,然后导航到该目录。

    mkdir myapp
    cd myapp
    
  2. 运行 npm init 命令以使用 package.json 文件创建一个 node 应用程序。 对于任何提示,请选择 Enter

    npm init
    
  3. 若要安装客户端库,请安装 ms-rest-azure@azure/cognitiveservices-computervision npm 包:

    npm install ms-rest-azure
    npm install @azure/cognitiveservices-computervision
    
  4. 安装异步模块:

    npm install async
    

    应用的 package.json 文件将使用依赖项进行更新。

  5. 创建新文件 index.js,将其在文本编辑器中打开。

  6. 将以下代码粘贴到 index.js 文件中。

'use strict';

const async = require('async');
const fs = require('fs');
const https = require('https');
const path = require("path");
const createReadStream = require('fs').createReadStream
const sleep = require('util').promisify(setTimeout);
const ComputerVisionClient = require('@azure/cognitiveservices-computervision').ComputerVisionClient;
const ApiKeyCredentials = require('@azure/ms-rest-js').ApiKeyCredentials;
/**
 * AUTHENTICATE
 * This single client is used for all examples.
 */
const key = process.env.VISION_KEY;
const endpoint = process.env.VISION_ENDPOINT;

const computerVisionClient = new ComputerVisionClient(
  new ApiKeyCredentials({ inHeader: { 'Ocp-Apim-Subscription-Key': key } }), endpoint);
/**
 * END - Authenticate
 */

function computerVision() {
  async.series([
    async function () {

      /**
       * OCR: READ PRINTED & HANDWRITTEN TEXT WITH THE READ API
       * Extracts text from images using OCR (optical character recognition).
       */
      console.log('-------------------------------------------------');
      console.log('READ PRINTED, HANDWRITTEN TEXT AND PDF');
      console.log();

      // URL images containing printed and/or handwritten text. 
      // The URL can point to image files (.jpg/.png/.bmp) or multi-page files (.pdf, .tiff).
      const printedTextSampleURL = 'https://raw.githubusercontent.com/Azure-Samples/cognitive-services-sample-data-files/master/ComputerVision/Images/printed_text.jpg';

      // Recognize text in printed image from a URL
      console.log('Read printed text from URL...', printedTextSampleURL.split('/').pop());
      const printedResult = await readTextFromURL(computerVisionClient, printedTextSampleURL);
      printRecText(printedResult);

      // Perform read and await the result from URL
      async function readTextFromURL(client, url) {
        // To recognize text in a local image, replace client.read() with readTextInStream() as shown:
        let result = await client.read(url);
        // Operation ID is last path segment of operationLocation (a URL)
        let operation = result.operationLocation.split('/').slice(-1)[0];

        // Wait for read recognition to complete
        // result.status is initially undefined, since it's the result of read
        while (result.status !== "succeeded") { await sleep(1000); result = await client.getReadResult(operation); }
        return result.analyzeResult.readResults; // Return the first page of result. Replace [0] with the desired page if this is a multi-page file such as .pdf or .tiff.
      }

      // Prints all text from Read result
      function printRecText(readResults) {
        console.log('Recognized text:');
        for (const page in readResults) {
          if (readResults.length > 1) {
            console.log(`==== Page: ${page}`);
          }
          const result = readResults[page];
          if (result.lines.length) {
            for (const line of result.lines) {
              console.log(line.words.map(w => w.text).join(' '));
            }
          }
          else { console.log('No recognized text.'); }
        }
      }

      /**
       * 
       * Download the specified file in the URL to the current local folder
       * 
       */
      function downloadFilesToLocal(url, localFileName) {
        return new Promise((resolve, reject) => {
          console.log('--- Downloading file to local directory from: ' + url);
          const request = https.request(url, (res) => {
            if (res.statusCode !== 200) {
              console.log(`Download sample file failed. Status code: ${res.statusCode}, Message: ${res.statusMessage}`);
              reject();
            }
            var data = [];
            res.on('data', (chunk) => {
              data.push(chunk);
            });
            res.on('end', () => {
              console.log('   ... Downloaded successfully');
              fs.writeFileSync(localFileName, Buffer.concat(data));
              resolve();
            });
          });
          request.on('error', function (e) {
            console.log(e.message);
            reject();
          });
          request.end();
        });
      }

      /**
       * END - Recognize Printed & Handwritten Text
       */
      console.log();
      console.log('-------------------------------------------------');
      console.log('End of quickstart.');

    },
    function () {
      return new Promise((resolve) => {
        resolve();
      })
    }
  ], (err) => {
    throw (err);
  });
}

computerVision();
  1. 作为可选步骤,请参阅确定如何处理数据。 例如,若要显式指定最新版本的 GA 模型,请按如下所示编辑 read 语句。 跳过该参数或使用 "latest" 则会自动使用最新版本的 GA 模型。

      let result = await client.read(url,{modelVersion:"2022-04-30"});
    
  2. 在快速入门文件中使用 node 命令运行应用程序。

    node index.js
    

输出

-------------------------------------------------
READ PRINTED, HANDWRITTEN TEXT AND PDF

Read printed text from URL... printed_text.jpg
Recognized text:
Nutrition Facts Amount Per Serving
Serving size: 1 bar (40g)
Serving Per Package: 4
Total Fat 13g
Saturated Fat 1.5g
Amount Per Serving
Trans Fat 0g
Calories 190
Cholesterol 0mg
ories from Fat 110
Sodium 20mg
nt Daily Values are based on Vitamin A 50%
calorie diet.

-------------------------------------------------
End of quickstart.

清理资源

如果想要清理并移除 Azure AI 服务订阅,可以删除资源或资源组。 删除资源组同时也会删除与之相关联的任何其他资源。

后续步骤

本快速入门了解了安装 OCR 客户端库和使用读取 API 的方法。 接下来,详细了解读取 API 功能。

使用光学字符识别 (OCR) REST API 读取印刷体文本和手写文本。

注意

此快速入门使用 cURL 命令来调用 REST API。 也可以使用编程语言调用 REST API。 请参阅 GitHub 示例,查看 C#PythonJavaJavaScript 的相关示例。

先决条件

  • Azure 订阅 - 创建试用订阅

  • 已安装 cURL

  • Azure AI 视觉资源。 可以使用免费定价层 (F0) 试用该服务,然后再升级到付费层进行生产。

  • 从创建的资源获取密钥和终结点,以便将应用程序连接到 Azure AI 视觉服务。

    1. 部署 Azure 视觉资源后,选择“转到资源”。
    2. 在左侧导航菜单中,选择“密钥和终结点”。
    3. 复制其中一个密钥和终结点,稍后你将在本快速入门中使用它们。

读取印刷体文本和手写文本

光学字符识别 (OCR) 服务可以提取图像或文档中的可见文本,并将其转换为字符流。 有关文本提取的详细信息,请参阅 OCR 概述

调用读取 API

要创建和运行示例,请执行以下步骤:

  1. 将以下命令复制到文本编辑器中。

  2. 必要时在命令中进行如下更改:

    1. <key> 的值替换为你的密钥。
    2. 将请求 URL 的第一部分 (https://api.cognitive.azure.cn/) 替换为你自己的终结点 URL 中的文本。

      注意

      2019 年 7 月 1 日之后创建的新资源将使用自定义子域名。 有关详细信息和区域终结点的完整列表,请参阅 Azure AI 服务的自定义子域名

    3. (可选)将请求正文中的图像 URL (https://learn.microsoft.com/azure/ai-services/computer-vision/media/quickstarts/presentation.png) 更改为要分析的其他图像的 URL。
  3. 打开命令提示符窗口。

  4. 将文本编辑器中的命令粘贴到命令提示符窗口,然后运行命令。

curl -v -X POST "https://chinaeast2.api.cognitive.azure.cn/vision/v3.2/read/analyze" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: <subscription key>" --data-ascii "{'url':'https://learn.microsoft.com/azure/ai-services/computer-vision/media/quickstarts/presentation.png'}"

响应包含一个 Operation-Location 标头,其值为唯一的 URL。 使用此 URL 可以查询读取操作的结果。 该 URL 在 48 小时后过期。

(可选)指定模型版本

作为可选步骤,请参阅确定如何处理数据。 例如,若要显式指定最新版本的 GA 模型,请使用 model-version=2022-04-30 作为参数。 跳过该参数或使用 model-version=latest 则会自动使用最新的 GA 模型。

curl -v -X POST "https://chinaeast2.api.cognitive.azure.cn/vision/v3.2/read/analyze?model-version=2022-04-30" -H "Content-Type: application/json" -H "Ocp-Apim-Subscription-Key: <subscription key>" --data-ascii "{'url':'https://learn.microsoft.com/azure/ai-services/computer-vision/media/quickstarts/presentation.png'}"

获取读取结果

  1. 将以下命令复制到文本编辑器中。

  2. 将该 URL 替换为在之前过程中复制的 Operation-Location 值。

  3. <key> 的值替换为你的密钥。

  4. 打开控制台窗口。

  5. 将文本编辑器中的命令粘贴到控制台窗口,然后运行命令。

    curl -v -X GET "https://chinaeast2.api.cognitive.azure.cn/vision/v3.2/read/analyzeResults/{operationId}" -H "Ocp-Apim-Subscription-Key: {key}" --data-ascii "{body}" 
    

检查响应

成功的响应以 JSON 格式返回。 示例应用程序会在控制台窗口中分析和显示成功响应,如下例所示:

{
  "status": "succeeded",
  "createdDateTime": "2021-04-08T21:56:17.6819115+00:00",
  "lastUpdatedDateTime": "2021-04-08T21:56:18.4161316+00:00",
  "analyzeResult": {
    "version": "3.2",
    "readResults": [
      {
        "page": 1,
        "angle": 0,
        "width": 338,
        "height": 479,
        "unit": "pixel",
        "lines": [
          {
            "boundingBox": [
              25,
              14,
              318,
              14,
              318,
              59,
              25,
              59
            ],
            "text": "NOTHING",
            "appearance": {
              "style": {
                "name": "other",
                "confidence": 0.971
              }
            },
            "words": [
              {
                "boundingBox": [
                  27,
                  15,
                  294,
                  15,
                  294,
                  60,
                  27,
                  60
                ],
                "text": "NOTHING",
                "confidence": 0.994
              }
            ]
          }
        ]
      }
    ]
  }
}

清理资源

如果想要清理并移除 Azure AI 服务订阅,可以删除资源或资源组。 删除资源组同时也会删除与之相关联的任何其他资源。

后续步骤

在本快速入门中,你学习了如何调用读取 REST API。 接下来,详细了解读取 API 功能。