/* * Copyright 2010-2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Licensed under the Apache License, Version 2.0 (the "License"). * You may not use this file except in compliance with the License. * A copy of the License is located at * * http://aws.amazon.com/apache2.0 * * or in the "license" file accompanying this file. This file is distributed * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either * express or implied. See the License for the specific language governing * permissions and limitations under the License. */ package com.amazonaws.services.rekognition.model; import java.io.Serializable; import com.amazonaws.AmazonWebServiceRequest; /** *

* Detects custom labels in a supplied image by using an Amazon Rekognition * Custom Labels model. *

*

* You specify which version of a model version to use by using the * ProjectVersionArn input parameter. *

*

* You pass the input image as base64-encoded image bytes or as a reference to * an image in an Amazon S3 bucket. If you use the AWS CLI to call Amazon * Rekognition operations, passing image bytes is not supported. The image must * be either a PNG or JPEG formatted file. *

*

* For each object that the model version detects on an image, the API returns a * (CustomLabel) object in an array (CustomLabels). * Each CustomLabel object provides the label name ( * Name), the level of confidence that the image contains the * object (Confidence), and object location information, if it * exists, for the label on the image (Geometry). *

*

* To filter labels that are returned, specify a value for * MinConfidence. DetectCustomLabelsLabels only * returns labels with a confidence that's higher than the specified value. The * value of MinConfidence maps to the assumed threshold values * created during training. For more information, see Assumed threshold * in the Amazon Rekognition Custom Labels Developer Guide. Amazon Rekognition * Custom Labels metrics expresses an assumed threshold as a floating point * value between 0-1. The range of MinConfidence normalizes the * threshold value to a percentage value (0-100). Confidence responses from * DetectCustomLabels are also returned as a percentage. You can * use MinConfidence to change the precision and recall or your * model. For more information, see Analyzing an image in the Amazon * Rekognition Custom Labels Developer Guide. *

*

* If you don't specify a value for MinConfidence, * DetectCustomLabels returns labels based on the assumed threshold * of each label. *

*

* This is a stateless API operation. That is, the operation does not persist * any data. *

*

* This operation requires permissions to perform the * rekognition:DetectCustomLabels action. *

*

* For more information, see Analyzing an image in the Amazon Rekognition * Custom Labels Developer Guide. *

*/ public class DetectCustomLabelsRequest extends AmazonWebServiceRequest implements Serializable { /** *

* The ARN of the model version that you want to use. *

*

* Constraints:
* Length: 20 - 2048
* Pattern: * (^arn:[a-z\d-]+:rekognition:[a-z\d-]+:\d{12}:project\/[a-zA * -Z0-9_.\-]{1,255}\/version\/[a-zA-Z0-9_.\-]{1,255}\/[0-9]+$)
*/ private String projectVersionArn; /** *

* Provides the input image either as bytes or an S3 object. *

*

* You pass image bytes to an Amazon Rekognition API operation by using the * Bytes property. For example, you would use the * Bytes property to pass an image loaded from a local file * system. Image bytes passed by using the Bytes property must * be base64-encoded. Your code may not need to encode image bytes if you * are using an AWS SDK to call Amazon Rekognition API operations. *

*

* For more information, see Analyzing an Image Loaded from a Local File * System in the Amazon Rekognition Developer Guide. *

*

* You pass images stored in an S3 bucket to an Amazon Rekognition API * operation by using the S3Object property. Images stored in * an S3 bucket do not need to be base64-encoded. *

*

* The region for the S3 bucket containing the S3 object must match the * region you use for Amazon Rekognition operations. *

*

* If you use the AWS CLI to call Amazon Rekognition operations, passing * image bytes using the Bytes property is not supported. You must first * upload the image to an Amazon S3 bucket and then call the operation using * the S3Object property. *

*

* For Amazon Rekognition to process an S3 object, the user must have * permission to access the S3 object. For more information, see How Amazon * Rekognition works with IAM in the Amazon Rekognition Developer Guide. *

*/ private Image image; /** *

* Maximum number of results you want the service to return in the response. * The service returns the specified number of highest confidence labels * ranked from highest confidence to lowest. *

*

* Constraints:
* Range: 0 -
*/ private Integer maxResults; /** *

* Specifies the minimum confidence level for the labels to return. * DetectCustomLabels doesn't return any labels with a * confidence value that's lower than this specified value. If you specify a * value of 0, DetectCustomLabels returns all labels, * regardless of the assumed threshold applied to each label. If you don't * specify a value for MinConfidence, * DetectCustomLabels returns labels based on the assumed * threshold of each label. *

*

* Constraints:
* Length: 0.0 - 100.0
*/ private Float minConfidence; /** *

* The ARN of the model version that you want to use. *

*

* Constraints:
* Length: 20 - 2048
* Pattern: * (^arn:[a-z\d-]+:rekognition:[a-z\d-]+:\d{12}:project\/[a-zA * -Z0-9_.\-]{1,255}\/version\/[a-zA-Z0-9_.\-]{1,255}\/[0-9]+$)
* * @return

* The ARN of the model version that you want to use. *

*/ public String getProjectVersionArn() { return projectVersionArn; } /** *

* The ARN of the model version that you want to use. *

*

* Constraints:
* Length: 20 - 2048
* Pattern: * (^arn:[a-z\d-]+:rekognition:[a-z\d-]+:\d{12}:project\/[a-zA * -Z0-9_.\-]{1,255}\/version\/[a-zA-Z0-9_.\-]{1,255}\/[0-9]+$)
* * @param projectVersionArn

* The ARN of the model version that you want to use. *

*/ public void setProjectVersionArn(String projectVersionArn) { this.projectVersionArn = projectVersionArn; } /** *

* The ARN of the model version that you want to use. *

*

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Length: 20 - 2048
* Pattern: * (^arn:[a-z\d-]+:rekognition:[a-z\d-]+:\d{12}:project\/[a-zA * -Z0-9_.\-]{1,255}\/version\/[a-zA-Z0-9_.\-]{1,255}\/[0-9]+$)
* * @param projectVersionArn

* The ARN of the model version that you want to use. *

* @return A reference to this updated object so that method calls can be * chained together. */ public DetectCustomLabelsRequest withProjectVersionArn(String projectVersionArn) { this.projectVersionArn = projectVersionArn; return this; } /** *

* Provides the input image either as bytes or an S3 object. *

*

* You pass image bytes to an Amazon Rekognition API operation by using the * Bytes property. For example, you would use the * Bytes property to pass an image loaded from a local file * system. Image bytes passed by using the Bytes property must * be base64-encoded. Your code may not need to encode image bytes if you * are using an AWS SDK to call Amazon Rekognition API operations. *

*

* For more information, see Analyzing an Image Loaded from a Local File * System in the Amazon Rekognition Developer Guide. *

*

* You pass images stored in an S3 bucket to an Amazon Rekognition API * operation by using the S3Object property. Images stored in * an S3 bucket do not need to be base64-encoded. *

*

* The region for the S3 bucket containing the S3 object must match the * region you use for Amazon Rekognition operations. *

*

* If you use the AWS CLI to call Amazon Rekognition operations, passing * image bytes using the Bytes property is not supported. You must first * upload the image to an Amazon S3 bucket and then call the operation using * the S3Object property. *

*

* For Amazon Rekognition to process an S3 object, the user must have * permission to access the S3 object. For more information, see How Amazon * Rekognition works with IAM in the Amazon Rekognition Developer Guide. *

* * @return

* Provides the input image either as bytes or an S3 object. *

*

* You pass image bytes to an Amazon Rekognition API operation by * using the Bytes property. For example, you would use * the Bytes property to pass an image loaded from a * local file system. Image bytes passed by using the * Bytes property must be base64-encoded. Your code may * not need to encode image bytes if you are using an AWS SDK to * call Amazon Rekognition API operations. *

*

* For more information, see Analyzing an Image Loaded from a Local * File System in the Amazon Rekognition Developer Guide. *

*

* You pass images stored in an S3 bucket to an Amazon Rekognition * API operation by using the S3Object property. Images * stored in an S3 bucket do not need to be base64-encoded. *

*

* The region for the S3 bucket containing the S3 object must match * the region you use for Amazon Rekognition operations. *

*

* If you use the AWS CLI to call Amazon Rekognition operations, * passing image bytes using the Bytes property is not supported. * You must first upload the image to an Amazon S3 bucket and then * call the operation using the S3Object property. *

*

* For Amazon Rekognition to process an S3 object, the user must * have permission to access the S3 object. For more information, * see How Amazon Rekognition works with IAM in the Amazon * Rekognition Developer Guide. *

*/ public Image getImage() { return image; } /** *

* Provides the input image either as bytes or an S3 object. *

*

* You pass image bytes to an Amazon Rekognition API operation by using the * Bytes property. For example, you would use the * Bytes property to pass an image loaded from a local file * system. Image bytes passed by using the Bytes property must * be base64-encoded. Your code may not need to encode image bytes if you * are using an AWS SDK to call Amazon Rekognition API operations. *

*

* For more information, see Analyzing an Image Loaded from a Local File * System in the Amazon Rekognition Developer Guide. *

*

* You pass images stored in an S3 bucket to an Amazon Rekognition API * operation by using the S3Object property. Images stored in * an S3 bucket do not need to be base64-encoded. *

*

* The region for the S3 bucket containing the S3 object must match the * region you use for Amazon Rekognition operations. *

*

* If you use the AWS CLI to call Amazon Rekognition operations, passing * image bytes using the Bytes property is not supported. You must first * upload the image to an Amazon S3 bucket and then call the operation using * the S3Object property. *

*

* For Amazon Rekognition to process an S3 object, the user must have * permission to access the S3 object. For more information, see How Amazon * Rekognition works with IAM in the Amazon Rekognition Developer Guide. *

* * @param image

* Provides the input image either as bytes or an S3 object. *

*

* You pass image bytes to an Amazon Rekognition API operation by * using the Bytes property. For example, you would * use the Bytes property to pass an image loaded * from a local file system. Image bytes passed by using the * Bytes property must be base64-encoded. Your code * may not need to encode image bytes if you are using an AWS SDK * to call Amazon Rekognition API operations. *

*

* For more information, see Analyzing an Image Loaded from a * Local File System in the Amazon Rekognition Developer Guide. *

*

* You pass images stored in an S3 bucket to an Amazon * Rekognition API operation by using the S3Object * property. Images stored in an S3 bucket do not need to be * base64-encoded. *

*

* The region for the S3 bucket containing the S3 object must * match the region you use for Amazon Rekognition operations. *

*

* If you use the AWS CLI to call Amazon Rekognition operations, * passing image bytes using the Bytes property is not supported. * You must first upload the image to an Amazon S3 bucket and * then call the operation using the S3Object property. *

*

* For Amazon Rekognition to process an S3 object, the user must * have permission to access the S3 object. For more information, * see How Amazon Rekognition works with IAM in the Amazon * Rekognition Developer Guide. *

*/ public void setImage(Image image) { this.image = image; } /** *

* Provides the input image either as bytes or an S3 object. *

*

* You pass image bytes to an Amazon Rekognition API operation by using the * Bytes property. For example, you would use the * Bytes property to pass an image loaded from a local file * system. Image bytes passed by using the Bytes property must * be base64-encoded. Your code may not need to encode image bytes if you * are using an AWS SDK to call Amazon Rekognition API operations. *

*

* For more information, see Analyzing an Image Loaded from a Local File * System in the Amazon Rekognition Developer Guide. *

*

* You pass images stored in an S3 bucket to an Amazon Rekognition API * operation by using the S3Object property. Images stored in * an S3 bucket do not need to be base64-encoded. *

*

* The region for the S3 bucket containing the S3 object must match the * region you use for Amazon Rekognition operations. *

*

* If you use the AWS CLI to call Amazon Rekognition operations, passing * image bytes using the Bytes property is not supported. You must first * upload the image to an Amazon S3 bucket and then call the operation using * the S3Object property. *

*

* For Amazon Rekognition to process an S3 object, the user must have * permission to access the S3 object. For more information, see How Amazon * Rekognition works with IAM in the Amazon Rekognition Developer Guide. *

*

* Returns a reference to this object so that method calls can be chained * together. * * @param image

* Provides the input image either as bytes or an S3 object. *

*

* You pass image bytes to an Amazon Rekognition API operation by * using the Bytes property. For example, you would * use the Bytes property to pass an image loaded * from a local file system. Image bytes passed by using the * Bytes property must be base64-encoded. Your code * may not need to encode image bytes if you are using an AWS SDK * to call Amazon Rekognition API operations. *

*

* For more information, see Analyzing an Image Loaded from a * Local File System in the Amazon Rekognition Developer Guide. *

*

* You pass images stored in an S3 bucket to an Amazon * Rekognition API operation by using the S3Object * property. Images stored in an S3 bucket do not need to be * base64-encoded. *

*

* The region for the S3 bucket containing the S3 object must * match the region you use for Amazon Rekognition operations. *

*

* If you use the AWS CLI to call Amazon Rekognition operations, * passing image bytes using the Bytes property is not supported. * You must first upload the image to an Amazon S3 bucket and * then call the operation using the S3Object property. *

*

* For Amazon Rekognition to process an S3 object, the user must * have permission to access the S3 object. For more information, * see How Amazon Rekognition works with IAM in the Amazon * Rekognition Developer Guide. *

* @return A reference to this updated object so that method calls can be * chained together. */ public DetectCustomLabelsRequest withImage(Image image) { this.image = image; return this; } /** *

* Maximum number of results you want the service to return in the response. * The service returns the specified number of highest confidence labels * ranked from highest confidence to lowest. *

*

* Constraints:
* Range: 0 -
* * @return

* Maximum number of results you want the service to return in the * response. The service returns the specified number of highest * confidence labels ranked from highest confidence to lowest. *

*/ public Integer getMaxResults() { return maxResults; } /** *

* Maximum number of results you want the service to return in the response. * The service returns the specified number of highest confidence labels * ranked from highest confidence to lowest. *

*

* Constraints:
* Range: 0 -
* * @param maxResults

* Maximum number of results you want the service to return in * the response. The service returns the specified number of * highest confidence labels ranked from highest confidence to * lowest. *

*/ public void setMaxResults(Integer maxResults) { this.maxResults = maxResults; } /** *

* Maximum number of results you want the service to return in the response. * The service returns the specified number of highest confidence labels * ranked from highest confidence to lowest. *

*

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Range: 0 -
* * @param maxResults

* Maximum number of results you want the service to return in * the response. The service returns the specified number of * highest confidence labels ranked from highest confidence to * lowest. *

* @return A reference to this updated object so that method calls can be * chained together. */ public DetectCustomLabelsRequest withMaxResults(Integer maxResults) { this.maxResults = maxResults; return this; } /** *

* Specifies the minimum confidence level for the labels to return. * DetectCustomLabels doesn't return any labels with a * confidence value that's lower than this specified value. If you specify a * value of 0, DetectCustomLabels returns all labels, * regardless of the assumed threshold applied to each label. If you don't * specify a value for MinConfidence, * DetectCustomLabels returns labels based on the assumed * threshold of each label. *

*

* Constraints:
* Length: 0.0 - 100.0
* * @return

* Specifies the minimum confidence level for the labels to return. * DetectCustomLabels doesn't return any labels with a * confidence value that's lower than this specified value. If you * specify a value of 0, DetectCustomLabels returns all * labels, regardless of the assumed threshold applied to each * label. If you don't specify a value for * MinConfidence, DetectCustomLabels * returns labels based on the assumed threshold of each label. *

*/ public Float getMinConfidence() { return minConfidence; } /** *

* Specifies the minimum confidence level for the labels to return. * DetectCustomLabels doesn't return any labels with a * confidence value that's lower than this specified value. If you specify a * value of 0, DetectCustomLabels returns all labels, * regardless of the assumed threshold applied to each label. If you don't * specify a value for MinConfidence, * DetectCustomLabels returns labels based on the assumed * threshold of each label. *

*

* Constraints:
* Length: 0.0 - 100.0
* * @param minConfidence

* Specifies the minimum confidence level for the labels to * return. DetectCustomLabels doesn't return any * labels with a confidence value that's lower than this * specified value. If you specify a value of 0, * DetectCustomLabels returns all labels, regardless * of the assumed threshold applied to each label. If you don't * specify a value for MinConfidence, * DetectCustomLabels returns labels based on the * assumed threshold of each label. *

*/ public void setMinConfidence(Float minConfidence) { this.minConfidence = minConfidence; } /** *

* Specifies the minimum confidence level for the labels to return. * DetectCustomLabels doesn't return any labels with a * confidence value that's lower than this specified value. If you specify a * value of 0, DetectCustomLabels returns all labels, * regardless of the assumed threshold applied to each label. If you don't * specify a value for MinConfidence, * DetectCustomLabels returns labels based on the assumed * threshold of each label. *

*

* Returns a reference to this object so that method calls can be chained * together. *

* Constraints:
* Length: 0.0 - 100.0
* * @param minConfidence

* Specifies the minimum confidence level for the labels to * return. DetectCustomLabels doesn't return any * labels with a confidence value that's lower than this * specified value. If you specify a value of 0, * DetectCustomLabels returns all labels, regardless * of the assumed threshold applied to each label. If you don't * specify a value for MinConfidence, * DetectCustomLabels returns labels based on the * assumed threshold of each label. *

* @return A reference to this updated object so that method calls can be * chained together. */ public DetectCustomLabelsRequest withMinConfidence(Float minConfidence) { this.minConfidence = minConfidence; return this; } /** * Returns a string representation of this object; useful for testing and * debugging. * * @return A string representation of this object. * @see java.lang.Object#toString() */ @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("{"); if (getProjectVersionArn() != null) sb.append("ProjectVersionArn: " + getProjectVersionArn() + ","); if (getImage() != null) sb.append("Image: " + getImage() + ","); if (getMaxResults() != null) sb.append("MaxResults: " + getMaxResults() + ","); if (getMinConfidence() != null) sb.append("MinConfidence: " + getMinConfidence()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getProjectVersionArn() == null) ? 0 : getProjectVersionArn().hashCode()); hashCode = prime * hashCode + ((getImage() == null) ? 0 : getImage().hashCode()); hashCode = prime * hashCode + ((getMaxResults() == null) ? 0 : getMaxResults().hashCode()); hashCode = prime * hashCode + ((getMinConfidence() == null) ? 0 : getMinConfidence().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof DetectCustomLabelsRequest == false) return false; DetectCustomLabelsRequest other = (DetectCustomLabelsRequest) obj; if (other.getProjectVersionArn() == null ^ this.getProjectVersionArn() == null) return false; if (other.getProjectVersionArn() != null && other.getProjectVersionArn().equals(this.getProjectVersionArn()) == false) return false; if (other.getImage() == null ^ this.getImage() == null) return false; if (other.getImage() != null && other.getImage().equals(this.getImage()) == false) return false; if (other.getMaxResults() == null ^ this.getMaxResults() == null) return false; if (other.getMaxResults() != null && other.getMaxResults().equals(this.getMaxResults()) == false) return false; if (other.getMinConfidence() == null ^ this.getMinConfidence() == null) return false; if (other.getMinConfidence() != null && other.getMinConfidence().equals(this.getMinConfidence()) == false) return false; return true; } }