parameters: (roidb, voxelizer)
return_statement: return depth_blob, label_blob,  meta_data_blob, vertex_target_blob, vertex_weight_blob, vertex_image_blob
docstring: build the label blob
docstring_summary: build the label blob
docstring_tokens: build the label blob
function: def _get_label_blob(roidb, voxelizer):
      """ build the label blob """
  
      num_images = len(roidb)
      num_classes = voxelizer.num_classes
      processed_depth = []
      processed_label = []
      processed_meta_data = []
      if cfg.TRAIN.VERTEX_REG:
          processed_vertex_targets = []
          processed_vertex_weights = []
          processed_vertex_images = []
  
      for i in xrange(num_images):
          # load meta data
          meta_data = scipy.io.loadmat(roidb[i]['meta_data'])
          im_depth = pad_im(cv2.imread(roidb[i]['depth'], cv2.IMREAD_UNCHANGED), 16)
  
          # read label image
          im = pad_im(cv2.imread(roidb[i]['label'], cv2.IMREAD_UNCHANGED), 16)
          height = im.shape[0]
          width = im.shape[1]
          # mask the label image according to depth
          if cfg.INPUT == 'DEPTH':
              I = np.where(im_depth == 0)
              if len(im.shape) == 2:
                  im[I[0], I[1]] = 0
              else:
                  im[I[0], I[1], :] = 0
          if roidb[i]['flipped']:
              if len(im.shape) == 2:
                  im = im[:, ::-1]
              else:
                  im = im[:, ::-1, :]
          im_cls, im_labels = _process_label_image(im, roidb[i]['class_colors'], roidb[i]['class_weights'])
          processed_label.append(im_cls)
  
          # vertex regression targets and weights
          if cfg.TRAIN.VERTEX_REG:
              # read vertmap image
              vertmap = pad_im(cv2.imread(roidb[i]['vertmap'], cv2.IMREAD_UNCHANGED), 16)
              if roidb[i]['flipped']:
                  vertmap = vertmap[:, ::-1, :]
              vertmap = vertmap[:, :, (2, 1, 0)]
              vertmap = vertmap.astype(np.float32) / 255.0
              vertex_targets, vertex_weights = _get_vertex_regression_labels(im_labels, vertmap, roidb[i]['class_extents'], num_classes)
              processed_vertex_targets.append(vertex_targets)
              processed_vertex_weights.append(vertex_weights)
              processed_vertex_images.append(vertmap)
              # center_targets, center_weights = _vote_centers(im, meta_data['cls_indexes'], meta_data['center'], num_classes)
              # processed_vertex_targets.append(np.concatenate((center_targets, vertex_targets), axis=2))
              # processed_vertex_weights.append(np.concatenate((center_weights, vertex_weights), axis=2))
  
          # depth
          if roidb[i]['flipped']:
              im_depth = im_depth[:, ::-1]
          depth = im_depth.astype(np.float32, copy=True) / float(meta_data['factor_depth'])
          processed_depth.append(depth)
  
          # voxelization
          points = voxelizer.backproject_camera(im_depth, meta_data)
          voxelizer.voxelized = False
          voxelizer.voxelize(points)
          RT_world = meta_data['rotation_translation_matrix']
  
          # compute camera poses
          RT_live = meta_data['rotation_translation_matrix']
          pose_world2live = se3_mul(RT_live, se3_inverse(RT_world))
          pose_live2world = se3_inverse(pose_world2live)
  
          # construct the meta data
          """
          format of the meta_data
          intrinsic matrix: meta_data[0 ~ 8]
          inverse intrinsic matrix: meta_data[9 ~ 17]
          pose_world2live: meta_data[18 ~ 29]
          pose_live2world: meta_data[30 ~ 41]
          voxel step size: meta_data[42, 43, 44]
          voxel min value: meta_data[45, 46, 47]
          """
          K = np.matrix(meta_data['intrinsic_matrix'])
          Kinv = np.linalg.pinv(K)
          mdata = np.zeros(48, dtype=np.float32)
          mdata[0:9] = K.flatten()
          mdata[9:18] = Kinv.flatten()
          mdata[18:30] = pose_world2live.flatten()
          mdata[30:42] = pose_live2world.flatten()
          mdata[42] = voxelizer.step_x
          mdata[43] = voxelizer.step_y
          mdata[44] = voxelizer.step_z
          mdata[45] = voxelizer.min_x
          mdata[46] = voxelizer.min_y
          mdata[47] = voxelizer.min_z
          if cfg.FLIP_X:
              mdata[0] = -1 * mdata[0]
              mdata[9] = -1 * mdata[9]
              mdata[11] = -1 * mdata[11]
          processed_meta_data.append(mdata)
  
      # construct the blobs
      height = processed_depth[0].shape[0]
      width = processed_depth[0].shape[1]
      depth_blob = np.zeros((num_images, height, width, 1), dtype=np.float32)
      label_blob = np.zeros((num_images, height, width, num_classes), dtype=np.float32)
      meta_data_blob = np.zeros((num_images, 1, 1, 48), dtype=np.float32)
      if cfg.TRAIN.VERTEX_REG:
          vertex_target_blob = np.zeros((num_images, height, width, 2 * num_classes), dtype=np.float32)
          vertex_weight_blob = np.zeros((num_images, height, width, 2 * num_classes), dtype=np.float32)
          vertex_image_blob = np.zeros((num_images, height, width, 3), dtype=np.float32)
      else:
          vertex_target_blob = []
          vertex_weight_blob = []
          vertex_image_blob = []
  
      for i in xrange(num_images):
          depth_blob[i,:,:,0] = processed_depth[i]
          label_blob[i,:,:,:] = processed_label[i]
          meta_data_blob[i,0,0,:] = processed_meta_data[i]
          if cfg.TRAIN.VERTEX_REG:
              vertex_target_blob[i,:,:,:] = processed_vertex_targets[i]
              vertex_weight_blob[i,:,:,:] = processed_vertex_weights[i]
              vertex_image_blob[i,:,:,:] = processed_vertex_images[i]
      
      return depth_blob, label_blob,  meta_data_blob, vertex_target_blob, vertex_weight_blob, vertex_image_blob
