ovl.target_filters.shape_filters.polygon_filter module

ovl.target_filters.shape_filters.polygon_filter.polygon_filter(contour_list, side_amount=6, min_angle_ratio: Union[float, ovl.helpers.types.RangedNumber.<locals>.Hint] = 0.7, min_area_ratio: Union[float, ovl.helpers.types.RangedNumber.<locals>.Hint] = 0.7, min_len_ratio: Union[float, ovl.helpers.types.RangedNumber.<locals>.Hint] = 0.7, approximation_coefficient: Union[float, ovl.helpers.types.RangedNumber.<locals>.Hint] = 0.02)[source]
A filter that Detects regular polygon of n-sides sides
Parameters:
  • contour_list – the list of contours to be filtered
  • side_amount – the amount of sides the wanted polygon has.
  • min_angle_ratio – the minimum ratio between the each angle and the average angle and the average angle and the

target angle of a shape of side_amount :param min_area_ratio: The minimum ratio between the contour’s area and the target area :param min_len_ratio: The minimum ratio between the length of each side and the average length and between the average length. :param approximation_coefficient: the coefficient for the function cv2.approxPolyDP. :return: the list of contours (numpy ndarrays) that passed the filter and are regular polygon