Algorithm Search⌘K

Definitioncore

CLEAR MOT metrics

Also called MOTA, MOTP.

MOTA counts misses, false positives and identity switches against the number of objects, and MOTP averages the localization error of matched pairs.

The CLEAR MOT metrics are two numbers that score the output of a multi-object tracker against a ground truth. In each frame, the tracker's hypotheses are matched one to one with the true objects. MOTA, the multiple object tracking accuracy, counts three kinds of errors over the whole video: missed objects, false positives and identity switches, and divides their sum by the number of true objects. MOTP, the multiple object tracking precision, is the mean localization quality of the matched pairs. MOTA weighs detection errors much more than identity errors, which is the weakness that the IDF1 score and HOTA address.

Definition

The ground truth gives, for each frame tt, a set of objects oo with boxes, and the tracker gives a set of hypotheses hh with boxes; an identity stays the same over the frames. A similarity s(o,h)s(o, h), here the intersection over union of the boxes, and a threshold TT decide when a pair is valid: s(o,h)≥Ts(o, h) \ge T. The MOT16 benchmark, on boxes, uses T=0.5T = 0.5. The original paper also allows a distance, such as the distance of two points on the ground, with a pair valid when the distance is below a threshold.

The matching is made frame by frame, and it remembers the matches of the frame before:

  1. CLEAR-MOT(the objects and the hypotheses of each frame, the threshold T)
  2. 1for each frame t:
  3. 2keep each match (o, h) of frame t - 1 when o and h are present and s(o, h) ≥ T
  4. 3match the other objects and hypotheses: the most valid pairs, then the largest total s
  5. 4for each match (o, h): if o was last matched to some h' ≠ h, count an identity switch
  6. 5count the misses (unmatched objects), the false positives (unmatched hypotheses) and the matches
  7. 6MOTA ← 1 - (FN + FP + IDSW) / GT; MOTP ← (sum of s over all matches) / (number of matches)

Line L2 keeps a match even when another hypothesis is closer, as the MOT16 protocol states. Line L3 is an assignment problem, solved with the Hungarian algorithm. Implementations differ in how they weigh the number of pairs against the total similarity; this page takes the most pairs first. The last match of line L4 may be from any earlier frame, so an object that is missed for some frames and then found again by the same hypothesis gives no switch. With GTt\mathrm{GT}_t the number of objects in frame tt, FNt\mathrm{FN}_t, FPt\mathrm{FP}_t and IDSWt\mathrm{IDSW}_t the counts of the frame, ctc_t the number of matches and st,is_{t,i} the similarity of match ii,

MOTA=1−∑t(FNt+FPt+IDSWt)∑tGTt,MOTP=∑t,ist,i∑tct.\mathrm{MOTA} = 1 - \frac{\sum_t (\mathrm{FN}_t + \mathrm{FP}_t + \mathrm{IDSW}_t)}{\sum_t \mathrm{GT}_t}, \qquad \mathrm{MOTP} = \frac{\sum_{t,i} s_{t,i}}{\sum_t c_t}.

With a distance instead of a similarity, MOTP is the mean distance of the matches, and lower is better. These facts follow from the definition and are proved in the correctness file of this page:

  • Theorem: the counts add up. In every frame, the matches plus the misses equal the objects, and the matches plus the false positives equal the hypotheses. The switches are at most the matches.
  • Theorem: the range. MOTA≤1\mathrm{MOTA} \le 1, with equality exactly when there are no errors. MOTA has no lower bound: false positives can make it as negative as we like. With overlap, T≤MOTP≤1T \le \mathrm{MOTP} \le 1.
  • Theorem: the matching of line L3 is optimal. It has the most valid pairs among the remaining objects and hypotheses, and among those the largest total similarity.

