Approximate circle by area
- tomni.contour_operations.approximate_circle_by_area(contour: numpy.ndarray) Tuple[float, float, float] [source]
Approximate a circle with the same area and center as the given contour.
- Parameters
contour (np.ndarray) – An OpenCV contour of a single object.
- Returns
- A tuple containing the following values:
x (float): Center x position of the approximate circle.
y (float): Center y position of the approximate circle.
radius (float): Radius of the approximate circle.
- Return type
Tuple[float, float, float]
Example:
contour = np.array([[[1, 2]], [[2, 3]], [[3, 2]], [[2, 1]]]) center_x, center_y, circle_radius = approximate_circle_by_area(contour) (2.0, 2.0, 1.0)