Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
In this quickstart, you analyze a locally stored image to extract visual features by using Computer Vision's REST API. With the Analyze Image method, you can extract visual features based on image content.
If you don't have an Azure subscription, create a Trial before you begin.
- You must have cURL.
- You must have a subscription key for Computer Vision. You can follow the instructions in Create a Cognitive Services account to subscribe to Computer Vision and get your key.
To create and run the sample, do the following steps:
- Copy the following command into a text editor.
- Make the following changes in the command where needed:
- Replace the value of
<subscriptionKey>
with your subscription key. - Replace the request URL (
https://api.cognitive.azure.cn/vision/v2.0/analyze
) with the endpoint URL for the Analyze Image method from the Azure region where you obtained your subscription keys, if necessary. - Replace the value of
<localImage>
with the full path and file name of the image to be analyzed. For example,@C:/Pictures/ImageToAnalyze.jpg
. - Optionally, change the language parameter of the request URL (
language=en
) to use a different supported language.
- Replace the value of
- Open a command prompt window.
- Paste the command from the text editor into the command prompt window, and then run the command.
curl -H "Ocp-Apim-Subscription-Key: <Subscription Key>" -H "Content-Type: application/octet-stream" "https://api.cognitive.azure.cn/vision/v2.0/analyze?visualFeatures=Categories,Description&details=Landmarks&language=en" --data-binary "<localImage>"
A successful response is returned in JSON. The sample application parses and displays a successful response in the command prompt window, similar to the following example:
{
"categories": [
{
"name": "outdoor_water",
"score": 0.9921875,
"detail": {
"landmarks": []
}
}
],
"description": {
"tags": [
"nature",
"water",
"waterfall",
"outdoor",
"rock",
"mountain",
"rocky",
"grass",
"hill",
"covered",
"hillside",
"standing",
"side",
"group",
"walking",
"white",
"man",
"large",
"snow",
"grazing",
"forest",
"slope",
"herd",
"river",
"giraffe",
"field"
],
"captions": [
{
"text": "a large waterfall over a rocky cliff",
"confidence": 0.916458423253597
}
]
},
"requestId": "b6e33879-abb2-43a0-a96e-02cb5ae0b795",
"metadata": {
"height": 959,
"width": 1280,
"format": "Jpeg"
}
}
Explore the Computer Vision API used to analyze an image, detect celebrities and landmarks, create a thumbnail, and extract printed and handwritten text. To rapidly experiment with the Computer Vision API, try the Open API testing console.