Examples and non-examples

  • A small sequence. Two objects move to the right by 2 pixels per frame, from the boxes (0,0,10,10)(0,0,10,10) and (20,0,30,10)(20,0,30,10). In frame 1 the hypotheses are a=(1,0,11,10)a = (1,0,11,10) with IoU 9/119/11 to object 1, bb exactly on object 2, and c=(50,50,60,60)c = (50,50,60,60) on nothing. In frame 2 only bb is there, exactly on object 2, so object 1 is missed. In frame 3 a new hypothesis dd is exactly on object 1, and b=(25,0,35,10)b = (25,0,35,10) has IoU 9/119/11 to object 2. The counts are 6 objects, 5 matches, 1 miss (frame 2), 1 false positive (cc) and 1 identity switch (object 1 goes from aa to dd). So MOTA=1−3/6=1/2\mathrm{MOTA} = 1 - 3/6 = 1/2 and MOTP=(9/11+1+1+1+9/11)/5=51/55≈0.93\mathrm{MOTP} = (9/11 + 1 + 1 + 1 + 9/11) / 5 = 51/55 \approx 0.93.
  • Keeping the last match. An object at (0,0,10,10)(0,0,10,10) is matched to hh in frame 1. In frame 2, hh is at (3,0,13,10)(3,0,13,10) with IoU 7/13≥0.57/13 \ge 0.5, and a second hypothesis gg at (1,0,11,10)(1,0,11,10) has the better IoU 9/119/11. Line L2 keeps (o,h)(o, h), so gg is a false positive and there is no switch: MOTA is 1/21/2. A matching without line L2 would take gg, count a switch and a false positive, and give MOTA 0. Line L2 is what keeps a correct track from being punished for a better box nearby.
  • Negative MOTA. One object over 3 frames, found in each frame, and 3 false positives in each frame: MOTA=1−9/3=−2\mathrm{MOTA} = 1 - 9/3 = -2. MOTA is not a fraction of correct answers.
  • Not a measure of identity. One object over 100 frames. Tracker A follows it with hypothesis aa for 50 frames and then with bb for 50 frames: one switch, MOTA=0.99\mathrm{MOTA} = 0.99. Tracker B finds it in all 100 frames with the same identity, but adds one false positive: also MOTA=0.99\mathrm{MOTA} = 0.99. The IDF1 score of tracker A is 1/21/2, and that of B is 200/201200/201.
  • Not a mean over frames. MOTA sums the errors over the whole video before it divides, so frames with many objects weigh more. A per-frame average of 1−errorst/GTt1 - \text{errors}_t / \mathrm{GT}_t is a different number.

MOTA is built from the same counts as precision and recall of detections: with TP\mathrm{TP} the matches, FN=GT−TP\mathrm{FN} = \mathrm{GT} - \mathrm{TP} and FP=H−TP\mathrm{FP} = \mathrm{H} - \mathrm{TP}, the score without switches is 1−(FN+FP)/GT1 - (\mathrm{FN} + \mathrm{FP})/\mathrm{GT}. Identity enters only through switches, which are events in single frames, so a tracker that keeps a wrong identity for a long time pays only once. The IDF1 score instead matches whole trajectories once for the full video and counts the frames that agree with that match. HOTA combines a detection score and an association score with equal weight, and averages over the threshold TT. The papers of SORT and Deep SORT report MOTA and MOTP; the paper of ByteTrack reports MOTA, IDF1 and HOTA. The Python code of this page computes MOTA and MOTP with exact fractions, and its tests check the matching of line L3 against all matchings, and the whole procedure against a version that uses that brute force matching in every frame.

Proof: The CLEAR MOT matching is a valid one-to-one matching with the most pairs, the counts add up, and MOTA is at most 1 but has no lower boundfull

Notation as on the page. In frame tt, GtG_t is the set of objects, HtH_t the set of hypotheses, s(o,h)∈[0,1]s(o, h) \in [0, 1] the similarity, and a pair is valid when s(o,h)≥Ts(o, h) \ge T with 0<T≤10 < T \le 1. The procedure CLEAR-MOT keeps old matches in line L2, matches the rest in line L3, and counts in lines L4 and L5.

Claim 1: each frame gets a one-to-one matching of valid pairs

After line L3, the set CtC_t of matches of frame tt uses each object and each hypothesis at most once, and every pair in it is valid.

