/* * 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; /** *
* Information about a word or line of text detected by DetectText. *
*
 * The DetectedText field contains the text that Amazon Rekognition
 * detected in the image.
 * 
 * Every word and line has an identifier (Id). Each word belongs to
 * a line and has a parent identifier (ParentId) that identifies
 * the line of text in which the word appears. The word Id is also
 * an index for the word within a line of words.
 * 
* For more information, see Detecting text in the Amazon Rekognition Developer * Guide. *
*/ public class TextDetection implements Serializable { /** ** The word or line of text recognized by Amazon Rekognition. *
*/ private String detectedText; /** ** The type of text that was detected. *
*
     * Constraints:
     * Allowed Values: LINE, WORD
     */
    private String type;
    /**
     * 
     * The identifier for the detected text. The identifier is only unique for a
     * single call to DetectText.
     * 
     * Constraints:
     * Range: 0 - 
     */
    private Integer id;
    /**
     * 
     * The Parent identifier for the detected text identified by the value of
     * ID. If the type of detected text is LINE, the
     * value of ParentId is Null.
     * 
     * Constraints:
     * Range: 0 - 
     */
    private Integer parentId;
    /**
     * 
* The confidence that Amazon Rekognition has in the accuracy of the * detected text and the accuracy of the geometry points around the detected * text. *
*
     * Constraints:
     * Length: 0.0 - 100.0
     */
    private Float confidence;
    /**
     * 
* The location of the detected text on the image. Includes an axis aligned * coarse bounding box surrounding the text and a finer grain polygon for * more accurate spatial information. *
*/ private Geometry geometry; /** ** The word or line of text recognized by Amazon Rekognition. *
* * @return* The word or line of text recognized by Amazon Rekognition. *
*/ public String getDetectedText() { return detectedText; } /** ** The word or line of text recognized by Amazon Rekognition. *
* * @param detectedText* The word or line of text recognized by Amazon Rekognition. *
*/ public void setDetectedText(String detectedText) { this.detectedText = detectedText; } /** ** The word or line of text recognized by Amazon Rekognition. *
** Returns a reference to this object so that method calls can be chained * together. * * @param detectedText
* The word or line of text recognized by Amazon Rekognition. *
* @return A reference to this updated object so that method calls can be * chained together. */ public TextDetection withDetectedText(String detectedText) { this.detectedText = detectedText; return this; } /** ** The type of text that was detected. *
*
     * Constraints:
     * Allowed Values: LINE, WORD
     *
     * @return 
* The type of text that was detected. *
* @see TextTypes */ public String getType() { return type; } /** ** The type of text that was detected. *
*
     * Constraints:
     * Allowed Values: LINE, WORD
     *
     * @param type 
* The type of text that was detected. *
* @see TextTypes */ public void setType(String type) { this.type = type; } /** ** The type of text that was detected. *
** Returns a reference to this object so that method calls can be chained * together. *
     * Constraints:
     * Allowed Values: LINE, WORD
     *
     * @param type 
* The type of text that was detected. *
* @return A reference to this updated object so that method calls can be * chained together. * @see TextTypes */ public TextDetection withType(String type) { this.type = type; return this; } /** ** The type of text that was detected. *
*
     * Constraints:
     * Allowed Values: LINE, WORD
     *
     * @param type 
* The type of text that was detected. *
* @see TextTypes */ public void setType(TextTypes type) { this.type = type.toString(); } /** ** The type of text that was detected. *
** Returns a reference to this object so that method calls can be chained * together. *
     * Constraints:
     * Allowed Values: LINE, WORD
     *
     * @param type 
* The type of text that was detected. *
* @return A reference to this updated object so that method calls can be * chained together. * @see TextTypes */ public TextDetection withType(TextTypes type) { this.type = type.toString(); return this; } /** *
     * The identifier for the detected text. The identifier is only unique for a
     * single call to DetectText.
     * 
     * Constraints:
     * Range: 0 - 
     *
     * @return 
     *         The identifier for the detected text. The identifier is only
     *         unique for a single call to DetectText.
     *         
     * The identifier for the detected text. The identifier is only unique for a
     * single call to DetectText.
     * 
     * Constraints:
     * Range: 0 - 
     *
     * @param id 
     *            The identifier for the detected text. The identifier is only
     *            unique for a single call to DetectText.
     *            
     * The identifier for the detected text. The identifier is only unique for a
     * single call to DetectText.
     * 
* Returns a reference to this object so that method calls can be chained * together. *
     * Constraints:
     * Range: 0 - 
     *
     * @param id 
     *            The identifier for the detected text. The identifier is only
     *            unique for a single call to DetectText.
     *            
     * The Parent identifier for the detected text identified by the value of
     * ID. If the type of detected text is LINE, the
     * value of ParentId is Null.
     * 
     * Constraints:
     * Range: 0 - 
     *
     * @return 
     *         The Parent identifier for the detected text identified by the
     *         value of ID. If the type of detected text is
     *         LINE, the value of ParentId is
     *         Null.
     *         
     * The Parent identifier for the detected text identified by the value of
     * ID. If the type of detected text is LINE, the
     * value of ParentId is Null.
     * 
     * Constraints:
     * Range: 0 - 
     *
     * @param parentId 
     *            The Parent identifier for the detected text identified by the
     *            value of ID. If the type of detected text is
     *            LINE, the value of ParentId is
     *            Null.
     *            
     * The Parent identifier for the detected text identified by the value of
     * ID. If the type of detected text is LINE, the
     * value of ParentId is Null.
     * 
* Returns a reference to this object so that method calls can be chained * together. *
     * Constraints:
     * Range: 0 - 
     *
     * @param parentId 
     *            The Parent identifier for the detected text identified by the
     *            value of ID. If the type of detected text is
     *            LINE, the value of ParentId is
     *            Null.
     *            
* The confidence that Amazon Rekognition has in the accuracy of the * detected text and the accuracy of the geometry points around the detected * text. *
*
     * Constraints:
     * Length: 0.0 - 100.0
     *
     * @return 
* The confidence that Amazon Rekognition has in the accuracy of the * detected text and the accuracy of the geometry points around the * detected text. *
*/ public Float getConfidence() { return confidence; } /** ** The confidence that Amazon Rekognition has in the accuracy of the * detected text and the accuracy of the geometry points around the detected * text. *
*
     * Constraints:
     * Length: 0.0 - 100.0
     *
     * @param confidence 
* The confidence that Amazon Rekognition has in the accuracy of * the detected text and the accuracy of the geometry points * around the detected text. *
*/ public void setConfidence(Float confidence) { this.confidence = confidence; } /** ** The confidence that Amazon Rekognition has in the accuracy of the * detected text and the accuracy of the geometry points around the detected * text. *
** Returns a reference to this object so that method calls can be chained * together. *
     * Constraints:
     * Length: 0.0 - 100.0
     *
     * @param confidence 
* The confidence that Amazon Rekognition has in the accuracy of * the detected text and the accuracy of the geometry points * around the detected text. *
* @return A reference to this updated object so that method calls can be * chained together. */ public TextDetection withConfidence(Float confidence) { this.confidence = confidence; return this; } /** ** The location of the detected text on the image. Includes an axis aligned * coarse bounding box surrounding the text and a finer grain polygon for * more accurate spatial information. *
* * @return* The location of the detected text on the image. Includes an axis * aligned coarse bounding box surrounding the text and a finer * grain polygon for more accurate spatial information. *
*/ public Geometry getGeometry() { return geometry; } /** ** The location of the detected text on the image. Includes an axis aligned * coarse bounding box surrounding the text and a finer grain polygon for * more accurate spatial information. *
* * @param geometry* The location of the detected text on the image. Includes an * axis aligned coarse bounding box surrounding the text and a * finer grain polygon for more accurate spatial information. *
*/ public void setGeometry(Geometry geometry) { this.geometry = geometry; } /** ** The location of the detected text on the image. Includes an axis aligned * coarse bounding box surrounding the text and a finer grain polygon for * more accurate spatial information. *
** Returns a reference to this object so that method calls can be chained * together. * * @param geometry
* The location of the detected text on the image. Includes an * axis aligned coarse bounding box surrounding the text and a * finer grain polygon for more accurate spatial information. *
* @return A reference to this updated object so that method calls can be * chained together. */ public TextDetection withGeometry(Geometry geometry) { this.geometry = geometry; 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 (getDetectedText() != null) sb.append("DetectedText: " + getDetectedText() + ","); if (getType() != null) sb.append("Type: " + getType() + ","); if (getId() != null) sb.append("Id: " + getId() + ","); if (getParentId() != null) sb.append("ParentId: " + getParentId() + ","); if (getConfidence() != null) sb.append("Confidence: " + getConfidence() + ","); if (getGeometry() != null) sb.append("Geometry: " + getGeometry()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getDetectedText() == null) ? 0 : getDetectedText().hashCode()); hashCode = prime * hashCode + ((getType() == null) ? 0 : getType().hashCode()); hashCode = prime * hashCode + ((getId() == null) ? 0 : getId().hashCode()); hashCode = prime * hashCode + ((getParentId() == null) ? 0 : getParentId().hashCode()); hashCode = prime * hashCode + ((getConfidence() == null) ? 0 : getConfidence().hashCode()); hashCode = prime * hashCode + ((getGeometry() == null) ? 0 : getGeometry().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof TextDetection == false) return false; TextDetection other = (TextDetection) obj; if (other.getDetectedText() == null ^ this.getDetectedText() == null) return false; if (other.getDetectedText() != null && other.getDetectedText().equals(this.getDetectedText()) == false) return false; if (other.getType() == null ^ this.getType() == null) return false; if (other.getType() != null && other.getType().equals(this.getType()) == false) return false; if (other.getId() == null ^ this.getId() == null) return false; if (other.getId() != null && other.getId().equals(this.getId()) == false) return false; if (other.getParentId() == null ^ this.getParentId() == null) return false; if (other.getParentId() != null && other.getParentId().equals(this.getParentId()) == false) return false; if (other.getConfidence() == null ^ this.getConfidence() == null) return false; if (other.getConfidence() != null && other.getConfidence().equals(this.getConfidence()) == false) return false; if (other.getGeometry() == null ^ this.getGeometry() == null) return false; if (other.getGeometry() != null && other.getGeometry().equals(this.getGeometry()) == false) return false; return true; } }