(cam_coords, proj)
return tf.transpose(pixel_coords, perm=[0, 2, 3, 1])
Transforms coordinates in a camera frame to the pixel frame.

    Args:
      cam_coords: [batch, 4, height, width]
      proj: [batch, 4, 4]
    Returns:
      Pixel coordinates projected from the camera frame [batch, height, width, 2]
Transforms coordinates in a camera frame to the pixel frame.
Transforms coordinates in a camera frame to the pixel frame .
def cam2pixel(cam_coords, proj):
    """Transforms coordinates in a camera frame to the pixel frame.

    Args:
      cam_coords: [batch, 4, height, width]
      proj: [batch, 4, 4]
    Returns:
      Pixel coordinates projected from the camera frame [batch, height, width, 2]
    """
    batch, _, height, width = cam_coords.get_shape().as_list()
    cam_coords = tf.reshape(cam_coords, [batch, 4, -1])
    unnormalized_pixel_coords = tf.matmul(proj, cam_coords)
    x_u = tf.slice(unnormalized_pixel_coords, [0, 0, 0], [-1, 1, -1])
    y_u = tf.slice(unnormalized_pixel_coords, [0, 1, 0], [-1, 1, -1])
    z_u = tf.slice(unnormalized_pixel_coords, [0, 2, 0], [-1, 1, -1])
    x_n = x_u / (z_u + 1e-10)
    y_n = y_u / (z_u + 1e-10)
    pixel_coords = tf.concat([x_n, y_n], axis=1)
    pixel_coords = tf.reshape(pixel_coords, [batch, 2, height, width])
    return tf.transpose(pixel_coords, perm=[0, 2, 3, 1])
def cam2pixel ( cam_coords , proj ) : batch , _ , height , width = cam_coords . get_shape ( ) . as_list ( ) cam_coords = tf . reshape ( cam_coords , [ batch , 4 , - 1 ] ) unnormalized_pixel_coords = tf . matmul ( proj , cam_coords ) x_u = tf . slice ( unnormalized_pixel_coords , [ 0 , 0 , 0 ] , [ - 1 , 1 , - 1 ] ) y_u = tf . slice ( unnormalized_pixel_coords , [ 0 , 1 , 0 ] , [ - 1 , 1 , - 1 ] ) z_u = tf . slice ( unnormalized_pixel_coords , [ 0 , 2 , 0 ] , [ - 1 , 1 , - 1 ] ) x_n = x_u / ( z_u + 1e-10 ) y_n = y_u / ( z_u + 1e-10 ) pixel_coords = tf . concat ( [ x_n , y_n ] , axis = 1 ) pixel_coords = tf . reshape ( pixel_coords , [ batch , 2 , height , width ] ) return tf . transpose ( pixel_coords , perm = [ 0 , 2 , 3 , 1 ] )