Proof. The matches of line L2 come from Ct−1C_{t-1}, which is one-to-one by induction (C0C_0 is empty), and line L2 keeps only pairs whose two members are present and valid. Line L3 works on the objects and the hypotheses that line L2 did not use, so its pairs share no member with the kept ones. The Hungarian algorithm returns an assignment, which is one-to-one, and the code drops the pairs that are not valid. □\square

Claim 2: line L3 finds the most valid pairs, then the largest total similarity

Let the remaining objects be 1,…,r1, \ldots, r and the remaining hypotheses 1,…,c1, \ldots, c, with similarities sijs_{ij}. Let β=min⁡(r,c)+1\beta = \min(r, c) + 1 and give the pair (i,j)(i, j) the weight wij=β+sijw_{ij} = \beta + s_{ij} if it is valid and 0 if not. A maximum weight assignment, with the pairs of weight 0 then removed, is a matching MM of valid pairs whose key (∣M∣,∑(i,j)∈Msij)(|M|, \sum_{(i,j) \in M} s_{ij}) is the largest in lexicographic order.

Proof. For a matching MM of valid pairs, w(M)=β∣M∣+S(M)w(M) = \beta |M| + S(M) with S(M)=∑sijS(M) = \sum s_{ij}, and 0≤S(M)≤∣M∣≤min⁡(r,c)<β0 \le S(M) \le |M| \le \min(r, c) < \beta. Each such MM extends to an assignment with the same weight by adding pairs of weight 0, and an assignment loses nothing when its pairs of weight 0 are removed. So the maximum weight assignment, after the removal, is a matching M∗M^* of valid pairs that maximizes ww.

Let MM be another matching of valid pairs. If ∣M∣<∣M∗∣|M| < |M^*|, its key is smaller. If ∣M∣>∣M∗∣|M| > |M^*|, then w(M)≥β∣M∣≥β∣M∗∣+β>β∣M∗∣+S(M∗)=w(M∗)w(M) \ge \beta |M| \ge \beta |M^*| + \beta > \beta |M^*| + S(M^*) = w(M^*), against the choice of M∗M^*; so this case does not happen. If ∣M∣=∣M∗∣|M| = |M^*|, then w(M)≤w(M∗)w(M) \le w(M^*) gives S(M)≤S(M∗)S(M) \le S(M^*). In every case the key of MM is at most that of M∗M^*. The Hungarian algorithm finds a maximum weight assignment; the proof of its optimality is on the SORT proof and the Hungarian algorithm page. □\square

The tests compare the key of the matching with the largest key over all matchings of small random matrices.

Claim 3: the counts add up

For every frame, ct+FNt=∣Gt∣c_t + \mathrm{FN}_t = |G_t| and ct+FPt=∣Ht∣c_t + \mathrm{FP}_t = |H_t|, and IDSWt≤ct\mathrm{IDSW}_t \le c_t.

Proof. By Claim 1, CtC_t is one-to-one, so it uses exactly ctc_t objects and ctc_t hypotheses. Line L5 counts the other objects as misses and the other hypotheses as false positives. Line L4 counts at most one switch for each match. □\square

Summing over the frames gives TP+FN=GT\mathrm{TP} + \mathrm{FN} = \mathrm{GT} and TP+FP=∑t∣Ht∣\mathrm{TP} + \mathrm{FP} = \sum_t |H_t|, with TP=∑tct\mathrm{TP} = \sum_t c_t.

Claim 4: the range of MOTA and MOTP

If GT>0\mathrm{GT} > 0, then MOTA≤1\mathrm{MOTA} \le 1, with equality exactly when FN=FP=IDSW=0\mathrm{FN} = \mathrm{FP} = \mathrm{IDSW} = 0. For every real mm there is an input with MOTA<m\mathrm{MOTA} < m. If there is a match, T≤MOTP≤1T \le \mathrm{MOTP} \le 1.

Proof. The three counts are nonnegative, so the fraction in MOTA is at least 0, and it is 0 exactly when all three are 0. For the lower bound, take one object in one frame and kk hypotheses far from it: FN=1\mathrm{FN} = 1 and FP=k\mathrm{FP} = k, so MOTA=1−(k+1)=−k\mathrm{MOTA} = 1 - (k + 1) = -k, which is below mm for k>−mk > -m. MOTP is a mean of similarities of valid pairs, each in [T,1][T, 1] by Claim 1, so the mean is in [T,1][T, 1]. □\square

