Class ImageAnalysisClient
java.lang.Object
com.azure.ai.vision.imageanalysis.ImageAnalysisClient
Initializes a new instance of the synchronous ImageAnalysisClient type.
//
// Create a synchronous Image Analysis client.
//
ImageAnalysisClient client = new ImageAnalysisClientBuilder()
.endpoint(endpoint)
.credential(new KeyCredential(key))
.buildClient();
-
Method Summary
Modifier and TypeMethodDescriptionanalyze(com.azure.core.util.BinaryData imageData, List<VisualFeatures> visualFeatures, ImageAnalysisOptions options) Performs a single Image Analysis operation on a given image buffer.analyzeFromUrl(String imageUrl, List<VisualFeatures> visualFeatures, ImageAnalysisOptions options) Performs a single Image Analysis operation on a give image URL.com.azure.core.http.rest.Response<ImageAnalysisResult>analyzeFromUrlWithResponse(String imageUrl, List<VisualFeatures> visualFeatures, ImageAnalysisOptions imageAnalysisOptions, com.azure.core.http.rest.RequestOptions requestOptions) Performs a single Image Analysis operation on a given image URL, while allowing customization of the HTTP request and access to HTTP request and response details.com.azure.core.http.rest.Response<ImageAnalysisResult>analyzeWithResponse(com.azure.core.util.BinaryData imageData, List<VisualFeatures> visualFeatures, ImageAnalysisOptions imageAnalysisOptions, com.azure.core.http.rest.RequestOptions requestOptions) Performs a single Image Analysis operation on a given image buffer, while allowing customization of the HTTP request and access to HTTP request and response details.
-
Method Details
-
analyzeFromUrl
public ImageAnalysisResult analyzeFromUrl(String imageUrl, List<VisualFeatures> visualFeatures, ImageAnalysisOptions options) Performs a single Image Analysis operation on a give image URL.- Parameters:
imageUrl- The publicly accessible URL of the image to analyze.visualFeatures- A list of visual features to analyze. Seven visual features are supported: Caption, DenseCaptions, Read (OCR), Tags, Objects, SmartCrops, and People. At least one visual feature must be specified.options- Additional image analysis options.- Returns:
- represents the outcome of an Image Analysis operation.
// // Synchronous analysis of an image file (https://aka.ms/azsdk/image-analysis/sample.jpg), // using all visual features, with all options set. You will likely need fewer visual features // and only some (or no) options set. // ImageAnalysisOptions options = new ImageAnalysisOptions() .setLanguage("en") .setGenderNeutralCaption(true) .setSmartCropsAspectRatios(Arrays.asList(0.9, 1.33)) .setModelVersion("latest"); ImageAnalysisResult result = client.analyzeFromUrl( "https://aka.ms/azsdk/image-analysis/sample.jpg", Arrays.asList( VisualFeatures.SMART_CROPS, VisualFeatures.CAPTION, VisualFeatures.DENSE_CAPTIONS, VisualFeatures.OBJECTS, VisualFeatures.PEOPLE, VisualFeatures.READ, VisualFeatures.TAGS), options); - Throws:
IllegalArgumentException- thrown if parameters fail the validation.com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.RuntimeException- all other wrapped checked exceptions if the request fails to be sent.
-
analyze
public ImageAnalysisResult analyze(com.azure.core.util.BinaryData imageData, List<VisualFeatures> visualFeatures, ImageAnalysisOptions options) Performs a single Image Analysis operation on a given image buffer.- Parameters:
imageData- The image to analyze.visualFeatures- A list of visual features to analyze. Seven visual features are supported: Caption, DenseCaptions, Read (OCR), Tags, Objects, SmartCrops, and People. At least one visual feature must be specified.options- Additional image analysis options.- Returns:
- represents the outcome of an Image Analysis operation.
// // Synchronous analysis of an image file (sample.jpg), using all visual features, // with all options set. You will likely need fewer visual features and only // some (or no) options set. // ImageAnalysisOptions options = new ImageAnalysisOptions() .setLanguage("en") .setGenderNeutralCaption(true) .setSmartCropsAspectRatios(Arrays.asList(0.9, 1.33)) .setModelVersion("latest"); ImageAnalysisResult result = client.analyze( BinaryData.fromFile(new File("sample.jpg").toPath()), Arrays.asList( VisualFeatures.SMART_CROPS, VisualFeatures.CAPTION, VisualFeatures.DENSE_CAPTIONS, VisualFeatures.OBJECTS, VisualFeatures.PEOPLE, VisualFeatures.READ, VisualFeatures.TAGS), options); - Throws:
IllegalArgumentException- thrown if parameters fail the validation.com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.RuntimeException- all other wrapped checked exceptions if the request fails to be sent.
-
analyzeFromUrlWithResponse
public com.azure.core.http.rest.Response<ImageAnalysisResult> analyzeFromUrlWithResponse(String imageUrl, List<VisualFeatures> visualFeatures, ImageAnalysisOptions imageAnalysisOptions, com.azure.core.http.rest.RequestOptions requestOptions) Performs a single Image Analysis operation on a given image URL, while allowing customization of the HTTP request and access to HTTP request and response details. This is not commonly used.- Parameters:
imageUrl- The publicly accessible URL of the image to analyze.visualFeatures- A list of visual features to analyze. Seven visual features are supported: Caption, DenseCaptions, Read (OCR), Tags, Objects, SmartCrops, and People. At least one visual feature must be specified.imageAnalysisOptions- Additional image analysis options.requestOptions- The options to configure the HTTP request before the HTTP client sends it.- Returns:
- represents the outcome of an Image Analysis operation along with Response.
- Throws:
IllegalArgumentException- thrown if parameters fail the validation.com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.RuntimeException- all other wrapped checked exceptions if the request fails to be sent.
-
analyzeWithResponse
public com.azure.core.http.rest.Response<ImageAnalysisResult> analyzeWithResponse(com.azure.core.util.BinaryData imageData, List<VisualFeatures> visualFeatures, ImageAnalysisOptions imageAnalysisOptions, com.azure.core.http.rest.RequestOptions requestOptions) Performs a single Image Analysis operation on a given image buffer, while allowing customization of the HTTP request and access to HTTP request and response details. This is not commonly used.- Parameters:
imageData- The image to analyze.visualFeatures- A list of visual features to analyze. Seven visual features are supported: Caption, DenseCaptions, Read (OCR), Tags, Objects, SmartCrops, and People. At least one visual feature must be specified.imageAnalysisOptions- Additional image analysis options.requestOptions- The options to configure the HTTP request before the HTTP client sends it.- Returns:
- represents the outcome of an Image Analysis operation along with Response.
- Throws:
IllegalArgumentException- thrown if parameters fail the validation.com.azure.core.exception.HttpResponseException- thrown if the request is rejected by server.com.azure.core.exception.ClientAuthenticationException- thrown if the request is rejected by server on status code 401.com.azure.core.exception.ResourceNotFoundException- thrown if the request is rejected by server on status code 404.com.azure.core.exception.ResourceModifiedException- thrown if the request is rejected by server on status code 409.RuntimeException- all other wrapped checked exceptions if the request fails to be sent.
-