paralleldomain.model.annotation.polyline_2d

class Line2D(start, end, class_id, directed=False, instance_id=-1, attributes=<factory>)

Represents a 2D Line.

Parameters:
start

the 2D start point of the line in image coordinates

end

the 2D end point of the line in image coordinates

directed

whether the line is directed from start to end (if False the line is bi-directional)

class_id

Class ID of the line. Can be used to lookup more details in ClassMap.

instance_id

Instance ID of annotated object. Can be used to cross-reference with other instance annotation types, e.g., InstanceSegmentation2D or InstanceSegmentation3D. If unknown defaults to -1.

attributes

Dictionary of arbitrary object attributes.

intersects_at(other)

Returns the point at which the two lines intersect and a bool value that indicated if the intersection point is within the line segments. Returns None if the lines are parallel. See: https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect

Return type:

Tuple[Optional[Point2DBaseGeometry[TypeVar(T, int, float)]], bool, bool]

Parameters:

other (Line2DBaseGeometry[T]) –

to_numpy()

Returns the start and end coordinates as a numpy array with shape (2 x 2).

Return type:

ndarray

property direction: Point2DBaseGeometry[T]

Returns the directional vector of the line.

property length: float

Returns the length of the line.

property slope: float

Returns the slope of the line. Returns np.inf for vertical lines.

class Polyline2D(lines, class_id, instance_id=-1, attributes=<factory>)

A polyline made of a collection of 2D Lines

Parameters:
lines

Ordered list of Line2D instances

class_id

Class ID of the polyline. Can be used to lookup more details in ClassMap.

instance_id

Instance ID of annotated object. Can be used to cross-reference with other instance annotation types, e.g., InstanceSegmentation2D or InstanceSegmentation3D. If unknown defaults to -1.

attributes

Dictionary of arbitrary object attributes.

to_numpy()

Returns all ordered vertices as a numpy array of shape (N x 2).

property length

Returns the length of the line.

class Polylines2D(polylines)

Collection of 2D Polylines

Parameters:

polylines (List[Polyline2D]) – Polylines2D.polylines

polylines

Ordered list of Polyline2D instances