/* * 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; /** *
* Identifies the bounding box around the label, face, text, object of interest,
* or personal protective equipment. The left
(x-coordinate) and
* top
(y-coordinate) are coordinates representing the top and left
* sides of the bounding box. Note that the upper-left corner of the image is
* the origin (0,0).
*
* The top
and left
values returned are ratios of the
* overall image size. For example, if the input image is 700x200 pixels, and
* the top-left coordinate of the bounding box is 350x50 pixels, the API returns
* a left
value of 0.5 (350/700) and a top
value of
* 0.25 (50/200).
*
* The width
and height
values represent the
* dimensions of the bounding box as a ratio of the overall image dimension. For
* example, if the input image is 700x200 pixels, and the bounding box width is
* 70 pixels, the width returned is 0.1.
*
* The bounding box coordinates can have negative values. For example, if Amazon
* Rekognition is able to detect a face that is at the image edge and is only
* partially visible, the service can return coordinates that are outside the
* image bounds and, depending on the image edge, you might get negative values
* or values greater than 1 for the left
or top
* values.
*
* Width of the bounding box as a ratio of the overall image width. *
*/ private Float width; /** ** Height of the bounding box as a ratio of the overall image height. *
*/ private Float height; /** ** Left coordinate of the bounding box as a ratio of overall image width. *
*/ private Float left; /** ** Top coordinate of the bounding box as a ratio of overall image height. *
*/ private Float top; /** ** Width of the bounding box as a ratio of the overall image width. *
* * @return* Width of the bounding box as a ratio of the overall image width. *
*/ public Float getWidth() { return width; } /** ** Width of the bounding box as a ratio of the overall image width. *
* * @param width* Width of the bounding box as a ratio of the overall image * width. *
*/ public void setWidth(Float width) { this.width = width; } /** ** Width of the bounding box as a ratio of the overall image width. *
** Returns a reference to this object so that method calls can be chained * together. * * @param width
* Width of the bounding box as a ratio of the overall image * width. *
* @return A reference to this updated object so that method calls can be * chained together. */ public BoundingBox withWidth(Float width) { this.width = width; return this; } /** ** Height of the bounding box as a ratio of the overall image height. *
* * @return* Height of the bounding box as a ratio of the overall image * height. *
*/ public Float getHeight() { return height; } /** ** Height of the bounding box as a ratio of the overall image height. *
* * @param height* Height of the bounding box as a ratio of the overall image * height. *
*/ public void setHeight(Float height) { this.height = height; } /** ** Height of the bounding box as a ratio of the overall image height. *
** Returns a reference to this object so that method calls can be chained * together. * * @param height
* Height of the bounding box as a ratio of the overall image * height. *
* @return A reference to this updated object so that method calls can be * chained together. */ public BoundingBox withHeight(Float height) { this.height = height; return this; } /** ** Left coordinate of the bounding box as a ratio of overall image width. *
* * @return* Left coordinate of the bounding box as a ratio of overall image * width. *
*/ public Float getLeft() { return left; } /** ** Left coordinate of the bounding box as a ratio of overall image width. *
* * @param left* Left coordinate of the bounding box as a ratio of overall * image width. *
*/ public void setLeft(Float left) { this.left = left; } /** ** Left coordinate of the bounding box as a ratio of overall image width. *
** Returns a reference to this object so that method calls can be chained * together. * * @param left
* Left coordinate of the bounding box as a ratio of overall * image width. *
* @return A reference to this updated object so that method calls can be * chained together. */ public BoundingBox withLeft(Float left) { this.left = left; return this; } /** ** Top coordinate of the bounding box as a ratio of overall image height. *
* * @return* Top coordinate of the bounding box as a ratio of overall image * height. *
*/ public Float getTop() { return top; } /** ** Top coordinate of the bounding box as a ratio of overall image height. *
* * @param top* Top coordinate of the bounding box as a ratio of overall image * height. *
*/ public void setTop(Float top) { this.top = top; } /** ** Top coordinate of the bounding box as a ratio of overall image height. *
** Returns a reference to this object so that method calls can be chained * together. * * @param top
* Top coordinate of the bounding box as a ratio of overall image * height. *
* @return A reference to this updated object so that method calls can be * chained together. */ public BoundingBox withTop(Float top) { this.top = top; 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 (getWidth() != null) sb.append("Width: " + getWidth() + ","); if (getHeight() != null) sb.append("Height: " + getHeight() + ","); if (getLeft() != null) sb.append("Left: " + getLeft() + ","); if (getTop() != null) sb.append("Top: " + getTop()); sb.append("}"); return sb.toString(); } @Override public int hashCode() { final int prime = 31; int hashCode = 1; hashCode = prime * hashCode + ((getWidth() == null) ? 0 : getWidth().hashCode()); hashCode = prime * hashCode + ((getHeight() == null) ? 0 : getHeight().hashCode()); hashCode = prime * hashCode + ((getLeft() == null) ? 0 : getLeft().hashCode()); hashCode = prime * hashCode + ((getTop() == null) ? 0 : getTop().hashCode()); return hashCode; } @Override public boolean equals(Object obj) { if (this == obj) return true; if (obj == null) return false; if (obj instanceof BoundingBox == false) return false; BoundingBox other = (BoundingBox) obj; if (other.getWidth() == null ^ this.getWidth() == null) return false; if (other.getWidth() != null && other.getWidth().equals(this.getWidth()) == false) return false; if (other.getHeight() == null ^ this.getHeight() == null) return false; if (other.getHeight() != null && other.getHeight().equals(this.getHeight()) == false) return false; if (other.getLeft() == null ^ this.getLeft() == null) return false; if (other.getLeft() != null && other.getLeft().equals(this.getLeft()) == false) return false; if (other.getTop() == null ^ this.getTop() == null) return false; if (other.getTop() != null && other.getTop().equals(this.getTop()) == false) return false; return true; } }