Ejemplo n.º 1
0
	# get matches

	matches=sift1.match(q_descr,descr)
	ind =matches.nonzero()[0]
	ind2 =matches[ind]
	tp = homography.make_homog(locs[:,:2].T)

	# compute homography,count inliers, if not enough matches return empty list

	try:
		H,inliers = homography.H_from_ransac(fp[:,ind],tp[:,ind2],model,match_theshold=4)

	except:
		inliers =[]

	# store inlier count

	rank[ndx] = len(inliers)


# sort dictionary to get the most inliers first

sorted_rank=sorted(rank.items(),key=lambda t: t[1],reverse=True)
res_geom=[res_reg[0]] + [s[0] for s in sorted_rank]

print 'top matches (homography):',res_geom

# plot the top results

new_imagesearch.plot_results(src,res_reg[:4])
new_imagesearch.plot_results(src,res_geom[:4])
Ejemplo n.º 2
0

def get_imlist(path):

    return [os.path.join(path, f) for f in os.listdir(path) if f.endswith(".pgm")]


imlist = get_imlist("img")

newimlist = []

for i in imlist:
    newimlist.append(i[4:])

with open("vocabulary.pkl", "rb") as f:
    voc = pickle.load(f)


src = new_imagesearch.Searcher("test.db", voc)

print new_imagesearch.compute_ukbench_score(src, newimlist)


# show actual search

nbr_results = 5

res = [w[1] for w in src.query(newimlist[0])[:nbr_results]]
print res
new_imagesearch.plot_results(src, res)