defget_patch(seq,t,idx):"""Gets a patch from a sequence with type=t and id=idx"""returngetattr(seq, t)[idx]
tps =['ref','e1','e2','e3','e4','e5','h1','h2','h3','h4','h5','t1','t2','t3','t4','t5']
t in tps
seq=hpatch_sequence(os.path.join(datadir,"hpatches-release","v_calder"))classhpatch_sequence:"""Class for loading an HPatches sequence from a sequence folder"""
itr = tps
def__init__(self,base):
name = base.split(os.path.sep)
self.name = name[-1]
self.base = base
for t in self.itr:
im_path = os.path.join(base, t+'.png')
im = cv2.imread(im_path,0)#一条图像
self.N = im.shape[0]/65setattr(self, t, np.split(im, self.N))#切分回一个个图像
读取数据hpatches.pydef get_patch(seq,t,idx): """Gets a patch from a sequence with type=t and id=idx""" return getattr(seq, t)[idx]tps = ['ref','e1','e2','e3','e4','e5','h1','h2','h3','h4','h5', 't1','t2','t3','t4','t5']t in tpsseq=hpatch_sequence