Esempio n. 1
0
def grid_suppress(points, weights, cell_size, cell_point_n):
    cells = np.array(points // cell_size, np.int32).view(np.int64).ravel()
    n = len(points)
    mask = np.zeros(n, np.bool8)
    for _, idxs in common.iter_grouped(cells, np.arange(n)):
        best_idxs = idxs[weights[idxs].argsort()[-cell_point_n:]]
        mask[best_idxs] = True
    return mask
Esempio n. 2
0
def grid_suppress(points, weights, cell_size, cell_point_n):
    cells = np.array(points // cell_size, np.int32).view(np.int64).ravel()
    n = len(points)
    mask = np.zeros(n, np.bool8)
    for _, idxs in common.iter_grouped(cells, np.arange(n)):
        best_idxs = idxs[weights[idxs].argsort()[-cell_point_n:]]
        mask[best_idxs] = True
    return mask
Esempio n. 3
0
def grid_suppress_kp(key_points, target_count, columns, img_size):
    if len(key_points) == 0:
        return key_points

    w, h = img_size
    rows = 1.0 * h / w * columns
    target_per_cell = int(target_count // (rows * columns))
    cell_size = w / columns

    key_points = np.array(key_points)
    cells = np.int32(np.int32([kp.pt for kp in key_points]) // cell_size)
    cells = cells.view(np.int64).ravel()
    res = []
    for _, kps in common.iter_grouped(cells, key_points):
        w = np.float32([kp.response for kp in kps])
        idx = w.argsort()[-target_per_cell:]
        res.extend(kps[idx])
    return res
Esempio n. 4
0
def grid_suppress_kp(key_points, target_count, columns, img_size):
    if len(key_points) == 0:
        return key_points

    w, h = img_size
    rows = 1.0 * h / w * columns
    target_per_cell = int(target_count // (rows * columns))
    cell_size = w / columns

    key_points = np.array(key_points)
    cells = np.int32(np.int32([kp.pt for kp in key_points]) // cell_size)
    cells = cells.view(np.int64).ravel()
    res = []
    for _, kps in common.iter_grouped(cells, key_points):
        w = np.float32([kp.response for kp in kps])
        idx = w.argsort()[-target_per_cell:]
        res.extend(kps[idx])
    return res