def compute(self, img, kps, mask=None): #mask is a fake input num_kps = len(kps) des = [] if num_kps>0: if not self.process_all: # compute descriptor for each patch patches = extract_patches_tensor(img, kps, patch_size=32, mag_factor=self.mag_factor) # patches /= 255. # patches -= 0.443728476019 # patches /= 0.20197947209 patches = (patches/255. - 0.443728476019)/0.20197947209 des = self.compute_des_batches(patches).astype(np.float32) else: # compute descriptor by feeeding the full patch tensor to the network t = time.time() if False: # use python code patches = extract_patches_array(img, kps, patch_size=32, mag_factor=self.mag_factor) else: # use faster cpp code patches = extract_patches_array_cpp(img, kps, patch_size=32, mag_factor=self.mag_factor) patches = np.asarray(patches) if kVerbose: print('patches.shape:',patches.shape) # patches /= 255. # patches -= 0.443728476019 # patches /= 0.20197947209 patches = (patches/255. - 0.443728476019)/0.20197947209 if kVerbose: print('patch elapsed: ', time.time()-t) des = self.compute_des(patches) # if kVerbose: # print('descriptor: HARDNET, #features: ', len(kps), ', frame res: ', img.shape[0:2]) return kps, des
def compute(self, frame, kps, mask=None): #mask is a fake input #print('kps: ', kps) if len(kps) > 0: #des = tfeat_utils.describe_opencv(self.model, frame, kps, 32, self.mag_factor) # extract the keypoint patches #t = time.time() if False: # use python code patches = extract_patches_array(frame, kps, patch_size=32, mag_factor=self.mag_factor) else: # use faster cpp code patches = extract_patches_array_cpp(frame, kps, patch_size=32, mag_factor=self.mag_factor) patches = np.asarray(patches) #if kVerbose: # print('patches.shape:',patches.shape) #if kVerbose: # print('patch elapsed: ', time.time()-t) # compute descriptor by feeeding the full patch tensor to the network des = self.compute_des(patches) else: des = [] # if kVerbose: # print('descriptor: TFEAT, #features: ', len(kps), ', frame res: ', frame.shape[0:2]) return kps, des
def compute(self, frame, kps, mask=None): #mask is a fake input #print('kps: ', kps) if len(kps)>0: if False: # use python code patches = extract_patches_array(frame, kps, patch_size=32, mag_factor=self.mag_factor) else: # use faster cpp code patches = extract_patches_array_cpp(frame, kps, patch_size=32, mag_factor=self.mag_factor) patches = np.asarray(patches) des = self.process_patches(patches) else: des = [] if kVerbose: print('descriptor: GEODESC, #features: ', len(kps), ', frame res: ', frame.shape[0:2]) return kps, des
def compute(self, frame, kps, mask=None): #mask is a fake input #print('kps: ', kps) if len(kps)>0: if False: # use python code patches = extract_patches_array(frame, kps, patch_size=32, mag_factor=self.mag_factor) else: # use faster cpp code patches = extract_patches_array_cpp(frame, kps, patch_size=32, mag_factor=self.mag_factor) patches = np.asarray(patches) patches = np.expand_dims(patches, -1) self.des = self.l2net.calc_descriptors(patches) else: self.des = [] if kVerbose: print('descriptor: L2NET, #features: ', len(kps), ', frame res: ', frame.shape[0:2]) return kps, self.des