-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
def __init__(self, shell: np.ndarray, holes:list[np.ndarray]=[]):
""" Creates a polygon.
Args:
shell (np.ndarray): The shell of the polygon. Expects a numpy array of shape (n, 2).
If the shape is (n, 1, 2), it will be reshaped to (n, 2). This is useful for cv2.findContours.
holes (list[np.ndarray]): The holes in the polygon.
"""
# Reshape the shell if needed
if len(shell.shape) == 3:
shell = shell.reshape(shell.shape[0], 2)
# Reshape the holes if needed
if len(holes) > 0:
for i, hole in enumerate(holes):
if len(hole.shape) == 3:
holes[i] = hole.reshape(hole.shape[0], 2)
self.shell = shell
self.holes = holes
self._calculate_key_points()
If 'None' is entered for 'holes' it raises a TypeError
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels