
com.amazonaws.services.rekognition.model.TextDetection Maven / Gradle / Ivy
/*
* Copyright 2019-2024 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 javax.annotation.Generated;
import com.amazonaws.protocol.StructuredPojo;
import com.amazonaws.protocol.ProtocolMarshaller;
/**
*
* 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.
*
*/
@Generated("com.amazonaws:aws-java-sdk-code-generator")
public class TextDetection implements Serializable, Cloneable, StructuredPojo {
/**
*
* The word or line of text recognized by Amazon Rekognition.
*
*/
private String detectedText;
/**
*
* The type of text that was detected.
*
*/
private String type;
/**
*
* The identifier for the detected text. The identifier is only unique for a single call to DetectText
.
*
*/
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
.
*
*/
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.
*
*/
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.
*
*
* @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.
*
*
* @return The word or line of text recognized by Amazon Rekognition.
*/
public String getDetectedText() {
return this.detectedText;
}
/**
*
* The word or line of text recognized by Amazon Rekognition.
*
*
* @param detectedText
* The word or line of text recognized by Amazon Rekognition.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public TextDetection withDetectedText(String detectedText) {
setDetectedText(detectedText);
return this;
}
/**
*
* The type of text that was detected.
*
*
* @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.
*
*
* @return The type of text that was detected.
* @see TextTypes
*/
public String getType() {
return this.type;
}
/**
*
* The type of text that was detected.
*
*
* @param type
* The type of text that was detected.
* @return Returns a reference to this object so that method calls can be chained together.
* @see TextTypes
*/
public TextDetection withType(String type) {
setType(type);
return this;
}
/**
*
* The type of text that was detected.
*
*
* @param type
* The type of text that was detected.
* @return Returns a reference to this 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
.
*
*
* @param id
* The identifier for the detected text. The identifier is only unique for a single call to
* DetectText
.
*/
public void setId(Integer id) {
this.id = id;
}
/**
*
* The identifier for the detected text. The identifier is only unique for a single call to DetectText
.
*
*
* @return The identifier for the detected text. The identifier is only unique for a single call to
* DetectText
.
*/
public Integer getId() {
return this.id;
}
/**
*
* The identifier for the detected text. The identifier is only unique for a single call to DetectText
.
*
*
* @param id
* The identifier for the detected text. The identifier is only unique for a single call to
* DetectText
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public TextDetection withId(Integer id) {
setId(id);
return this;
}
/**
*
* 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
.
*
*
* @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
.
*/
public void setParentId(Integer parentId) {
this.parentId = 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
.
*
*
* @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
.
*/
public Integer getParentId() {
return this.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
.
*
*
* @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
.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public TextDetection withParentId(Integer parentId) {
setParentId(parentId);
return this;
}
/**
*
* The confidence that Amazon Rekognition has in the accuracy of the detected text and the accuracy of the geometry
* points around the detected text.
*
*
* @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.
*
*
* @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 this.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.
*
*
* @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 Returns a reference to this object so that method calls can be chained together.
*/
public TextDetection withConfidence(Float confidence) {
setConfidence(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.
*
*
* @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.
*
*
* @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 this.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.
* @return Returns a reference to this object so that method calls can be chained together.
*/
public TextDetection withGeometry(Geometry geometry) {
setGeometry(geometry);
return this;
}
/**
* Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be
* redacted from this string using a placeholder value.
*
* @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: ").append(getDetectedText()).append(",");
if (getType() != null)
sb.append("Type: ").append(getType()).append(",");
if (getId() != null)
sb.append("Id: ").append(getId()).append(",");
if (getParentId() != null)
sb.append("ParentId: ").append(getParentId()).append(",");
if (getConfidence() != null)
sb.append("Confidence: ").append(getConfidence()).append(",");
if (getGeometry() != null)
sb.append("Geometry: ").append(getGeometry());
sb.append("}");
return sb.toString();
}
@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;
}
@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 TextDetection clone() {
try {
return (TextDetection) super.clone();
} catch (CloneNotSupportedException e) {
throw new IllegalStateException("Got a CloneNotSupportedException from Object.clone() " + "even though we're Cloneable!", e);
}
}
@com.amazonaws.annotation.SdkInternalApi
@Override
public void marshall(ProtocolMarshaller protocolMarshaller) {
com.amazonaws.services.rekognition.model.transform.TextDetectionMarshaller.getInstance().marshall(this, protocolMarshaller);
}
}