def hand_generator(self): for root, directories, files in walk(self.color_folder): for c_filename in files: if self.c_file_ext in c_filename: try: c_filepath = path.join(root, c_filename) d_filepath = c_filepath.replace('color', 'depth').replace(self.c_file_ext, self.d_file_ext) _, c_data = utils.load_data(c_filepath, self.data_type) d_data, d_data_norm = utils.load_data(d_filepath, 'depth') c_fgmask = self.c_fgbg.apply(c_data) c_fgmask = cv2.morphologyEx(c_fgmask, cv2.MORPH_OPEN, self.kernel) img_bs = d_data_norm.copy() img_bs[c_fgmask==0] = 0 img_bs = ip.smooth_image(img_bs) boxes = ip.parse_hands(img_bs, display=False) hands = Hands(c_fgmask, d_data, boxes, d_filepath, 'depth') yield hands except Exception as e: print e
def hand_generator(self): for root, directories, files in walk(self.folder): for filename in files: if self.file_ext in filename: filepath = path.join(root, filename) data, data_norm = utils.load_data(filepath, self.data_type) fgmask = self.fgbg.apply(data_norm) fgmask = cv2.morphologyEx(fgmask, cv2.MORPH_OPEN, self.kernel) img_bs = data.copy() img_bs[fgmask==0] = 0 img_bs = ip.smooth_image(img_bs) orig_mask = fgmask.copy() fgmask, thresh_val = self.remove_legs(img_bs) img_fg = data_norm.copy() img_fg[fgmask==0] = 0 boxes = ip.parse_hands(fgmask, display=False) hands = Hands(fgmask, data, boxes, filepath, 'depth') yield hands