def __init__(self): with open('vocabulary-new.pkl', 'rb') as f: self.voc = pickle.load(f) url = 'static/' self.imlist = vocabulary.get_img_list(url) self.feature = vocabulary.get_feature_list(url) self.nbr_images = len(self.imlist) self.ndx = range(self.nbr_images) self.maxres = 15 self.header = """ <!doctype html> <head> <title>Image search</title> </head> <body> """ self.footer = """
# encoding:UTF-8 import pickle import sift import imagesearch import homography import vocabulary from vocabulary import * if __name__=='__main__': url = '/home/aurora/hdd/workspace/PycharmProjects/data/pcv_img/first1000/' imlists = vocabulary.get_img_list(url) feature = vocabulary.get_feature_list(url) nbr_images = len(imlists) with open('vocabulary-new.pkl', 'rb') as f: voc = pickle.load(f) src = imagesearch.Searcher('test.db', voc) q_ind = 50 nbr_results = 20 res_reg = [w[1] for w in src.query(imlists[q_ind])[:nbr_images]] print 'top matches (regular):', res_reg q_locs, q_descr = sift.read_feature_from_file(feature[q_ind]) fp = homography.make_homog(q_locs[:, :2].T) model = homography.RansacModel() rank = {} # load image features for result #载入候选图像的特征