Skip to content

Commit d4731fb

Browse files
authored
Merge pull request #265948 from dargilco/dargilco/02-09-2024-java-python-updates-for-image-analysis-beta2
Java & Python public docs updates for beta.2 release of Image Analysis SDK
2 parents 4a8ca7d + 4f00c49 commit d4731fb

File tree

3 files changed

+26
-28
lines changed

3 files changed

+26
-28
lines changed

articles/ai-services/computer-vision/includes/how-to-guides/analyze-image-40-java.md

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -34,27 +34,23 @@ You can select an image by providing a publicly accessible image URL, or by read
3434

3535
### Image URL
3636

37-
Create a [URL](https://docs.oracle.com/javase/8/docs/api/java/net/URL.html) object for the image you want to analyze.
37+
Create an `imageUrl` string to hold the publicly accessible URL of the image you want to analyze.
3838

3939
[!code-java[](~/cognitive-services-quickstart-code/java/ComputerVision/4-0/ImageAnalysisHowTo.java?name=snippet_url)]
4040

41-
4241
### Image buffer
4342

44-
Alternatively, you can pass in the image as a data array using a **BinaryData** object. For example, read from a local image file you want to analyze.
43+
Alternatively, you can pass in the image as memory buffer using a [BinaryData](/java/api/com.azure.core.util.binarydata) object. For example, read from a local image file you want to analyze.
4544

4645
[!code-java[](~/cognitive-services-quickstart-code/java/ComputerVision/4-0/ImageAnalysisHowTo.java?name=snippet_file)]
4746

4847
## Select visual features
4948

5049
The Analysis 4.0 API gives you access to all of the service's image analysis features. Choose which operations to do based on your own use case. See the [overview](/azure/ai-services/computer-vision/overview-image-analysis) for a description of each feature. The example in this section adds all of the [available visual features](/java/api/com.azure.ai.vision.imageanalysis.models.visualfeatures), but for practical usage you likely need fewer.
5150

52-
5351
> [!IMPORTANT]
5452
> The visual features [Captions](/java/api/com.azure.ai.vision.imageanalysis.models.visualfeatures#com-azure-ai-vision-imageanalysis-models-visualfeatures-caption) and [DenseCaptions](/java/api/com.azure.ai.vision.imageanalysis.models.visualfeatures#com-azure-ai-vision-imageanalysis-models-visualfeatures-dense-captions) are only supported in the following Azure regions: East US, France Central, Korea Central, North Europe, Southeast Asia, West Europe, West US.
5553
56-
57-
5854
[!code-java[](~/cognitive-services-quickstart-code/java/ComputerVision/4-0/ImageAnalysisHowTo.java?name=snippet_features)]
5955

6056
<!--
@@ -67,7 +63,6 @@ To use a custom model, create the [ImageAnalysisOptions](/java/api/com.azure.ai.
6763
[!code-java[](~/azure-ai-vision-sdk/docs/learn.microsoft.com/java/image-analysis/custom-model/ImageAnalysis.java?name=model_name)]
6864
-->
6965

70-
7166
## Select analysis options
7267

7368
Use an [ImageAnalysisOptions](/java/api/com.azure.ai.vision.imageanalysis.models.imageanalysisoptions) object to specify various options for the Analyze API call.
@@ -78,16 +73,13 @@ Use an [ImageAnalysisOptions](/java/api/com.azure.ai.vision.imageanalysis.models
7873

7974
[!code-java[](~/cognitive-services-quickstart-code/java/ComputerVision/4-0/ImageAnalysisHowTo.java?name=snippet_options)]
8075

76+
## Call the analyzeFromUrl method
8177

78+
This section shows you how to make an analysis call to the service.
8279

80+
Call the [analyzeFromUrl](/java/api/com.azure.ai.vision.imageanalysis.imageanalysisclient#method-summary) method on the [ImageAnalysisClient](/java/api/com.azure.ai.vision.imageanalysis.imageanalysisclient) object, as shown here. The call is synchronous, and will block until the service returns the results or an error occurred. Alternatively, you can use a [ImageAnalysisAsyncClient](/java/api/com.azure.ai.vision.imageanalysis.imageanalysisasyncclient) object instead, and call its [analyzeFromUrl](/java/api/com.azure.ai.vision.imageanalysis.imageanalysisasyncclient#method-summary) method which is non-blocking.
8381

84-
## Call the Analyze API
85-
86-
This section shows you how to make an analysis call to the service.
87-
88-
Call the [analyze](/java/api/com.azure.ai.vision.imageanalysis.imageanalysisclient#method-summary) method on the [ImageAnalysisClient](/java/api/com.azure.ai.vision.imageanalysis.imageanalysisclient) object, as shown here. The call is synchronous, and will block until the service returns the results or an error occurred. Alternatively, you can use a [ImageAnalysisAsyncClient](/java/api/com.azure.ai.vision.imageanalysis.imageanalysisasyncclient) object instead, and call its [analyze](/java/api/com.azure.ai.vision.imageanalysis.imageanalysisasyncclient#method-summary) method which is non-blocking.
89-
90-
Use the input objects created in the above sections. To analyze from an image buffer instead of URL, replace `imageURL` in the method call with `imageData`.
82+
To analyze from an image buffer instead of URL, call the [analyze](/java/api/com.azure.ai.vision.imageanalysis.imageanalysisclient#method-summary) method instead, and pass in the `imageData` as the first argument.
9183

9284
[!code-java[](~/cognitive-services-quickstart-code/java/ComputerVision/4-0/ImageAnalysisHowTo.java?name=snippet_call)]
9385

@@ -104,7 +96,7 @@ The code is similar to the standard model case. The only difference is that resu
10496

10597
## Get results from the service
10698

107-
The following code shows you how to parse the results of the various Analyze operations.
99+
The following code shows you how to parse the results from the **analyzeFromUrl** and **analyze** operations.
108100

109101
[!code-java[](~/cognitive-services-quickstart-code/java/ComputerVision/4-0/ImageAnalysisHowTo.java?name=snippet_results)]
110102

articles/ai-services/computer-vision/includes/how-to-guides/analyze-image-40-python.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ You can use the following sample image URL.
4343

4444
### Image buffer
4545

46-
Alternatively, you can pass in the image as a data array. For example, read from a local image file you want to analyze.
46+
Alternatively, you can pass in the image as [bytes](https://docs.python.org/3/library/stdtypes.html#bytes-objects) object. For example, read from a local image file you want to analyze.
4747

4848
[!code-python[](~/cognitive-services-quickstart-code/python/ComputerVision/4-0/how-to.py?name=snippet_file)]
4949

@@ -63,9 +63,9 @@ To use a custom model, create the [ImageAnalysisOptions](/python/api/azure-ai-vi
6363
[!code-python[](~/azure-ai-vision-sdk/docs/learn.microsoft.com/python/image-analysis/custom-model/main.py?name=model_name)]
6464
-->
6565

66-
## Call the Analyze API with options
66+
## Call the analyze_from_url method with options
6767

68-
The following code calls the [Analyze API](/python/api/azure-ai-vision-imageanalysis/azure.ai.vision.imageanalysis.imageanalysisclient#azure-ai-vision-imageanalysis-imageanalysisclient-analyze) with the features you selected above and additional options, defined below. To analyze from an image buffer instead of URL, replace `image_url=image_url` in the method call with `image_data=image_data`.
68+
The following code calls the [analyze_from_url](/python/api/azure-ai-vision-imageanalysis/azure.ai.vision.imageanalysis.imageanalysisclient#azure-ai-vision-imageanalysis-imageanalysisclient-analyzefromurl) method on the client with the features you selected above and additional options, defined below. To analyze from an image buffer instead of URL, call the method [analyze](/python/api/azure-ai-vision-imageanalysis/azure.ai.vision.imageanalysis.imageanalysisclient#azure-ai-vision-imageanalysis-imageanalysisclient-analyze) instead, with `image_data=image_data` as the first argument.
6969

7070
[!code-python[](~/cognitive-services-quickstart-code/python/ComputerVision/4-0/how-to.py?name=snippet_call)]
7171

@@ -85,7 +85,7 @@ You can specify the language of the returned data. The language is optional, wit
8585

8686
## Get results from the service
8787

88-
The following code shows you how to parse the results of the various **analyze** operations.
88+
The following code shows you how to parse the results from the **analyze_from_url** or **analyze** operations.
8989

9090
[!code-python[](~/cognitive-services-quickstart-code/python/ComputerVision/4-0/how-to.py?name=snippet_result)]
9191

articles/ai-services/computer-vision/includes/quickstarts-sdk/image-analysis-java-sdk-40.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,31 +35,37 @@ Use the Image Analysis client SDK for Java to analyze an image to read text and
3535
Open a console window and create a new folder for your quickstart application.
3636

3737
1. Open a text editor and copy the following content to a new file. Save the file as `pom.xml` in your project directory
38-
<!-- [!INCLUDE][](https://raw.githubusercontent.com/Azure-Samples/azure-ai-vision-sdk/main/docs/learn.microsoft.com/java/image-analysis/quick-start/pom.xml)] -->
38+
<!-- [!INCLUDE][](https://raw.githubusercontent.com/Azure-Samples/cognitive-services-quickstart-code/master/java/ComputerVision/4-0/pom.xml)] -->
3939
```xml
4040
<project xmlns="http://maven.apache.org/POM/4.0.0"
41-
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
42-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
41+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
42+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4343
<modelVersion>4.0.0</modelVersion>
44-
<groupId>azure.ai.vision.imageanalysis.samples</groupId>
45-
<artifactId>image-analysis-quickstart</artifactId>
46-
<version>0.0</version>
44+
<groupId>com.example</groupId>
45+
<artifactId>my-application-name</artifactId>
46+
<version>1.0.0</version>
4747
<dependencies>
48+
<!-- https://mvnrepository.com/artifact/com.azure/azure-ai-vision-imageanalysis -->
4849
<dependency>
4950
<groupId>com.azure</groupId>
5051
<artifactId>azure-ai-vision-imageanalysis</artifactId>
51-
<version>1.0.0-beta.1</version>
52+
<version>1.0.0-beta.2</version>
5253
</dependency>
54+
<!-- https://mvnrepository.com/artifact/org.slf4j/slf4j-nop -->
55+
<!-- Optional: provide a slf4j implementation. Here we use a no-op implementation
56+
just to make the slf4j console spew warning go away. We can still use the internal
57+
logger in azure.core library. See
58+
https://github.com/Azure/azure-sdk-for-java/tree/main/sdk/vision/azure-ai-vision-imageanalysis#enable-http-requestresponse-logging -->
5359
<dependency>
5460
<groupId>org.slf4j</groupId>
5561
<artifactId>slf4j-nop</artifactId>
56-
<version>1.7.36</version>
62+
<version>1.7.36</version>
5763
</dependency>
5864
</dependencies>
5965
</project>
6066
```
6167

62-
1. Update the version value (`1.0.0-beta.1`) based on the latest available version of the [azure-ai-vision-imageanalysis](https://aka.ms/azsdk/image-analysis/package/maven) package in the Maven repository.
68+
1. Update the version value (`1.0.0-beta.2`) based on the latest available version of the [azure-ai-vision-imageanalysis](https://aka.ms/azsdk/image-analysis/package/maven) package in the Maven repository.
6369
1. Install the SDK and dependencies by running the following in the project directory:
6470
```console
6571
mvn clean dependency:copy-dependencies

0 commit comments

Comments
 (0)