rekall.predicates module

A collection of built-in predicate functions. Each function in this module takes in some number of arguments and returns an anonymous function that evaluates to True or False.

Example

The area_at_least predicate returns a predicate that computes whether a 2D bounding box’s area is at least some value. This is how you would use it:

bbox = { 'x1': 0.1, 'x2': 0.3, 'y1': 0.1, 'y2': 0.3 }
pred = area_at_least(.03)
bbox_satisfies_pred = pred(bbox)
rekall.predicates.above()

Returns a function that takes two 2D bounding boxes and computes whether the first one is strictly above the second one.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the first bounding box’s ‘y2’ value is less than the second bounding box’s ‘y1’ value.

Returns:A function that takes two 2D bounding boxes and returns True if the first bounding box is strictly above the second one.
rekall.predicates.after(min_dist=0, max_dist='infty')

Returns a function that computes whether a temporal interval is after another, optionally filtering the time difference to be between min_dist and max_dist (inclusive).

The output function expects two temporal intervals (dicts with keys ‘t1’ and ‘t2’ for the start and end times, respectively). It returns True if the time difference between the start of the first interval and the end of the second interval is between min_dist and max_dist, inclusive.

Arg:
min_dist: The minimum time difference between the two intervals.
Negative values are undefined.
max_dist: The maximum time difference between the two intervals. If
this is INFTY, then the maximum time difference is unbounded.
Returns:An output function that takes two temporal intervals and returns True if the first interval is after the second interval.
rekall.predicates.and_pred(*preds)

ANDs the predicates.

rekall.predicates.area_at_least(area)

Returns a function that computes whether a 2D bounding box’s area is at least area.

