parameters: (shot, depth, image)
return_statement: return io.points_to_ply_string(vertices)
docstring: Export depthmap points as a PLY string
docstring_summary: Export depthmap points as a PLY string
docstring_tokens: Export depthmap points as a PLY string
function: def depthmap_to_ply(shot, depth, image):
      """Export depthmap points as a PLY string"""
      height, width = depth.shape
      K = shot.camera.get_K_in_pixel_coordinates(width, height)
      R = shot.pose.get_rotation_matrix()
      t = shot.pose.translation
      y, x = np.mgrid[:height, :width]
      v = np.vstack((x.ravel(), y.ravel(), np.ones(width * height)))
      camera_coords = depth.reshape((1, -1)) * np.linalg.inv(K).dot(v)
      points = R.T.dot(camera_coords - t.reshape(3, 1))
  
      vertices = []
      for p, c, d in zip(points.T, image.reshape(-1, 3), depth.reshape(-1, 1)):
          if d != 0:  # ignore points with zero depth
              s = "{} {} {} {} {} {}".format(p[0], p[1], p[2], c[0], c[1], c[2])
              vertices.append(s)
  
      return io.points_to_ply_string(vertices)
function_tokens: def depthmap_to_ply ( shot , depth , image ) : height , width = depth . shape K = shot . camera . get_K_in_pixel_coordinates ( width , height ) R = shot . pose . get_rotation_matrix ( ) t = shot . pose . translation y , x = np . mgrid [ : height , : width ] v = np . vstack ( ( x . ravel ( ) , y . ravel ( ) , np . ones ( width * height ) ) ) camera_coords = depth . reshape ( ( 1 , - 1 ) ) * np . linalg . inv ( K ) . dot ( v ) points = R . T . dot ( camera_coords - t . reshape ( 3 , 1 ) ) vertices = [ ] for p , c , d in zip ( points . T , image . reshape ( - 1 , 3 ) , depth . reshape ( - 1 , 1 ) ) : if d != 0 : # ignore points with zero depth s = "{} {} {} {} {} {}" . format ( p [ 0 ] , p [ 1 ] , p [ 2 ] , c [ 0 ] , c [ 1 ] , c [ 2 ] ) vertices . append ( s ) return io . points_to_ply_string ( vertices )