pycognaize.document.tag.tag.BoxTag
- class BoxTag(left, right, top, bottom, page, confidence=None)[source]
Bases:
Tag
Represents a tag that has a varying width and height
- Parameters:
left (
Union
[int
,float
])right (
Union
[int
,float
])top (
Union
[int
,float
])bottom (
Union
[int
,float
])page (
Page
)confidence (
Confidence
)
Methods
construct_from_raw
Return the Euclidean distance of two tag centers
get_top_left
get_width_height
Shifts rectangle horizontally
Checks id there is an intersection between this and other rectangle
Calculate Intersection over Union for given rectangles
Check if the rectangle is in the other rectangle
set_class_confidence
Shifts rectangle by 2 axes simultaneously
Return a dictionary representing the tag object
Shifts rectangle vertically
Attributes
Area of the rectangle
bottom
Center point of the rectangle
confidence
Height of the rectangle
left
page
right
top
Width of the rectangle
Center of horizontal line of the rectangle
Center of vertical line of the rectangle
- property area: float
Area of the rectangle
- property center: Tuple[float, float]
Center point of the rectangle
- distance(other)[source]
Return the Euclidean distance of two tag centers
- Parameters:
other (
BoxTag
)- Return type:
Union
[int
,float
]
- property height: int | float
Height of the rectangle
- hshift(by)[source]
Shifts rectangle horizontally
- Parameters:
by – the amount by which the tag should be horizontally shifted
- Return type:
- Returns:
shifted rectangle
- iou(other)[source]
Calculate Intersection over Union for given rectangles
- Return type:
Union
[int
,float
]
- is_in_rectangle(other, thresh)[source]
Check if the rectangle is in the other rectangle
- Parameters:
other (
BoxTag
) – Another rectangle objectthresh (
float
) – If the fraction area of the rectangle is in the other rectangle is larger or equal to thresh, it is in the other rectangle
- Return type:
bool
- Returns:
True if rectangle is in other rectangle, False otherwise
- shift(horizontal, vertical)[source]
Shifts rectangle by 2 axes simultaneously
- Parameters:
horizontal
vertical
- Return type:
- Returns:
shifted rectangle
- vshift(by)[source]
Shifts rectangle vertically
- Parameters:
by – the amount by which the tag should be vertically shifted
- Return type:
- Returns:
shifted rectangle
- property width: int | float
Width of the rectangle
- property xcenter: float
Center of horizontal line of the rectangle
- property ycenter: float
Center of vertical line of the rectangle