Class AxisAlignedBoundingBox
- java.lang.Object
-
- edu.wpi.first.wpilibj.geometry.Translation2d
-
- io.github.frc5024.lib5k.vision.types.Contour
-
- io.github.frc5024.lib5k.vision.types.AxisAlignedBoundingBox
-
- Direct Known Subclasses:
HyperbolicAxisAlignedBoundingBox
public class AxisAlignedBoundingBox extends Contour
A computer-vision axis-aligned bounding box. Relative to a camera
-
-
Field Summary
-
Fields inherited from class io.github.frc5024.lib5k.vision.types.Contour
NO_ROTATION
-
-
Constructor Summary
Constructors Constructor Description AxisAlignedBoundingBox(Translation2d topLeft, Translation2d bottomRight)
Create an AxisAlignedBoundingBox from opposing cornersAxisAlignedBoundingBox(Translation2d topLeft, Translation2d bottomRight, Rotation2d xRot, Rotation2d yRot)
Create an AxisAlignedBoundingBox from opposing corners, with angles relative to a camera
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(Translation2d point)
Check if this contour contains a pointdouble
getAspectRatio()
Get the aspect ratio of this box as width/heightTranslation2d
getBottomLeftCorner()
Get the bottom left corner of this box expressed as a percentage of the frame from the center (top left is -1,1)Translation2d
getBottomRightCorner()
Get the bottom right corner of this box expressed as a percentage of the frame from the center (top left is -1,1)double
getHeight()
Get box heightTranslation2d
getTopLeftCorner()
Get the top left corner of this box expressed as a percentage of the frame from the center (top left is -1,1)Translation2d
getTopRightCorner()
Get the top right corner of this box expressed as a percentage of the frame from the center (top left is -1,1)double
getWidth()
Get box widthboolean
overlaps(AxisAlignedBoundingBox box)
Check if this contour overlaps with an AxisAlignedBoundingBoxjava.lang.String
toString()
-
Methods inherited from class io.github.frc5024.lib5k.vision.types.Contour
getXRotation, getYRotation
-
Methods inherited from class edu.wpi.first.wpilibj.geometry.Translation2d
div, equals, getDistance, getNorm, getX, getY, hashCode, minus, plus, rotateBy, times, unaryMinus
-
-
-
-
Constructor Detail
-
AxisAlignedBoundingBox
public AxisAlignedBoundingBox(Translation2d topLeft, Translation2d bottomRight)
Create an AxisAlignedBoundingBox from opposing corners- Parameters:
topLeft
- Top left corner expressed as a percentage of the frame from the center (top left is -1,1)bottomRight
- Bottom right corner expressed as a percentage of the frame from the center (top left is -1,1)
-
AxisAlignedBoundingBox
public AxisAlignedBoundingBox(Translation2d topLeft, Translation2d bottomRight, Rotation2d xRot, Rotation2d yRot)
Create an AxisAlignedBoundingBox from opposing corners, with angles relative to a camera- Parameters:
topLeft
- Top left corner expressed as a percentage of the frame from the center (top left is -1,1)bottomRight
- Bottom right corner expressed as a percentage of the frame from the center (top left is -1,1)xRot
- X angle from camerayRot
- Y angle from camera
-
-
Method Detail
-
getAspectRatio
public double getAspectRatio()
Get the aspect ratio of this box as width/height- Returns:
- Aspect ratio
-
contains
public boolean contains(Translation2d point)
Description copied from class:Contour
Check if this contour contains a point
-
overlaps
public boolean overlaps(AxisAlignedBoundingBox box)
Description copied from class:Contour
Check if this contour overlaps with an AxisAlignedBoundingBox
-
getTopLeftCorner
public Translation2d getTopLeftCorner()
Get the top left corner of this box expressed as a percentage of the frame from the center (top left is -1,1)- Returns:
- top left corner
-
getBottomLeftCorner
public Translation2d getBottomLeftCorner()
Get the bottom left corner of this box expressed as a percentage of the frame from the center (top left is -1,1)- Returns:
- bottom left corner
-
getTopRightCorner
public Translation2d getTopRightCorner()
Get the top right corner of this box expressed as a percentage of the frame from the center (top left is -1,1)- Returns:
- top right corner
-
getBottomRightCorner
public Translation2d getBottomRightCorner()
Get the bottom right corner of this box expressed as a percentage of the frame from the center (top left is -1,1)- Returns:
- bottom right corner
-
getWidth
public double getWidth()
Get box width- Returns:
- Width
-
getHeight
public double getHeight()
Get box height- Returns:
- Height
-
toString
public java.lang.String toString()
- Overrides:
toString
in classTranslation2d
-
-