使用计算机视觉检测图像类型Detecting image types with Computer Vision

利用分析图像 API,计算机视觉可以分析图像的内容类型,指示图像是剪贴画还是线条图。With the Analyze Image API, Computer Vision can analyze the content type of images, indicating whether an image is clip art or a line drawing.

检测剪贴画Detecting clip art

计算机视觉可分析图像,并通过 0-3 的量表对图像为剪贴画的可能性进行评级,如下表中所示。Computer Vision analyzes an image and rates the likelihood of the image being clip art on a scale of 0 to 3, as described in the following table.

Value 含义Meaning
00 非剪贴画Non-clip-art
11 不明确Ambiguous
22 正常剪贴画Normal-clip-art
33 良好剪贴画Good-clip-art

剪贴画检测示例Clip art detection examples

以下 JSON 响应说明了计算机视觉将图像评级为剪贴画的可能性时返回的内容。The following JSON responses illustrates what Computer Vision returns when rating the likelihood of the example images being clip art.

一片奶酪的剪贴画

{
    "imageType": {
        "clipArtType": 3,
        "lineDrawingType": 0
    },
    "requestId": "88c48d8c-80f3-449f-878f-6947f3b35a27",
    "metadata": {
        "height": 225,
        "width": 300,
        "format": "Jpeg"
    }
}

一座蓝色的房子和前院

{
    "imageType": {
        "clipArtType": 0,
        "lineDrawingType": 0
    },
    "requestId": "a9c8490a-2740-4e04-923b-e8f4830d0e47",
    "metadata": {
        "height": 200,
        "width": 300,
        "format": "Jpeg"
    }
}

检测线条图Detecting line drawings

计算机视觉分析图像并返回一个布尔值,该值指示图像是否为线条图。Computer Vision analyzes an image and returns a boolean value indicating whether the image is a line drawing.

线条图检测示例Line drawing detection examples

以下 JSON 响应说明了计算机视觉指示图像是否为线条图时返回的内容。The following JSON responses illustrates what Computer Vision returns when indicating whether the example images are line drawings.

狮子的线描图像

{
    "imageType": {
        "clipArtType": 2,
        "lineDrawingType": 1
    },
    "requestId": "6442dc22-476a-41c4-aa3d-9ceb15172f01",
    "metadata": {
        "height": 268,
        "width": 300,
        "format": "Jpeg"
    }
}

具有绿色背景的白色花卉

{
    "imageType": {
        "clipArtType": 0,
        "lineDrawingType": 0
    },
    "requestId": "98437d65-1b05-4ab7-b439-7098b5dfdcbf",
    "metadata": {
        "height": 200,
        "width": 300,
        "format": "Jpeg"
    }
}

使用 APIUse the API

图像类型检测功能属于分析图像 API。The image type detection feature is part of the Analyze Image API. 可以通过本机 SDK 或 REST 调用来调用此 API。You can call this API through a native SDK or through REST calls. ImageType 包括在 visualFeatures 查询参数中。Include ImageType in the visualFeatures query parameter. 然后,在获取完整 JSON 响应时,就只需分析 "imageType" 部分内容的字符串。Then, when you get the full JSON response, simply parse the string for the contents of the "imageType" section.