你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Detect Objects - Detect Objects
Performs object detection on the specified image. Two input methods are supported -- (1) Uploading an image or (2) specifying an image URL. A successful response will be returned in JSON. If the request failed, the response will contain an error code and a message to help understand what went wrong.
POST {Endpoint}/vision/v3.1/detect
URI Parameters
Name | In | Required | Type | Description |
---|---|---|---|---|
Endpoint
|
path | True |
string |
Supported Cognitive Services endpoints. |
Request Header
Name | Required | Type | Description |
---|---|---|---|
Ocp-Apim-Subscription-Key | True |
string |
Request Body
Name | Required | Type | Description |
---|---|---|---|
url | True |
string |
Publicly reachable URL of an image. |
Responses
Name | Type | Description |
---|---|---|
200 OK |
The response include the detected objects in JSON format. |
|
Other Status Codes |
Error response. |
Security
Ocp-Apim-Subscription-Key
Type:
apiKey
In:
header
Examples
Successful DetectObjects request
Sample Request
POST https://westus.api.cognitive.microsoft.com/vision/v3.1/detect
{
"url": "{url}"
}
Sample Response
{
"objects": [
{
"rectangle": {
"x": 0,
"y": 0,
"w": 50,
"h": 50
},
"object": "tree",
"confidence": 0.9,
"parent": {
"object": "plant",
"confidence": 0.95
}
}
],
"requestId": "1ad0e45e-b7b4-4be3-8042-53be96103337",
"metadata": {
"width": 100,
"height": 100,
"format": "Jpeg"
}
}
Definitions
Name | Description |
---|---|
Bounding |
A bounding box for an area inside an image. |
Computer |
Details about the API request error. |
Computer |
The error code. |
Detected |
An object detected in an image. |
Detect |
Result of a DetectImage call. |
Image |
Image metadata. |
Image |
|
Object |
An object detected inside an image. |
BoundingRect
A bounding box for an area inside an image.
Name | Type | Description |
---|---|---|
h |
integer |
Height measured from the top-left point of the area, in pixels. |
w |
integer |
Width measured from the top-left point of the area, in pixels. |
x |
integer |
X-coordinate of the top left point of the area, in pixels. |
y |
integer |
Y-coordinate of the top left point of the area, in pixels. |
ComputerVisionError
Details about the API request error.
Name | Type | Description |
---|---|---|
code |
The error code. |
|
message |
string |
A message explaining the error reported by the service. |
requestId |
string |
A unique request identifier. |
ComputerVisionErrorCodes
The error code.
Name | Type | Description |
---|---|---|
BadArgument |
string |
|
CancelledRequest |
string |
|
DetectFaceError |
string |
|
FailedToProcess |
string |
|
InternalServerError |
string |
|
InvalidDetails |
string |
|
InvalidImageFormat |
string |
|
InvalidImageSize |
string |
|
InvalidImageUrl |
string |
|
InvalidModel |
string |
|
InvalidThumbnailSize |
string |
|
NotSupportedFeature |
string |
|
NotSupportedImage |
string |
|
NotSupportedLanguage |
string |
|
NotSupportedVisualFeature |
string |
|
StorageException |
string |
|
Timeout |
string |
|
Unspecified |
string |
|
UnsupportedMediaType |
string |
DetectedObject
An object detected in an image.
Name | Type | Description |
---|---|---|
confidence |
number |
Confidence score of having observed the object in the image, as a value ranging from 0 to 1. |
object |
string |
Label for the object. |
parent |
The parent object, from a taxonomy perspective. The parent object is a more generic form of this object. For example, a 'bulldog' would have a parent of 'dog'. |
|
rectangle |
Approximate location of the detected object. |
DetectResult
Result of a DetectImage call.
Name | Type | Description |
---|---|---|
metadata |
Image metadata. |
|
objects |
An array of detected objects. |
|
requestId |
string |
Id of the REST API request. |
ImageMetadata
Image metadata.
Name | Type | Description |
---|---|---|
format |
string |
Image format. |
height |
integer |
Image height, in pixels. |
width |
integer |
Image width, in pixels. |
ImageUrl
Name | Type | Description |
---|---|---|
url |
string |
Publicly reachable URL of an image. |
ObjectHierarchy
An object detected inside an image.
Name | Type | Description |
---|---|---|
confidence |
number |
Confidence score of having observed the object in the image, as a value ranging from 0 to 1. |
object |
string |
Label for the object. |
parent |
The parent object, from a taxonomy perspective. The parent object is a more generic form of this object. For example, a 'bulldog' would have a parent of 'dog'. |