Claim 5: what an identity switch counts

Let λt(o)\lambda_t(o) be the hypothesis that oo was matched to in its last match before frame tt, if any. Then IDSWt\mathrm{IDSW}_t is the number of matches (o,h)∈Ct(o, h) \in C_t with λt(o)\lambda_t(o) defined and different from hh. In particular, an object that is missed for some frames and then matched again to the same hypothesis adds no switch, and an object that changes its hypothesis kk times over the video adds kk switches.

Proof. The code keeps a table last that it sets to hh for every match (o,h)(o, h) after it tests it, and never changes otherwise. So at the start of frame tt the table holds λt\lambda_t, and line L4 counts exactly the stated matches. A change of hypothesis is a match with h≠λt(o)h \ne \lambda_t(o), which happens kk times. □\square

This shows why MOTA treats identity lightly: a hypothesis that takes the wrong object and keeps it for the rest of the video costs one switch, the same as a short swap.

Code

Each implementation follows the pseudocode above. A comment @line links a line of code to a line of the pseudocode. Point at a line of the pseudocode to see the matching code. The build runs the native tests of each language.

clear_mot_metrics.pyI0RawGitHub
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/clear-mot-metrics/. The authors are listed in prov/TXWACJ.jsonl.
"""The CLEAR MOT metrics MOTA and MOTP (Bernardin and Stiefelhagen 2008), with IoU.

A sequence is a list of frames; a frame is a dict from an identity to a box
(x1, y1, x2, y2). A pair (object o, hypothesis h) is valid when IoU(o, h) >= T.
In each frame:
  1. the pairs of the frame before stay matched if both are present and valid;
  2. the other objects and hypotheses are matched with the most valid pairs,
     and among those the largest total IoU (the Hungarian algorithm);
  3. a match (o, h) is an identity switch if o was last matched to h' != h;
  4. unmatched objects are misses, unmatched hypotheses are false positives.
MOTA = 1 - (FN + FP + IDSW) / GT and MOTP = (sum of IoU of matches) / matches.
With integer boxes all values are exact fractions.
"""

from fractions import Fraction


def iou(a, b):
    w = min(a[2], b[2]) - max(a[0], b[0])
    h = min(a[3], b[3]) - max(a[1], b[1])
    inter = w * h if w > 0 and h > 0 else 0
    union = (a[2] - a[0]) * (a[3] - a[1]) + (b[2] - b[0]) * (b[3] - b[1]) - inter
    return Fraction(inter) / union if union > 0 else Fraction(0)


def hungarian_min(cost):
    """Minimum cost assignment of a rectangular matrix; exact for fractions.
    Returns the sorted pairs (row, column), min(rows, columns) of them."""
    r = len(cost)
    if r == 0 or len(cost[0]) == 0:
        return []
    c = len(cost[0])
    flip = r > c
    if flip:
        cost = [list(col) for col in zip(*cost)]
        r, c = c, r
    inf = float("inf")
    u, v = [0] * (r + 1), [0] * (c + 1)
    p, way = [0] * (c + 1), [0] * (c + 1)
    for i in range(1, r + 1):
        p[0], j0 = i, 0
        minv, used = [inf] * (c + 1), [False] * (c + 1)
        while True:
            used[j0] = True
            i0, delta, j1 = p[j0], inf, 0
            for j in range(1, c + 1):
                if not used[j]:
                    cur = cost[i0 - 1][j - 1] - u[i0] - v[j]
                    if cur < minv[j]:
                        minv[j], way[j] = cur, j0
                    if minv[j] < delta:
                        delta, j1 = minv[j], j
            for j in range(c + 1):
                if used[j]:
                    u[p[j]] += delta
                    v[j] -= delta
                else:
                    minv[j] -= delta
            j0 = j1
            if p[j0] == 0:
                break
        while True:
            j1 = way[j0]
            p[j0] = p[j1]
            j0 = j1
            if j0 == 0:
                break
    pairs = [(p[j] - 1, j - 1) for j in range(1, c + 1) if p[j] != 0]
    if flip:
        pairs = [(b, a) for a, b in pairs]
    return sorted(pairs)


