예제 #1
0
파일: matcher.py 프로젝트: caomw/Leporis
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
예제 #2
0
파일: matcher.py 프로젝트: caomw/Leporis
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
예제 #3
0
파일: matcher.py 프로젝트: caomw/Leporis
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
예제 #4
0
파일: matcher.py 프로젝트: caomw/Leporis
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