parameters: (roidb, voxelizer)
return_statement: return depth_blob, label_blob, meta_data_blob, state_blob, weights_blob, points_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)
      processed_depth = []
      processed_label = []
      processed_meta_data = []
  
      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)
          # 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']:
              im = im[:, ::-1, :]
          im_cls = _process_label_image(im, roidb[i]['class_colors'], roidb[i]['class_weights'])
          processed_label.append(im_cls)
  
          # 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
          if i % cfg.TRAIN.NUM_STEPS == 0:
              points = voxelizer.backproject_camera(im_depth, meta_data)
              voxelizer.voxelized = False
              voxelizer.voxelize(points)
              # store the RT for the first frame
              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)
  
          # compute the delta transformation between frames
          RT_world = RT_live
  
      # construct the blobs
      height = processed_depth[0].shape[0]
      width = processed_depth[0].shape[1]
      num_classes = voxelizer.num_classes
      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)
      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]
  
      state_blob = np.zeros((cfg.TRAIN.IMS_PER_BATCH, height, width, cfg.TRAIN.NUM_UNITS), dtype=np.float32)
      weights_blob = np.ones((cfg.TRAIN.IMS_PER_BATCH, height, width, cfg.TRAIN.NUM_UNITS), dtype=np.float32)
      points_blob = np.zeros((cfg.TRAIN.IMS_PER_BATCH, height, width, 3), dtype=np.float32)
  
      return depth_blob, label_blob, meta_data_blob, state_blob, weights_blob, points_blob
function_tokens: def _get_label_blob ( roidb , voxelizer ) : num_images = len ( roidb ) processed_depth = [ ] processed_label = [ ] processed_meta_data = [ ] 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 ) # 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' ] : im = im [ : , : : - 1 , : ] im_cls = _process_label_image ( im , roidb [ i ] [ 'class_colors' ] , roidb [ i ] [ 'class_weights' ] ) processed_label . append ( im_cls ) # 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 if i % cfg . TRAIN . NUM_STEPS == 0 : points = voxelizer . backproject_camera ( im_depth , meta_data ) voxelizer . voxelized = False voxelizer . voxelize ( points ) # store the RT for the first frame 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 ) # compute the delta transformation between frames RT_world = RT_live # construct the blobs height = processed_depth [ 0 ] . shape [ 0 ] width = processed_depth [ 0 ] . shape [ 1 ] num_classes = voxelizer . num_classes 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 ) 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 ] state_blob = np . zeros ( ( cfg . TRAIN . IMS_PER_BATCH , height , width , cfg . TRAIN . NUM_UNITS ) , dtype = np . float32 ) weights_blob = np . ones ( ( cfg . TRAIN . IMS_PER_BATCH , height , width , cfg . TRAIN . NUM_UNITS ) , dtype = np . float32 ) points_blob = np . zeros ( ( cfg . TRAIN . IMS_PER_BATCH , height , width , 3 ) , dtype = np . float32 ) return depth_blob , label_blob , meta_data_blob , state_blob , weights_blob , points_blob