The output function takes in a 2D bounding box (dict with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the bounding box’s area is greater than or equal to area.

Parameters:area – Target area value.
Returns:A function that takes a 2D bounding box and returns True if the bounding box’s area is greater than or equal to area.
rekall.predicates.area_at_most(area)

Returns a function that computes whether a 2D bounding box’s area less than or equal to area.

The output function takes in a 2D bounding box (dict with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the bounding box’s area is less than or equal to area.

Parameters:area – Target area value.
Returns:A function that takes a 2D bounding box and returns True if the bounding box’s area is less than or equal to area.
rekall.predicates.area_between(area1, area2)

Returns a function that computes whether a 2D bounding box’s area is between area1 and area2 (inclusive).

The output function takes in a 2D bounding box (dict with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the bounding box’s area is between area1 and area2.

Parameters:
  • area1 – Minimum area value.
  • area2 – Maximum area value.
Returns:

A function that takes a 2D bounding box and returns True if the bounding box’s area is between area1 and area2.

rekall.predicates.area_exactly(area, epsilon=0.1)

Returns a function that computes whether a 2D bounding box has a certain area (+/- epsilon).

The output function takes in a 2D bounding box (dict with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the absolute difference between the bounding box’s area and the specified area is less than epsilon.

Parameters:
  • area – Target area value.
  • epsilon – Maximum difference between the bounding box’s area and area.
Returns:

A function that takes a 2D bounding box and returns True if the bounding box’s area is within epsilon of area.

rekall.predicates.before(min_dist=0, max_dist='infty')

Returns a function that computes whether a temporal interval is before another, optionally filtering the time difference to be between min_dist and max_dist (inclusive).

The output function expects two temporal intervals (dicts with keys ‘t1’ and ‘t2’ for the start and end times, respectively). It returns True if the time difference between the start of the second interval and the end of the first interval is between min_dist and max_dist, inclusive.

Arg:
min_dist: The minimum time difference between the two intervals.
Negative values are undefined.
max_dist: The maximum time difference between the two intervals. If
this is INFTY, then the maximum time difference is unbounded.
Returns:An output function that takes two temporal intervals and returns True if the first interval is before the second interval.
rekall.predicates.below()

Returns a function that takes two 2D bounding boxes and computes whether the first one is strictly below the second one.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the first bounding box’s ‘y1’ value is greater than the second bounding box’s ‘y2’ value.

Returns:A function that takes two 2D bounding boxes and returns True if the first bounding box is strictly below the second one.
rekall.predicates.contains()

Returns a function that takes two 2D bounding boxes and computes whether the first one contains the second one.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the first one contains the second one (boundaries inclusive).

Returns:A function that takes two 2D bounding boxes and returns True if the first one contains the second one.
rekall.predicates.during()

Returns a function that computes whether a temporal interval takes place entirely during another temporal interval (i.e. it starts after the other interval starts and ends before the other interval ends).

The output function expects two temporal intervals (dicts with keys ‘t1’ and ‘t2’ for the start and end times, respectively). It returns True if the first interval starts strictly after the second interval starts and ends strictly before the second interval ends.

Returns:An output function that takes two temporal intervals and returns True if the first interval takes place strictly during the second interval.
rekall.predicates.during_inv()

Returns a function that computes whether a temporal interval takes place entirely during another temporal interval (i.e. it starts after the other interval starts and ends before the other interval ends). This is the inverse of the during predicate; it checks whether the second interval takes place during the first interval.

The output function expects two temporal intervals (dicts with keys ‘t1’ and ‘t2’ for the start and end times, respectively). It returns True if the second interval starts strictly after the first interval starts and ends strictly before the first interval ends.

Returns:An output function that takes two temporal intervals and returns True if the second interval takes place strictly during the first interval.
rekall.predicates.equal()

Returns a function that computes whether two temporal intervals are strictly equal.

The output function expects two temporal intervals (dicts with keys ‘t1’ and ‘t2’ for the start and end times, respectively). It returns True if the two intervals have equal start times and equal end times.

Returns:An output function that takes two temporal intervals and returns True if the two intervals have equal start times and equal end times.
rekall.predicates.false_pred()

Returns a predicate that always returns False.

rekall.predicates.finishes(epsilon=0)

Returns a function that computes whether a temporal interval has the same end time as another interval (+/- epsilon), and starts after it.

The output function expects two temporal intervals (dicts with keys ‘t1’ and ‘t2’ for the start and end times, respectively). It returns True if the first interval ends at the same time as the second interval (+/- epsilon), and the first interval starts after the second interval.

Parameters:epsilon – The maximum difference between the end time of the first interval and the end time of the second interval.
Returns:An output function that takes two temporal intervals and returns True if the first interval ends at the same time as the second interval, and starts after the second interval starts.
rekall.predicates.finishes_inv(epsilon=0)

Returns a function that computes whether a temporal interval has the same end time as another interval (+/- epsilon), and starts after it. This is the inverse of the finishes predicate; it checks whether the second interval finishes the first interval.

The output function expects two temporal intervals (dicts with keys ‘t1’ and ‘t2’ for the start and end times, respectively). It returns True if the second interval ends at the same time as the first interval (+/- epsilon), and the second interval starts after the first interval.

Parameters:epsilon – The maximum difference between the end time of the second interval and the end time of the first interval.
Returns:An output function that takes two temporal intervals and returns True if the second interval ends at the same time as the first interval, and starts after the first interval starts.
rekall.predicates.has_value(key, target, epsilon=0.1)

Returns a function that computes whether a specified value in a dict is within epsilon of target.

The output function takes in a dict d and returns True if the absolute difference between d[key] and target is less than epsilon.

Parameters:
  • key – Lookup key for the value in the dict to compare.
  • target – The value to compare against.
  • epsilon – Maximum difference between the two values.
Returns:

A function that takes a dict and returns True if the absolute value between dict[key] and target is less than epsilon.

rekall.predicates.height_at_least(height)

Returns a function that computes whether a 2D bounding box’s height is at least height.

The output function takes in a 2D bounding box (dict with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the bounding box’s height is greater than or equal to height.

Parameters:height – Target height value.
Returns:A function that takes a 2D bounding box and returns True if the bounding box’s height is greater than or equal to height.
rekall.predicates.height_at_most(height)

Returns a function that computes whether a 2D bounding box’s height is less than or equal to height.

The output function takes in a 2D bounding box (dict with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the bounding box’s height is less than or equal to height.

Parameters:height – Target height value.
Returns:A function that takes a 2D bounding box and returns True if the bounding box’s height is less than or equal to height.
rekall.predicates.height_between(height1, height2)

Returns a function that computes whether a 2D bounding box’s height is between height1 and height2 (inclusive).

The output function takes in a 2D bounding box (dict with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the bounding box’s height is between height1 and height2.

Parameters:
  • height1 – Minimum height value.
  • height2 – Maximum height value.
Returns:

A function that takes a 2D bounding box and returns True if the bounding box’s height is between height1 and height2.

rekall.predicates.height_exactly(height, epsilon=0.1)

Returns a function that computes whether a 2D bounding box has a certain height (+/- epsilon).

The output function takes in a 2D bounding box (dict with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the absolute difference between the bounding box’s height and the specified height is less than epsilon.

Parameters:
  • height – Target height value.
  • epsilon – Maximum difference between the bounding box’s height and height.
Returns:

A function that takes a 2D bounding box and returns True if the bounding box’s height is within epsilon of height.

rekall.predicates.inside()

Returns a function that takes two 2D bounding boxes and computes whether the first one is inside the second one.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the first one is inside the second one (boundaries inclusive).

Returns:A function that takes two 2D bounding boxes and returns True if the first one is inside the second one.
rekall.predicates.iou_at_least(n)

Returns a function that takes two 2D bounding boxes and computes whether their intersection over area is at least n.

Parameters:n – Minimum IOU (float).
Returns:A function that takes in two 2D bounding boxes and returns True if their IOU is at least n.
rekall.predicates.left_of()

Returns a function that takes two 2D bounding boxes and computes whether the first one is strictly to the left of the second one.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the first bounding box’s ‘x2’ value is less than the second bounding box’s ‘x1’ value.

Returns:A function that takes two 2D bounding boxes and returns True if the first bounding box is strictly to the left of the second one.
rekall.predicates.length_at_least(n)

Returns a function that checks whether a list has length at least n.

Parameters:n – The length to check against.
Returns:A function that takes in a list l and returns True if len(l) is greater than or equal to n.
rekall.predicates.length_at_most(n)

Returns a function that checks whether a list has length less than or equal to n.

Parameters:n – The length to check against.
Returns:A function that takes in a list l and returns True if len(l) is less than or equal to n.
rekall.predicates.length_between(n1, n2)

Returns a function that checks whether a list’s length is between n1 and n2 (inclusive).

Parameters:
  • n1 – The minimum length of the list.
  • n2 – The maximum length of the list.
Returns:

A function that takes in a list l and returns True if len(l) is between n1 and n2 (inclusive).

rekall.predicates.length_exactly(n)

Returns a function that checks whether a list has length exactly n.

Parameters:n – The length to check against.
Returns:A function that takes in a list l and returns True if len(l) is equal to n.
rekall.predicates.less_area()

Returns a function that takes two 2D bounding boxes and computes whether the first one has strictly less area than the second one.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the first bounding box has strictly less area than the second one.

Returns:A function that takes two 2D bounding boxes and returns True if the first bounding box has strictly less area than the second one.
rekall.predicates.less_height()

Returns a function that takes two 2D bounding boxes and computes whether the first one is strictly shorter than the second one.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the first bounding box is strictly shorter than the second one.

Returns:A function that takes two 2D bounding boxes and returns True if the first bounding box is strictly shorter than the second one.
rekall.predicates.less_width()

Returns a function that takes two 2D bounding boxes and computes whether the first one is strictly narrower than the second one.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the first bounding box is strictly narrower than the second one.

Returns:A function that takes two 2D bounding boxes and returns True if the first bounding box is strictly narrower than the second one.
rekall.predicates.meets_after(epsilon=0)

Returns a function that computes whether a temporal interval ends at the same time as another interval starts (+/- epsilon). This is the inverse of the meets_before predicate; it checks whether the first interval starts when the second interval ends.

The output function expects two temporal intervals (dicts with keys ‘t1’ and ‘t2’ for the start and end times, respectively). It returns True if the absolute time difference between the start of the first interval and the end of the second interval is less than epsilon.

Parameters:epsilon – The maximum time difference between the start of the first interval and the end of the second interval.
Returns:An output function that takes two temporal intervals and returns True if the first interval starts at the same time as the second interval ends.
rekall.predicates.meets_before(epsilon=0)

Returns a function that computes whether a temporal interval ends at the same time as another interval starts (+/- epsilon).

The output function expects two temporal intervals (dicts with keys ‘t1’ and ‘t2’ for the start and end times, respectively). It returns True if the absolute time difference between the end of the first interval and the start of the second interval is less than epsilon.

Parameters:epsilon – The maximum time difference between the end of the first interval and the start of the second interval.
Returns:An output function that takes two temporal intervals and returns True if the first interval ends at the same time as the second interval starts.
rekall.predicates.more_area()

Returns a function that takes two 2D bounding boxes and computes whether the first one has strictly more area than the second one.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the first bounding box has strictly more area than the second one.

Returns:A function that takes two 2D bounding boxes and returns True if the first bounding box has strictly more area than the second one.
rekall.predicates.more_height()

Returns a function that takes two 2D bounding boxes and computes whether the first one is strictly taller than the second one.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the first bounding box is strictly taller than the second one.

Returns:A function that takes two 2D bounding boxes and returns True if the first bounding box is strictly taller than the second one.
rekall.predicates.more_width()

Returns a function that takes two 2D bounding boxes and computes whether the first one is strictly wider than the second one.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the first bounding box is strictly wider than the second one.

Returns:A function that takes two 2D bounding boxes and returns True if the first bounding box is strictly wider than the second one.
rekall.predicates.not_pred(pred)

Negates the predicate.

rekall.predicates.on_key(key, pred)

This wraps a predicate so it is applied to a value in a dict instead of the dict itself.

The output function expects one or more dicts as input (depending on how many arguments pred expects) and applies the predicate to d[key] for every dict d of input.

Arg:
key: The key of the dict to apply the predicate to. pred: The predicate to wrap.
Returns:An output function that applies pred to keyed values of dict(s).
rekall.predicates.or_pred(*preds)

ORs the predicates.

rekall.predicates.overlaps()

Returns a function that computes whether a temporal interval overlaps another in any way (including just at the endpoints).

The output function expects two temporal intervals (dicts with keys ‘t1’ and ‘t2’ for the start and end times, respectively). It returns True if the two intervals overlap in any way

Returns:An output function that takes two temporal intervals and returns True if the two intervals overlap in any way.
rekall.predicates.overlaps_after()

Returns a function that computes whether a temporal interval has non-zero overlap with another interval, and starts after it.

The output function expects two temporal intervals (dicts with keys ‘t1’ and ‘t2’ for the start and end times, respectively). It returns True if the first interval starts after the second interval, and the two intervals have a non-zero amount of overlap.

Returns:An output function that takes two temporal intervals and returns True if the first interval starts after the second interval, and the two intervals have non-zero overlap.
rekall.predicates.overlaps_before()

Returns a function that computes whether a temporal interval has non-zero overlap with another interval, and starts before it.

The output function expects two temporal intervals (dicts with keys ‘t1’ and ‘t2’ for the start and end times, respectively). It returns True if the first interval starts before the second interval, and the two intervals have a non-zero amount of overlap.

Returns:An output function that takes two temporal intervals and returns True if the first interval starts before the second interval, and the two intervals have non-zero overlap.
rekall.predicates.payload_satisfies(pred)

This wraps a predicate so it is applied to the payloads of intervals.

The output function expects one or more Intervals as input (depending on how many arguments pred expects) and applies the predicate to the payloads of the Intervals instead of the Intervals themselves.

Arg:
pred: The predicate to wrap.
Returns:An output function that applies pred to payloads.
rekall.predicates.position(x1, y1, x2, y2, epsilon=0.1)

Returns a function that computes whether a 2D bounding box has certain co-ordinates (+/- epsilon).

The output function takes in a 2D bounding box (dict with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the absolute difference between the dict’s values and the specified co-ordinates are all less than epsilon.

Parameters:
  • x1 – Value to compare against the bounding box’s ‘x1’ field.
  • y1 – Value to compare against the bounding box’s ‘y1’ field.
  • x2 – Value to compare against the bounding box’s ‘x2’ field.
  • y2 – Value to compare against the bounding box’s ‘y2’ field.
  • epsilon – Maximum difference against specified co-ordinates.
Returns:

A function that takes a 2D bounding box and returns True if the bounding box’s spatial co-ordinates are all within epsilon of x1, y1, x2, and y2.

rekall.predicates.right_of()

Returns a function that takes two 2D bounding boxes and computes whether the first one is strictly to the right of the second one.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the first bounding box’s ‘x1’ value is greater than the second bounding box’s ‘x2’ value.

Returns:A function that takes two 2D bounding boxes and returns True if the first bounding box is strictly to the right of the second one.
rekall.predicates.same_area(epsilon=0.1)

Returns a function that takes two 2D bounding boxes and computes whether the difference in their areas is less than epsilon.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the difference in their areas is less than epsilon.

Parameters:epsilon – The maximum difference in area between the two bounding boxes.
Returns:A function that takes two 2D bounding boxes and returns True if the difference in their areas is less than epsilon.
rekall.predicates.same_height(epsilon=0.1)

Returns a function that takes two 2D bounding boxes and computes whether the difference in their heights is less than epsilon.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the difference in their heights is less than epsilon.

Parameters:epsilon – The maximum difference in area between the two bounding boxes.
Returns:A function that takes two 2D bounding boxes and returns True if the difference in their heights is less than epsilon.
rekall.predicates.same_value(key, epsilon=0.1)

Returns a function that takes two dicts and computes whether the difference between two of their values is less than epsilon.

The output function takes in two dicts d1 and d2 and returns True if the absolute difference between d1[key] and d2[key] is less than epsilon.

Parameters:epsilon – The maximum difference between the two values of the two dicts.
Returns:A function that takes two dicts and returns True if the absolute difference between two of their values is less than epsilon.
rekall.predicates.same_width(epsilon=0.1)

Returns a function that takes two 2D bounding boxes and computes whether the difference in their widths is less than epsilon.

The output function takes in two 2D bounding boxes (dicts with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the difference in their widths is less than epsilon.

Parameters:epsilon – The maximum difference in area between the two bounding boxes.
Returns:A function that takes two 2D bounding boxes and returns True if the difference in their widths is less than epsilon.
rekall.predicates.starts(epsilon=0)

Returns a function that computes whether a temporal interval has the same start time as another interval (+/- epsilon), and ends before it.

The output function expects two temporal intervals (dicts with keys ‘t1’ and ‘t2’ for the start and end times, respectively). It returns True if the first interval starts at the same time as the second interval (+/- epsilon), and the first interval ends before the second interval.

Parameters:epsilon – The maximum difference between the start time of the first interval and the start time of the second interval.
Returns:An output function that takes two temporal intervals and returns True if the first interval starts at the same time as the second interval, and ends before the second interval ends.
rekall.predicates.starts_inv(epsilon=0)

Returns a function that computes whether a temporal interval has the same start time as another interval (+/- epsilon), and ends before it. This is the inverse of the starts predicate; it checks whether the second interval starts the first interval.

The output function expects two temporal intervals (dicts with keys ‘t1’ and ‘t2’ for the start and end times, respectively). It returns True if the second interval starts at the same time as the first interval (+/- epsilon), and the second interval ends before the first interval.

Parameters:epsilon – The maximum difference between the start time of the second interval and the start time of the first interval.
Returns:An output function that takes two temporal intervals and returns True if the second interval starts at the same time as the first interval, and ends before the first interval ends.
rekall.predicates.true_pred()

Returns a predicate that always returns True.

rekall.predicates.width_at_least(width)

Returns a function that computes whether a 2D bounding box’s width is at least width.

The output function takes in a 2D bounding box (dict with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the bounding box’s width is greater than or equal to width.

Parameters:width – Target width value.
Returns:A function that takes a 2D bounding box and returns True if the bounding box’s width is greater than or equal to width.
rekall.predicates.width_at_most(width)

Returns a function that computes whether a 2D bounding box’s width is less than or equal to width.

The output function takes in a 2D bounding box (dict with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the bounding box’s width is less than or equal to width.

Parameters:width – Target width value.
Returns:A function that takes a 2D bounding box and returns True if the bounding box’s width is less than or equal to width.
rekall.predicates.width_between(width1, width2)

Returns a function that computes whether a 2D bounding box’s width is between width1 and width2 (inclusive).

The output function takes in a 2D bounding box (dict with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the bounding box’s width is between width1 and width2.

Parameters:
  • width1 – Minimum width value.
  • width2 – Maximum width value.
Returns:

A function that takes a 2D bounding box and returns True if the bounding box’s width is between width1 and width2.

rekall.predicates.width_exactly(width, epsilon=0.1)

Returns a function that computes whether a 2D bounding box has a certain width (+/- epsilon).

The output function takes in a 2D bounding box (dict with keys ‘x1’, ‘x2’, ‘y1’, ‘y2’) and returns True if the absolute difference between the bounding box’s width and the specified width is less than epsilon.

Parameters:
  • width – Target width value.
  • epsilon – Maximum difference between the bounding box’s width and width.
Returns:

A function that takes a 2D bounding box and returns True if the bounding box’s width is within epsilon of width.