Shortcuts

mmocr.utils.offset_polygon

mmocr.utils.offset_polygon(poly, distance)[source]

Offset (expand/shrink) the polygon by the target distance. It’s a wrapper around pyclipper based on Vatti clipping algorithm.

Warning

Polygon coordinates will be casted to int type in PyClipper. Mind the potential precision loss caused by the casting.

Parameters
  • poly (ArrayLike) – A polygon. In any form can be converted to an 1-D numpy array. E.g. list[float], np.ndarray, or torch.Tensor. Polygon is written in [x1, y1, x2, y2, …].

  • distance (float) – The offset distance. Positive value means expanding, negative value means shrinking.

Returns

1-D Offsetted polygon ndarray in float32 type. If the result polygon is invalid or has been split into several parts, return an empty array.

Return type

np.array

Read the Docs v: dev-1.x
Versions
latest
stable
v1.0.1
v1.0.0
0.x
v0.6.3
v0.6.2
v0.6.1
v0.6.0
v0.5.0
v0.4.1
v0.4.0
v0.3.0
v0.2.1
v0.2.0
v0.1.0
dev-1.x
Downloads
pdf
html
epub
On Read the Docs
Project Home
Builds

Free document hosting provided by Read the Docs.