Shortcuts

Source code for mmocr.utils.point_utils

# Copyright (c) OpenMMLab. All rights reserved.
import numpy as np

from mmocr.utils.typing_utils import ArrayLike


[docs]def points_center(points: ArrayLike) -> np.ndarray: """Calculate the center of a set of points. Args: points (ArrayLike): A set of points. Returns: np.ndarray: The coordinate of center point. """ points = np.array(points, dtype=np.float32) assert points.size % 2 == 0 points = points.reshape([-1, 2]) return np.mean(points, axis=0)
[docs]def point_distance(pt1: ArrayLike, pt2: ArrayLike) -> float: """Calculate the distance between two points. Args: pt1 (ArrayLike): The first point. pt2 (ArrayLike): The second point. Returns: float: The distance between two points. """ pt1 = np.array(pt1) pt2 = np.array(pt2) assert (pt1.size == 2 and pt2.size == 2) dist = np.square(pt2 - pt1).sum() dist = np.sqrt(dist) return dist
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.