ovl.target_filters.contour_filters module

ovl.target_filters.contour_filters.absolute_distance_filter(contour_list, max_dist=50, min_dist=0, image_dimensions=(320, 240))[source]

Filters out contours that their center is not close enough to the center of the image

Parameters:
  • contour_list – a list of contours to be filtered
  • image_dimensions – the size of the image(width, height)
  • max_dist – the maximum distance from the center in pixels
  • min_dist – the minimum distance from the center in pixels
Returns:

ovl.target_filters.contour_filters.area_filter(contour_list, min_area: float = 200, max_area: float = inf)[source]

Filters contours that are not within the threshold of area (in pixels)

Parameters:
  • max_area – maximum area of a contour (Inclusive) default is no limit (infinity)
  • min_area – minimum area of a contour (Inclusive) set to 0 for no lower limit.
  • contour_list – List of Contours to filter
Returns:

the contour list filtered.

ovl.target_filters.contour_filters.distance_filter(contour_list, point: Tuple[int, int], min_dist: float = 0, max_dist: float = 50)[source]

Filters out contours that their center is not close enough to the given (x, y) point in the image

Parameters:
  • contour_list – a list of contours to be filtered
  • point – the point from which the contours should be filtered a tuple (or list) of 2 numbers.
  • max_dist – the maximum distance from the point in pixels
  • min_dist – the minimum distance from the point in pixels
Returns:

the filtered contour list

ovl.target_filters.contour_filters.image_center_filter(contour_list, image_dimensions: Tuple[int, int] = (320, 240), min_ratio: Union[float, ovl.helpers.types.RangedNumber.<locals>.Hint] = 0.7, max_ratio: Union[float, ovl.helpers.types.RangedNumber.<locals>.Hint] = inf)[source]

Filters out contours that their center is not close enough to the center of the image

Parameters:
  • contour_list – a list of contours to be filtered
  • image_dimensions – the size of the image(width, height)
  • min_ratio – the minimum ratio between the distance from the image center to the distance from the frame
  • max_ratio – the maximum ratio between the distance from the image center to the distance from the frame
Returns:

list of contours within the maximum distance from the image center

ovl.target_filters.contour_filters.length_filter(contour_list, min_length=50, max_length=76800)[source]

Receives a list of contours and removes ones that are not long enough Note: for “open” contours only!

Parameters:
  • contour_list – list of contours (numpy array) to be filtered
  • min_length – minimum length of a contour (in pixels)
  • max_length – maximum length of a contour (in pixels)
Returns:

list of filtered contours and list of the lengths

ovl.target_filters.contour_filters.percent_area_filter(contour_list, minimal_percent: Union[float, ovl.helpers.types.RangedNumber.<locals>.Hint] = 0.02, maximum_percent: Union[float, ovl.helpers.types.RangedNumber.<locals>.Hint] = 1, image_dimensions: Tuple[int, int] = (320, 240))[source]

Filters out contours that are not in the specified ratio to the area of the image (1% -> 0.1)

Parameters:
  • contour_list – list of contours to be filtered (numpy.ndarray)
  • minimal_percent – the minimal ratio between the contour area and the image area
  • maximum_percent – the maximum ratio between the contour area and the image area
  • image_dimensions – The (width, height) of the image in pixels,
ovl.target_filters.contour_filters.size_ratio_filter(contours, min_ratio: float = 2, max_ratio: float = inf, reverse_ratio=False)[source]

Sorts out contours by the ratio between their width and height

Parameters:
  • contours – the contours to be filtered
  • min_ratio – the minimum ratio
  • max_ratio – the maximum ratio default
  • reverse_ratio – reversed the ratio to be height to width
Returns:

the filtered list