def mot_in_roi(df, roi):
    """
    Limit MOT to a region of interest.

    :param df: MOT trajectories, DataFrame
    :param roi: utils.roi.ROI
    :return: MOT trajectories, DataFrame
    """
    idx_in_roi = (
        (df.x >= roi.x())
        & (df.y >= roi.y())
        & (df.x < roi.x() + roi.width())
        & (df.y < roi.y() + roi.height())
    )
    return df[idx_in_roi]