Example #1
0
def get_file_descs(fn):
    #print 'computing descriptors for %s' % fn
    f = path.join('descs', path.basename(fn) + '.npy')
    if path.exists(f):
        descs = np.load(f)
    else:
        frames = util.vidread(fn)
        pts = video.get_interest_points(frames)
        descs = video.compute_descriptors(frames, pts)
        np.save(f, descs)

    return descs
Example #2
0
    pts = pts[:, inds]

    descs = []
    for x, y, t in zip(*pts):
        sub_flo = flo[x - nx : x + nx + 1, y - ny : y + ny + 1, t - nt : t + nt + 1]

        xhist, _ = np.histogram(sub_flo[..., 0], bins=bins)
        yhist, _ = np.histogram(sub_flo[..., 1], bins=bins)
        xhist = xhist.astype(np.float64) / xhist.sum()
        yhist = xhist.astype(np.float64) / yhist.sum()

        descs.append(np.hstack([xhist, yhist]))

    return np.vstack(descs)


## Given an input video, overlay the Harris points and output to a
## file.
if __name__ == "__main__":
    frames = util.vidread(sys.argv[1])
    pts = get_interest_points(frames)

    for x, y, t in zip(*pts):
        frames[
            max(0, x - 3) : min(frames.shape[0], x + 4),
            max(0, y - 3) : min(frames.shape[1], y + 4),
            max(0, t - 1) : min(frames.shape[2], t + 2),
        ] = 255

    util.vidwrite(frames, sys.argv[2])