コード例 #1
0
axis('off')

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#### STEP I: COMPUTE HOMOGRAPHY BETWEEN 2 IMAGES
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impath1 = '../../data/other/all_souls_000015.jpg'
im1 = Image.open(impath1)
frames1, sift1 = week2.compute_sift(impath1)

impath2 = '../../data/other/all_souls_000091_half.jpg'
im2 = Image.open(impath2)
frames2, sift2 = week2.compute_sift(impath2)

matches = week2.match_sift(sift1, sift2, 1.15) # BY NOW YOU SHOULD HAVE THIS ALREADY IMPLEMENTED
H, inliers = homography.estimate_homography_with_ransac(frames1, frames2, matches) # ALREADY PROVIDED

ix = matches != -1
# PLOT GOOD MATCHES
good_matches = -1 * np.ones(frames1.shape[0])
good_matches[inliers] = inliers
week2.plot_matches(im1, im2, frames1[ix], frames2[matches[ix]], good_matches)

# PLOT BAD MATCHES WITH A DIFFERENT COLOR
bad_matches = np.arange(frames1.shape[0])
bad_matches[inliers] = -1
week2.plot_matches(im1, im2, frames1[ix], frames2[matches[ix]], bad_matches, 'b', False)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#### STEP J: IMAGE RECOGNITION WITH GEOMETRIC VERIFICATION
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
コード例 #2
0
ファイル: main_script_week2.py プロジェクト: pkok/MIS-labs
"""
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#### STEP I: COMPUTE HOMOGRAPHY BETWEEN 2 IMAGES
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

impath1 = '../../data/other/all_souls_000026.jpg'
im1 = Image.open(impath1)
frames1, sift1 = week2.compute_sift(impath1)

impath2 = '../../data/other/all_souls_000068.jpg'
im2 = Image.open(impath2)
frames2, sift2 = week2.compute_sift(impath2)

matches = week2.match_sift(sift1, sift2, 1.1) # BY NOW YOU SHOULD HAVE THIS ALREADY IMPLEMENTED
week2.store_cache()
H, inliers = homography.estimate_homography_with_ransac(frames1, frames2, matches) # ALREADY PROVIDED

# PLOT GOOD MATCHES
good_matches = -1 * np.ones(frames1.shape[0])
good_matches[inliers] = inliers
week2.plot_matches(im1, im2, frames1[ix], frames2[matches[ix]], good_matches)

# PLOT BAD MATCHES WITH A DIFFERENT COLOR
bad_matches = np.arange(frames1.shape[0])
bad_matches[inliers] = -1
week2.plot_matches(im1, im2, frames1[ix], frames2[matches[ix]], bad_matches, 'b', False)

#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#### STEP J: IMAGE RECOGNITION WITH GEOMETRIC VERIFICATION
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~