def best_matching(sim, threshold):
    """Among the matchings that use only pairs with sim >= threshold, one with the
    most pairs and, among those, the largest total sim. sim[i][j] lies in [0, 1].
    Returns the sorted list of pairs (i, j)."""
    if not sim or not sim[0]:
        return []
    big = min(len(sim), len(sim[0])) + 1  # one more pair is worth more than any total sim
    cost = [[-(big + s) if s >= threshold else 0 for s in row] for row in sim]
    return [(i, j) for i, j in hungarian_min(cost) if sim[i][j] >= threshold]


def clear_mot(gt_frames, hyp_frames, threshold=Fraction(1, 2), keep_previous=True):
    """Returns a dict with gt, matches, fn, fp, idsw, sum_iou, mota and motp."""
    gt_total = matches = fn = fp = idsw = 0
    sum_iou = Fraction(0)
    previous = {}  # object -> hypothesis, the matches of the frame before
    last = {}  # object -> the hypothesis it was last matched to, in any earlier frame
    for gt, hyp in zip(gt_frames, hyp_frames):  # @line L1
        current = {}
        if keep_previous:
            for o, h in previous.items():  # @line L2
                if o in gt and h in hyp and iou(gt[o], hyp[h]) >= threshold:
                    current[o] = h
        objs = sorted(o for o in gt if o not in current)
        used = set(current.values())
        hyps = sorted(h for h in hyp if h not in used)
        sim = [[iou(gt[o], hyp[h]) for h in hyps] for o in objs]
        for i, j in best_matching(sim, threshold):  # @line L3
            current[objs[i]] = hyps[j]
        for o, h in current.items():
            if o in last and last[o] != h:  # @line L4
                idsw += 1
            last[o] = h
            sum_iou += iou(gt[o], hyp[h])
        gt_total += len(gt)  # @line L5
        matches += len(current)
        fn += len(gt) - len(current)
        fp += len(hyp) - len(current)
        previous = current
    mota = 1 - Fraction(fn + fp + idsw, gt_total) if gt_total else None  # @line L6
    motp = sum_iou / matches if matches else None
    return {"gt": gt_total, "matches": matches, "fn": fn, "fp": fp, "idsw": idsw,
            "sum_iou": sum_iou, "mota": mota, "motp": motp}
test_clear_mot_metrics.py 177 lines
# SPDX-License-Identifier: MIT
# Part of https://algorithm.tamnd.com/clear-mot-metrics/. The authors are listed in prov/TXWACJ.jsonl.

import itertools
import random
from fractions import Fraction

from clear_mot_metrics import best_matching, clear_mot, iou

HALF = Fraction(1, 2)


def brute_matching(sim, threshold):
    """All matchings of valid pairs; the key is (number of pairs, total sim)."""
    rows = len(sim)
    cols = len(sim[0]) if rows else 0
    best_key, best = (0, Fraction(0)), []
    for k in range(min(rows, cols) + 1):
        for rs in itertools.combinations(range(rows), k):
            for cs in itertools.permutations(range(cols), k):
                pairs = list(zip(rs, cs))
                if all(sim[i][j] >= threshold for i, j in pairs):
                    key = (k, sum((sim[i][j] for i, j in pairs), Fraction(0)))
                    if key > best_key:
                        best_key, best = key, pairs
    return best_key


def key_of(sim, pairs):
    return (len(pairs), sum((sim[i][j] for i, j in pairs), Fraction(0)))


def test_iou_values():
    assert iou((0, 0, 10, 10), (1, 0, 11, 10)) == Fraction(9, 11)
    assert iou((0, 0, 10, 10), (3, 0, 13, 10)) == Fraction(7, 13)
    assert iou((0, 0, 10, 10), (20, 0, 30, 10)) == 0


