video699.quadrangle.rtree

This module implements a convex quadrangle index that uses the R-tree data structure to efficiently retrieve convex quadrangles. The implementation uses the libspatialindex library exposed through the Rtree Python package. A convex quadrangle tracker that uses the convex quadrangle index is also implemented.

Module Contents

class video699.quadrangle.rtree.RTreeConvexQuadrangleIndex(quadrangles=())

Bases: video699.interface.ConvexQuadrangleIndexABC

A convex quadrangle index that uses the R-tree structure to efficiently retrieve quadrangles.

Parameters:quadrangles (iterable of ConvexQuadrangleABC) – The initial convex quadrangles in the index.
quadrangles

read-only set-like object of ConvexQuadrangleABC – The convex quadrangles in the index.

quadrangles
add(self, quadrangle)
discard(self, quadrangle)
clear(self)
jaccard_indexes(self, input_quadrangle)
class video699.quadrangle.rtree.RTreeDequeConvexQuadrangleTracker(window_size=None)

Bases: video699.interface.ConvexQuadrangleTrackerABC

Quadrangle tracker using RTreeConvexQuadrangleIndex, DequeMovingQuadrangle.

Parameters:window_size (int or None, optional) – The maximum number of previous time frames for which the quadrangle movements are stored. If None or unspecified, then the number of time frames is unbounded.
Raises:ValueError – If the window size is less than two.
clear(self)
update(self, current_quadrangles)

Records convex quadrangles that exist in the current time frame.

The convex quadrangles in the current time frame in the order of iteration are compared with the convex quadrangles in the previous time frame. The current quadrangles that intersect no previous quadrangles are added to the tracker. The current quadrangles that intersect at least one previous quadrangle are considered to be the current position of the previous quadrangle with the largest Jaccard index. The previous quadrangles that cross no current quadrangles are removed from the tracker.

Parameters:current_quadrangles (iterable of ConvexQuadrangleABC) – The convex quadrangles in the current time frame.
Returns:
  • appeared_quadrangles (set of MovingConvexQuadrangleABC) – The current quadrangles that intersect no previous quadrangles.
  • existing_quadrangles (set of MovingConvexQuadrangleABC) – The current quadrangles that intersect at least one previous quadrangle.
  • disappeared_quadrangles (set of MovingConvexQuadrangleABC) – The previous quadrangles that cross no current quadrangles.
__iter__(self)
__len__(self)