Package ai.djl.modality.cv.output
Class Rectangle
- java.lang.Object
-
- ai.djl.modality.cv.output.Rectangle
-
- All Implemented Interfaces:
BoundingBox,java.io.Serializable
public class Rectangle extends java.lang.Object implements BoundingBox
ARectanglespecifies an area in a coordinate space that is enclosed by theRectangleobject's upper-left pointPointin the coordinate space, its width, and its height.The rectangle coordinates are usually from 0-1 and are ratios of the image size. For example, if you have an image width of 400 pixels and the rectangle starts at 100 pixels, you would use .25.
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Rectangle(double x, double y, double width, double height)Constructs a newRectanglewhose upper-left corner is specified as(x,y)and whose width and height are specified by the arguments of the same name.Rectangle(Point point, double width, double height)Constructs a newRectanglewhose upper-left corner is specified as coordinatepointand whose width and height are specified by the arguments of the same name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RectanglegetBounds()Returns the boundingRectangleof thisBoundingBox.doublegetHeight()Returns the height of the Rectangle.doublegetIoU(BoundingBox box)Returns the Intersection over Union (IoU) value between bounding boxes.java.lang.Iterable<Point>getPath()Returns an iterator object that iterates along theBoundingBoxboundary and provides access to the geometry of theBoundingBoxoutline.PointgetPoint()Returns the top left point of the bounding box.doublegetWidth()Returns the width of the Rectangle.doublegetX()Returns the left x-coordinate of the Rectangle.doublegetY()Returns the top y-coordinate of the Rectangle.java.lang.StringtoString()
-
-
-
Constructor Detail
-
Rectangle
public Rectangle(double x, double y, double width, double height)Constructs a newRectanglewhose upper-left corner is specified as(x,y)and whose width and height are specified by the arguments of the same name.- Parameters:
x- the specified X coordinate (0-1)y- the specified Y coordinate (0-1)width- the width of theRectangle(0-1)height- the height of theRectangle(0-1)
-
Rectangle
public Rectangle(Point point, double width, double height)
Constructs a newRectanglewhose upper-left corner is specified as coordinatepointand whose width and height are specified by the arguments of the same name.- Parameters:
point- the upper-left corner of the coordinate (0-1)width- the width of theRectangle(0-1)height- the height of theRectangle(0-1)
-
-
Method Detail
-
getBounds
public Rectangle getBounds()
Returns the boundingRectangleof thisBoundingBox.- Specified by:
getBoundsin interfaceBoundingBox- Returns:
- a new
Rectanglefor thisBoundingBox
-
getPath
public java.lang.Iterable<Point> getPath()
Returns an iterator object that iterates along theBoundingBoxboundary and provides access to the geometry of theBoundingBoxoutline.- Specified by:
getPathin interfaceBoundingBox- Returns:
- a
Iterableobject, which independently traverses the geometry of theBoundingBox
-
getPoint
public Point getPoint()
Returns the top left point of the bounding box.- Specified by:
getPointin interfaceBoundingBox- Returns:
- the
Pointof the top left corner
-
getIoU
public double getIoU(BoundingBox box)
Returns the Intersection over Union (IoU) value between bounding boxes.Also known as Jaccard index
- Specified by:
getIoUin interfaceBoundingBox- Parameters:
box- the bounding box to calculate- Returns:
- the IoU value
-
getX
public double getX()
Returns the left x-coordinate of the Rectangle.- Returns:
- the left x-coordinate of the Rectangle (0-1)
-
getY
public double getY()
Returns the top y-coordinate of the Rectangle.- Returns:
- the top y-coordinate of the Rectangle (0-1)
-
getWidth
public double getWidth()
Returns the width of the Rectangle.- Returns:
- the width of the Rectangle (0-1)
-
getHeight
public double getHeight()
Returns the height of the Rectangle.- Returns:
- the height of the Rectangle (0-1)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-