def test_best_matching_against_brute_force():
    rng = random.Random(1)
    for _ in range(300):
        r, c = rng.randint(0, 4), rng.randint(0, 4)
        sim = [[Fraction(rng.randint(0, 10), 10) for _ in range(c)] for _ in range(r)]
        if r == 0:
            sim = []
        pairs = best_matching(sim, HALF)
        assert len({i for i, _ in pairs}) == len(pairs) == len({j for _, j in pairs})
        assert all(sim[i][j] >= HALF for i, j in pairs)
        assert key_of(sim, pairs) == brute_matching(sim, HALF)


PAGE_GT = [
    {1: (0, 0, 10, 10), 2: (20, 0, 30, 10)},
    {1: (2, 0, 12, 10), 2: (22, 0, 32, 10)},
    {1: (4, 0, 14, 10), 2: (24, 0, 34, 10)},
]
PAGE_HYP = [
    {"a": (1, 0, 11, 10), "b": (20, 0, 30, 10), "c": (50, 50, 60, 60)},
    {"b": (22, 0, 32, 10)},
    {"d": (4, 0, 14, 10), "b": (25, 0, 35, 10)},
]


def test_page_example():
    r = clear_mot(PAGE_GT, PAGE_HYP)
    assert (r["gt"], r["matches"], r["fn"], r["fp"], r["idsw"]) == (6, 5, 1, 1, 1)
    assert r["mota"] == HALF
    assert r["motp"] == Fraction(51, 55)


def test_previous_pairs_are_kept():
    gt = [{1: (0, 0, 10, 10)}, {1: (0, 0, 10, 10)}]
    hyp = [{"h": (0, 0, 10, 10)}, {"h": (3, 0, 13, 10), "g": (1, 0, 11, 10)}]
    kept = clear_mot(gt, hyp)
    assert (kept["idsw"], kept["fp"], kept["mota"]) == (0, 1, HALF)
    assert kept["motp"] == (1 + Fraction(7, 13)) / 2
    plain = clear_mot(gt, hyp, keep_previous=False)
    assert (plain["idsw"], plain["fp"], plain["mota"]) == (1, 1, 0)


def test_switch_is_counted_against_the_last_match():
    box = (0, 0, 10, 10)
    gt = [{1: box}] * 4
    hyp = [{"a": box}, {}, {"a": box}, {"b": box}]
    r = clear_mot(gt, hyp)
    assert (r["matches"], r["fn"], r["idsw"]) == (3, 1, 1)


def test_bounds_of_mota():
    box = (0, 0, 10, 10)
    gt = [{1: box}] * 3
    assert clear_mot(gt, [{"a": box}] * 3)["mota"] == 1
    assert clear_mot(gt, [{}] * 3)["mota"] == 0
    far = {"x": (50, 0, 60, 10), "y": (70, 0, 80, 10), "z": (90, 0, 100, 10)}
    assert clear_mot(gt, [dict(far, a=box)] * 3)["mota"] == -2


def random_box(rng):
    x, y = rng.randint(0, 12), rng.randint(0, 12)
    return (x, y, x + rng.randint(3, 6), y + rng.randint(3, 6))


def reference(gt_frames, hyp_frames, threshold):
    """The same procedure with a brute force matching in each frame; returns the counts."""
    previous, last = {}, {}
    out = [0, 0, 0, 0, 0, Fraction(0)]
    for gt, hyp in zip(gt_frames, hyp_frames):
        cur = {o: h for o, h in previous.items() if o in gt and h in hyp and iou(gt[o], hyp[h]) >= threshold}
        objs = [o for o in sorted(gt) if o not in cur]
        hyps = [h for h in sorted(hyp) if h not in cur.values()]
        sim = [[iou(gt[o], hyp[h]) for h in hyps] for o in objs]
        best_key, best = (-1, 0), []
        for k in range(min(len(objs), len(hyps)) + 1):
            for rs in itertools.combinations(range(len(objs)), k):
                for cs in itertools.permutations(range(len(hyps)), k):
                    pairs = list(zip(rs, cs))
                    if all(sim[i][j] >= threshold for i, j in pairs):
                        key = key_of(sim, pairs)
                        if key > best_key:
                            best_key, best = key, pairs
        for i, j in best:
            cur[objs[i]] = hyps[j]
        for o, h in cur.items():
            out[4] += o in last and last[o] != h
            last[o] = h
            out[5] += iou(gt[o], hyp[h])
        out[0] += len(gt)
        out[1] += len(cur)
        out[2] += len(gt) - len(cur)
        out[3] += len(hyp) - len(cur)
        previous = cur
    return out


