gbvision.utils.continuity package

Submodules

gbvision.utils.continuity.continues_circle module

class gbvision.utils.continuity.continues_circle.ContinuesCircle(shape, frame: Optional[numpy.ndarray], tracker: gbvision.utils.tracker.Tracker = None, max_area_ratio=2.0, max_distance_ratio=2.0)[source]

Bases: gbvision.utils.continuity.continues_shape.ContinuesShape

An implementation of ContinuesShape to circles. used to try and check whether two circles are indeed the same one.

gbvision.utils.continuity.continues_rect module

class gbvision.utils.continuity.continues_rect.ContinuesRect(shape, frame: Optional[numpy.ndarray], tracker: gbvision.utils.tracker.Tracker = None, max_area_ratio=2.0, max_distance_ratio=2.0)[source]

Bases: gbvision.utils.continuity.continues_shape.ContinuesShape

An implementation of ContinuesShape to rectangles. used to try and check whether two rectangles are indeed the same one.

gbvision.utils.continuity.continues_rotated_rect module

class gbvision.utils.continuity.continues_rotated_rect.ContinuesRotatedRect(shape, frame: Optional[numpy.ndarray], tracker: gbvision.utils.tracker.Tracker = None, max_area_ratio=2.0, max_distance_ratio=2.0)[source]

Bases: gbvision.utils.continuity.continues_shape.ContinuesShape

An implementation of ContinuesShape to rotated rectangles. used to try and check whether two rotated rectangles are indeed the same one.

gbvision.utils.continuity.continues_shape module

class gbvision.utils.continuity.continues_shape.ContinuesShape(shape, frame: Optional[numpy.ndarray], tracker: gbvision.utils.tracker.Tracker = None, max_area_ratio=2.0, max_distance_ratio=2.0)[source]

Bases: abc.ABC

An abstract class who’s target is to determine in which case two shapes are describing the same object, and by that represent a shape in a continues matter.

in case that no shape matching the object is found then the tracker is deployed by using force_update.

Parameters:
  • shape – the shape to track with continuity
  • frame – the frame from which the shape was taken
  • tracker – optional, a tracker used to track the object if it wasn’t found with continuity (default is an empty tracker)
  • max_area_ratio – the maximum ration between areas of the current shape and another shape so that they can be thought of as the same, default is 2.0
  • max_distance_ratio – the maximum ratio between the sum of areas of this shape and another and their distance, default is 0.1
get() → Shape[source]

retrieve the shape that this continues shape tracks

Returns:this continues shape’s inner shape
is_lost(max_count: int) → bool[source]

check if it has been too long (more that max_count frames) since you last saw the object

:param max_count:the maximum amount of frames tolerable before the shape is declared lost, None is infinity :return: lost or not

update(shape: Shape, frame: Optional[numpy.ndarray]) → bool[source]

an annual check updating the location and data of the object :param shape: the shape suspect as the same object :param frame: the frame on which the suspect shape is :return: true or false, same shape, not the same shape

update_forced(frame: Optional[numpy.ndarray])[source]

an update which happens when you lost the shape with continuity :param frame: the frame on which opencv2 tracking is happening

gbvision.utils.continuity.continues_shape_wrapper module

class gbvision.utils.continuity.continues_shape_wrapper.ContinuesShapeWrapper(shapes: List[Shape], frame: Optional[numpy.ndarray], finding_pipeline: Callable[[Optional[numpy.ndarray]], List[Shape]], shape_type: Union[str, type] = 'RECT', tracker_type: str = 'EMPTY', shape_lifespan: Optional[int] = None, track_new: bool = False, *args, **kwargs)[source]

Bases: object

An object that tracks several shapes in a frame using continuity

Parameters:
  • shapes – A list of shapes to track using continuity (must be of the same shape)
  • frame – The frame from which the shapes were found
  • finding_pipeline – A function that finds the shapes in a given frame and returns a list of them (order irrelevant)
  • shape_type – The type of the shape, can be either ‘CIRCLE’, ‘RECT’, or ‘ROTATED_RECT’, default is ‘RECT’, can also be a class that inherits from ContinuesShape
  • tracker_type – The type of the trackers to use, default is ‘EMPTY’
  • shape_lifespan – The maximum amount of frames for a shape to not be found until it is considered lost
  • track_new – Indicates whether to track new shapes that were un-tracked so far or ignore them, default is False (ignore)
  • args – Additional arguments for continues shape constructor
  • kwargs – Additional keyword arguments for continues shape constructor
SHAPE_TYPE_CIRCLE = 'CIRCLE'
SHAPE_TYPE_RECT = 'RECT'
SHAPE_TYPE_ROTATED_RECT = 'ROTATED_RECT'
find_shapes(frame: Optional[numpy.ndarray]) → Dict[int, Shape][source]

Finds all shapes in the frame, them performs a continues shape operations on them and return the result as a dict where the keys are unique ids and the values are the shapes if a shape was lost it removes it from the tracked shapes list if a new shape was found and the track_new field is set to True it adds it to the tracked shapes list

Parameters:frame – The frame to search in
Returns:A dict mapping from unique ids to shapes, based on continuity
get_shapes() → Dict[int, Shape][source]

Returns the current location of the shapes based on continuity NOTE! this will be applied to the last frame given to the find_shapes method, only use this method if you need to get the shapes twice in an iteration

Returns:A dict mapping from unique ids to shapes
get_shapes_as_list() → List[Shape][source]

Gets all the shapes as a list instead of a dictionary

Returns:A list of all the tracked shapes (sorted by unique id’s)

Module contents