function_tokens: def _get_label_blob ( roidb , voxelizer ) : num_images = len ( roidb ) num_classes = voxelizer . num_classes processed_depth = [ ] processed_label = [ ] processed_meta_data = [ ] if cfg . TRAIN . VERTEX_REG : processed_vertex_targets = [ ] processed_vertex_weights = [ ] processed_vertex_images = [ ] for i in xrange ( num_images ) : # load meta data meta_data = scipy . io . loadmat ( roidb [ i ] [ 'meta_data' ] ) im_depth = pad_im ( cv2 . imread ( roidb [ i ] [ 'depth' ] , cv2 . IMREAD_UNCHANGED ) , 16 ) # read label image im = pad_im ( cv2 . imread ( roidb [ i ] [ 'label' ] , cv2 . IMREAD_UNCHANGED ) , 16 ) height = im . shape [ 0 ] width = im . shape [ 1 ] # mask the label image according to depth if cfg . INPUT == 'DEPTH' : I = np . where ( im_depth == 0 ) if len ( im . shape ) == 2 : im [ I [ 0 ] , I [ 1 ] ] = 0 else : im [ I [ 0 ] , I [ 1 ] , : ] = 0 if roidb [ i ] [ 'flipped' ] : if len ( im . shape ) == 2 : im = im [ : , : : - 1 ] else : im = im [ : , : : - 1 , : ] im_cls , im_labels = _process_label_image ( im , roidb [ i ] [ 'class_colors' ] , roidb [ i ] [ 'class_weights' ] ) processed_label . append ( im_cls ) # vertex regression targets and weights if cfg . TRAIN . VERTEX_REG : # read vertmap image vertmap = pad_im ( cv2 . imread ( roidb [ i ] [ 'vertmap' ] , cv2 . IMREAD_UNCHANGED ) , 16 ) if roidb [ i ] [ 'flipped' ] : vertmap = vertmap [ : , : : - 1 , : ] vertmap = vertmap [ : , : , ( 2 , 1 , 0 ) ] vertmap = vertmap . astype ( np . float32 ) / 255.0 vertex_targets , vertex_weights = _get_vertex_regression_labels ( im_labels , vertmap , roidb [ i ] [ 'class_extents' ] , num_classes ) processed_vertex_targets . append ( vertex_targets ) processed_vertex_weights . append ( vertex_weights ) processed_vertex_images . append ( vertmap ) # center_targets, center_weights = _vote_centers(im, meta_data['cls_indexes'], meta_data['center'], num_classes) # processed_vertex_targets.append(np.concatenate((center_targets, vertex_targets), axis=2)) # processed_vertex_weights.append(np.concatenate((center_weights, vertex_weights), axis=2)) # depth if roidb [ i ] [ 'flipped' ] : im_depth = im_depth [ : , : : - 1 ] depth = im_depth . astype ( np . float32 , copy = True ) / float ( meta_data [ 'factor_depth' ] ) processed_depth . append ( depth ) # voxelization points = voxelizer . backproject_camera ( im_depth , meta_data ) voxelizer . voxelized = False voxelizer . voxelize ( points ) RT_world = meta_data [ 'rotation_translation_matrix' ] # compute camera poses RT_live = meta_data [ 'rotation_translation_matrix' ] pose_world2live = se3_mul ( RT_live , se3_inverse ( RT_world ) ) pose_live2world = se3_inverse ( pose_world2live ) # construct the meta data """
          format of the meta_data
          intrinsic matrix: meta_data[0 ~ 8]
          inverse intrinsic matrix: meta_data[9 ~ 17]
          pose_world2live: meta_data[18 ~ 29]
          pose_live2world: meta_data[30 ~ 41]
          voxel step size: meta_data[42, 43, 44]
          voxel min value: meta_data[45, 46, 47]
          """ K = np . matrix ( meta_data [ 'intrinsic_matrix' ] ) Kinv = np . linalg . pinv ( K ) mdata = np . zeros ( 48 , dtype = np . float32 ) mdata [ 0 : 9 ] = K . flatten ( ) mdata [ 9 : 18 ] = Kinv . flatten ( ) mdata [ 18 : 30 ] = pose_world2live . flatten ( ) mdata [ 30 : 42 ] = pose_live2world . flatten ( ) mdata [ 42 ] = voxelizer . step_x mdata [ 43 ] = voxelizer . step_y mdata [ 44 ] = voxelizer . step_z mdata [ 45 ] = voxelizer . min_x mdata [ 46 ] = voxelizer . min_y mdata [ 47 ] = voxelizer . min_z if cfg . FLIP_X : mdata [ 0 ] = - 1 * mdata [ 0 ] mdata [ 9 ] = - 1 * mdata [ 9 ] mdata [ 11 ] = - 1 * mdata [ 11 ] processed_meta_data . append ( mdata ) # construct the blobs height = processed_depth [ 0 ] . shape [ 0 ] width = processed_depth [ 0 ] . shape [ 1 ] depth_blob = np . zeros ( ( num_images , height , width , 1 ) , dtype = np . float32 ) label_blob = np . zeros ( ( num_images , height , width , num_classes ) , dtype = np . float32 ) meta_data_blob = np . zeros ( ( num_images , 1 , 1 , 48 ) , dtype = np . float32 ) if cfg . TRAIN . VERTEX_REG : vertex_target_blob = np . zeros ( ( num_images , height , width , 2 * num_classes ) , dtype = np . float32 ) vertex_weight_blob = np . zeros ( ( num_images , height , width , 2 * num_classes ) , dtype = np . float32 ) vertex_image_blob = np . zeros ( ( num_images , height , width , 3 ) , dtype = np . float32 ) else : vertex_target_blob = [ ] vertex_weight_blob = [ ] vertex_image_blob = [ ] for i in xrange ( num_images ) : depth_blob [ i , : , : , 0 ] = processed_depth [ i ] label_blob [ i , : , : , : ] = processed_label [ i ] meta_data_blob [ i , 0 , 0 , : ] = processed_meta_data [ i ] if cfg . TRAIN . VERTEX_REG : vertex_target_blob [ i , : , : , : ] = processed_vertex_targets [ i ] vertex_weight_blob [ i , : , : , : ] = processed_vertex_weights [ i ] vertex_image_blob [ i , : , : , : ] = processed_vertex_images [ i ] return depth_blob , label_blob , meta_data_blob , vertex_target_blob , vertex_weight_blob , vertex_image_blob