ovl.directions.director module

class ovl.directions.director.Director(directing_function: Callable, failed_detection: Any = None, target_amount: int = 1, direction_modifiers: List[ovl.direction_modifiers.direction_modifier.DirectionModifier] = None)[source]

Bases: object

Directors are object that extract usable information from the objects that were detected image. This information be where they are located in the image relative to the center (directions for a robot), how many objects were detected, identifying an object or any other logical usage of the object detection rather than raw image processing or computer vision. This is the final step before sending/using the data.

Director.direct works in the following way: - if the amount of contours is less than target amount then set directions to failed_detection - else it passes only target_amount of contours to the direction function - The final result (direction function or failed_detection) is passed to the direction monitors - each monitor is applied to the result and its result is passed to the next one - then the final result is returned

apply_direction_monitors(directions: Any, contours: List[numpy.ndarray], image: numpy.ndarray) → Any[source]

Applies the list of direction monitors one after the other

Direction monitors are functions that receive directions contours image and camera settings and change it some way, like applying a PID feedback loop, returning a “stop” value based on some condition (like getting close enough to the target)

Parameters:
  • directions – the raw directions returned from the directions function
  • contours – the list of contours that passed all filters
  • image – the image from which the contours were found
Returns:

the final direction result

direct(contours: List[numpy.ndarray], image: numpy.ndarray, sorter=None) → Any[source]

Returns the directions using the vision.director for the given contours using the image and camera settings (if given).

Director.direct works in the following way:
  • if the amount of contours is less than target amount then set directions to failed_detection
  • else it passes only target_amount of contours to the direction function
  • The final result (direction function or failed_detection) is passed to the direction monitors
  • each monitor is applied to the result and its result is passed to the next one
  • then the final result is returned
Parameters:
  • contours – the list of contours (numpy ndarrays) from which to extrapolate target direction
  • image – the image from which the contours were taken
  • sorter – A sorter function to be applied on the contours, or None to not apply one
Returns:

Depends on the directing function and the direction monitors, usually a number or a string