def random_sequence(rng):
    """Objects that move a little; a tracker that copies them with jitter, sometimes
    with another identity, sometimes not at all, plus random false positives."""
    start = {o: random_box(rng) for o in range(4)}
    names = {o: "abcd"[o] for o in range(4)}
    gt_frames, hyp_frames = [], []
    for t in range(rng.randint(1, 6)):
        gt, hyp = {}, {}
        for o, b in start.items():
            if rng.random() < 0.8:
                gt[o] = (b[0] + t, b[1], b[2] + t, b[3])
                if rng.random() < 0.15:
                    names[o] = rng.choice("abcdef")
                if rng.random() < 0.8 and names[o] not in hyp:
                    dx = rng.randint(-1, 1)
                    g = gt[o]
                    hyp[names[o]] = (g[0] + dx, g[1], g[2] + dx, g[3] + rng.randint(-1, 1))
        if rng.random() < 0.4:
            hyp["z"] = random_box(rng)
        gt_frames.append(gt)
        hyp_frames.append(hyp)
    return gt_frames, hyp_frames


def test_against_reference_and_invariants():
    rng = random.Random(2)
    switches = 0
    for _ in range(80):
        gt_frames, hyp_frames = random_sequence(rng)
        r = clear_mot(gt_frames, hyp_frames)
        ref = reference(gt_frames, hyp_frames, HALF)
        assert [r[k] for k in ("gt", "matches", "fn", "fp", "idsw", "sum_iou")] == ref
        switches += r["idsw"]
        hyp_total = sum(len(h) for h in hyp_frames)
        assert r["fn"] + r["matches"] == r["gt"]
        assert r["fp"] + r["matches"] == hyp_total
        assert r["idsw"] <= r["matches"]
        if r["gt"]:
            assert r["mota"] == 1 - Fraction(r["fn"] + r["fp"] + r["idsw"], r["gt"])
            assert r["mota"] <= 1
        if r["matches"]:
            assert HALF <= r["motp"] <= 1
    assert switches >= 5  # the sequences do exercise identity switches

References

  1. Keni Bernardin and Rainer Stiefelhagen, Evaluating multiple object tracking performance: the CLEAR MOT metrics, EURASIP Journal on Image and Video Processing 2008, article 246309, the whole paper (the frame by frame mapping of hypotheses to objects, the counting of mismatches, and the definitions of MOTP and MOTA)
  2. Anton Milan, Laura Leal-Taixe, Ian Reid, Stefan Roth and Konrad Schindler, MOT16: a benchmark for multi-object tracking, arXiv:1603.00831, 2016, Section IV-A1 (the kept correspondences and the switches against the last known match), Section IV-A2 (the IoU threshold 0.5), Section IV-A4, Eq. 1 (MOTA) and Section IV-A5, Eq. 2 (MOTP)
  3. Ergys Ristani, Francesco Solera, Roger S. Zou, Rita Cucchiara and Carlo Tomasi, Performance measures and a data set for multi-target, multi-camera tracking, ECCV 2016 Workshops, 17-35, the discussion of the measures based on events, such as MOTA, compared with the identity measures
  4. Jonathon Luiten, Aljosa Osep, Patrick Dendorfer, Philip Torr, Andreas Geiger, Laura Leal-Taixe and Bastian Leibe, HOTA: a higher order metric for evaluating multi-object tracking, International Journal of Computer Vision 129(2), 2021, 548-578, Section 4.1 (MOTA in the notation of HOTA) and Section 9.1 (the problems of MOTA, among them that detection outweighs association and that a switch looks only at the previous match)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH2 full proof
  • correctness: no review record reviews/TXWACJ/proof-correctness.yaml
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
Code (python)I0 not checked yet
  • the tests did not run in this build
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW4 complete
  • a review of the text: no review record reviews/TXWACJ/text.yaml