Roundness
- tomni.contour_operations.roundness(contour: numpy.ndarray) float [source]
Calculate the roundness of a contour.
The roundness is determined by the ratio of the area of the contour to the area of the minimum enclosing circle.
- Parameters
contour (np.ndarray) – An OpenCV contour of a single object.
- Returns
The roundness value, ranging from 0 to 1, where 1 indicates a perfect circle.
- Return type
float
Examples
>>> contour = np.array([[[1, 2]], [[2, 3]], [[3, 2]], [[2, 1]]]) >>> roundness(contour) 0.8367346938775511