def read_corr(self, sid1, sid2): ''' Output: corr_2to1: (h,w,2) correspondence from image 2 to image 1. corr_2to1[y,x] = [u,v], means image2[y,x] -> image1[v,u] mask_2: (h,w) visibility mask of image 2. 0: human pixel with correspondence 1: human pixel without correspondece 2: background pixel ''' fn = os.path.join(self.corr_dir, '%s_%s.corr'%(sid2, sid1)) corr_2to1, vis_2 = flow_util.read_corr(fn) vis_2 = vis_2[...,np.newaxis] if self.opt.vis_smooth_rate > 0: vis_2b = cv2.medianBlur(vis_2, self.opt.vis_smooth_rate)[...,np.newaxis] m = (vis_2<2).astype(np.uint8) vis_2 = vis_2b*m + vis_2*(1-m) return corr_2to1, vis_2
def read_corr(self, sid1, sid2): ''' Output: corr_2to1: (h, w, 2) vis_2: (h, w) ''' try: fn = os.path.join(self.corr_dir, '%s_%s.corr' % (sid2, sid1)) corr_2to1, vis_2 = flow_util.read_corr(fn) vis_2 = vis_2[..., np.newaxis] if self.opt.vis_smooth_rate > 0: vis_2b = cv2.medianBlur(vis_2, self.opt.vis_smooth_rate)[..., np.newaxis] m = (vis_2 < 2).astype(np.uint8) vis_2 = vis_2b * m + vis_2 * (1 - m) return corr_2to1, vis_2 except: h, w = self.opt.image_size return np.zeros((h, w, 2), dtype=np.float32), np.ones( (h, w, 1), dtype=np.float32) * 2