Exemplo n.º 1
0
        # seems we've found a match for feature sift1[i]
        # adding the sift2 index to our match array
        matches[i] = dist_sift_sort[dist_frst]
    else:
        # no match for sift1[i] in sift2.
        # so no kudos for this one
        matches[i] = -1

# STEP C.2 COMPUTE DISTANCES BETWEEN ALL VECTORS IN SIFT1 AND SIFT2.

# PUT YOUR CODE IN week2.match_sift, SO THAT IT CAN BE CALLED AS
#dist_thresh = ...
#matches = week2.match_sift(sift1, sift2, dist_thres) # [YOU NEED TO IMPLEMENT THIS]

# NOW YOU ARE ABLE TO PLOT THE MATCHES AND GET SOMETHING LIKE IN FIG.1 OF THE HANDOUT
week2.plot_matches(im1, im2, frames1, frames2, matches) # [ALREADY IMPLEMENTED]

# !!! EXPERIMENT FOR DIFFERENT VALUES OF DIST_THRESH AND CONTINUE WITH THAT ONE.
# !!! REPORT THIS VALUE IN YOUR REPORT
# Rog - Result for assignment in C2
impath1 = '../../data/oxford_scaled/all_souls_000075.jpg'
frames1, sift1 = week2.compute_sift(impath1)
impath2 = '../../data/oxford_scaled/all_souls_000076.jpg'
frames2, sift2 = week2.compute_sift(impath2)

im1 = Image.open(impath2)
im2 = Image.open(impath2)

matches = week2.match_sift(sift1, sift2, 1.15)
week2.plot_matches(im1, im2, frames1, frames2, matches)
Exemplo n.º 2
0
matches, ranked_ratio = week2.match_sift(sift1, sift2, dist_thresh) # [YOU NEED TO IMPLEMENT THIS]
week2.store_cache()

while True:
    rawinput = raw_input('>> ')
    if rawinput == 'q':
        week2.store_cache()
        sys.exit()
    tmp_matches = -1 * np.ones(matches.shape)
    theta = float(rawinput)
    for i in range(len(matches)):
        if ranked_ratio[i] > theta:
            tmp_matches[i] = matches[i]
    print sum(tmp_matches != -1)
    # NOW YOU ARE ABLE TO PLOT THE MATCHES AND GET SOMETHING LIKE IN FIG.1 OF THE HANDOUT
    week2.plot_matches(im1, im2, frames1, frames2, tmp_matches) # [ALREADY IMPLEMENTED]
    plt.show()

"""
# !!! EXPERIMENT FOR DIFFERENT VALUES OF DIST_THRESH AND CONTINUE WITH THAT ONE.
# !!! REPORT THIS VALUE IN YOUR REPORT

##############################################################################
#### PART 3. SIFT FEATURES ARE INVARIANT TO
##############################################################################

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#### STEP D: ROTATION (REPEAT FOR 15, 30, 45, 60, 75, 90)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
impath1 = '../../data/oxford_scaled/all_souls_000026.jpg'
frames1, sift1 = week2.compute_sift(impath1)