Skip to content
Snippets Groups Projects
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
BoundingBox.java 973 B
package object_detection.types;

public class BoundingBox {

    public BoundingBox(Point2D tr, Point2D tl, Point2D br, Point2D bl, int idx, String predClass) {
        this.topRight = tr;
        this.topLeft = tl;
        this.botRight = br;
        this.botLeft = bl;
        this.idx = idx;
        this.predClass = predClass;
    }

    public boolean within(Point2D p){
        return p.getX() <= this.topRight.getX()
                && p.getX() >= this.topLeft.getX()
                && p.getY() >= this.topLeft.getY()
                && p.getY() <= this.botLeft.getY();
    }


    // members
    Point2D topRight;
    Point2D topLeft;
    Point2D botRight;
    Point2D botLeft;
    int idx;
    String predClass;

    @Override
    public String toString(){
        return "BBOX with corners:" +
                "\n TR: " + topRight +
                "\n TL: " + topLeft +
                "\n BR: " + botRight +
                "\n BL: " + botLeft + "\n";
    }
}