Shortcuts

mmocr.utils.rescale_polygon

mmocr.utils.rescale_polygon(polygon, scale_factor, mode='mul')[source]

Rescale a polygon according to scale_factor.

The behavior is different depending on the mode. When mode is ‘mul’, the coordinates will be multiplied by scale_factor, which is usually used in preprocessing transforms such as Resize(). The coordinates will be divided by scale_factor if mode is ‘div’. It can be used in postprocessors to recover the polygon in the original image size.

Parameters
  • polygon (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, …].

  • scale_factor (tuple(int, int)) – (w_scale, h_scale).

  • model (str) – Rescale mode. Can be ‘mul’ or ‘div’. Defaults to ‘mul’.

  • mode (str) –

Returns

Rescaled polygon.

Return type

np.ndarray

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.