parameters: (
      image: np.ndarray,
      rotation: np.ndarray,
      translation: np.ndarray,
      focal_length: Tuple[float, float] = (1.0, 1.0),
      principal_point: Tuple[float, float] = (0.0, 0.0),
      axis_length: float = 0.1,
      axis_drawing_spec: DrawingSpec = DrawingSpec())
docstring: Draws the 3D axis on the image.
  
    Args:
      image: A three channel RGB image represented as numpy ndarray.
      rotation: Rotation matrix from object to camera coordinate frame.
      translation: Translation vector from object to camera coordinate frame.
      focal_length: camera focal length along x and y directions.
      principal_point: camera principal point in x and y.
      axis_length: length of the axis in the drawing.
      axis_drawing_spec: A DrawingSpec object that specifies the xyz axis
        drawing settings such as line thickness.
  
    Raises:
      ValueError: If one of the followings:
        a) If the input image is not three channel RGB.
docstring_summary: Draws the 3D axis on the image.
docstring_tokens: Draws the 3D axis on the image .
function: def draw_axis(
      image: np.ndarray,
      rotation: np.ndarray,
      translation: np.ndarray,
      focal_length: Tuple[float, float] = (1.0, 1.0),
      principal_point: Tuple[float, float] = (0.0, 0.0),
      axis_length: float = 0.1,
      axis_drawing_spec: DrawingSpec = DrawingSpec()):
    """Draws the 3D axis on the image.
  
    Args:
      image: A three channel RGB image represented as numpy ndarray.
      rotation: Rotation matrix from object to camera coordinate frame.
      translation: Translation vector from object to camera coordinate frame.
      focal_length: camera focal length along x and y directions.
      principal_point: camera principal point in x and y.
      axis_length: length of the axis in the drawing.
      axis_drawing_spec: A DrawingSpec object that specifies the xyz axis
        drawing settings such as line thickness.
  
    Raises:
      ValueError: If one of the followings:
        a) If the input image is not three channel RGB.
    """
    if image.shape[2] != _RGB_CHANNELS:
      raise ValueError('Input image must contain three channel rgb data.')
    image_rows, image_cols, _ = image.shape
    # Create axis points in camera coordinate frame.
    axis_world = np.float32([[0, 0, 0], [1, 0, 0], [0, 1, 0], [0, 0, 1]])
    axis_cam = np.matmul(rotation, axis_length*axis_world.T).T + translation
    x = axis_cam[..., 0]
    y = axis_cam[..., 1]
    z = axis_cam[..., 2]
    # Project 3D points to NDC space.
    fx, fy = focal_length
    px, py = principal_point
    x_ndc = np.clip(-fx * x / (z + 1e-5) + px, -1., 1.)
    y_ndc = np.clip(-fy * y / (z + 1e-5) + py, -1., 1.)
    # Convert from NDC space to image space.
    x_im = np.int32((1 + x_ndc) * 0.5 * image_cols)
    y_im = np.int32((1 - y_ndc) * 0.5 * image_rows)
    # Draw xyz axis on the image.
    origin = (x_im[0], y_im[0])
    x_axis = (x_im[1], y_im[1])
    y_axis = (x_im[2], y_im[2])
    z_axis = (x_im[3], y_im[3])
    cv2.arrowedLine(image, origin, x_axis, RED_COLOR, axis_drawing_spec.thickness)
    cv2.arrowedLine(image, origin, y_axis, GREEN_COLOR,
                    axis_drawing_spec.thickness)
    cv2.arrowedLine(image, origin, z_axis, BLUE_COLOR,
                    axis_drawing_spec.thickness)
function_tokens: def draw_axis ( image : np . ndarray , rotation : np . ndarray , translation : np . ndarray , focal_length : Tuple [ float , float ] = ( 1.0 , 1.0 ) , principal_point : Tuple [ float , float ] = ( 0.0 , 0.0 ) , axis_length : float = 0.1 , axis_drawing_spec : DrawingSpec = DrawingSpec ( ) ) : if image . shape [ 2 ] != _RGB_CHANNELS : raise ValueError ( 'Input image must contain three channel rgb data.' ) image_rows , image_cols , _ = image . shape # Create axis points in camera coordinate frame. axis_world = np . float32 ( [ [ 0 , 0 , 0 ] , [ 1 , 0 , 0 ] , [ 0 , 1 , 0 ] , [ 0 , 0 , 1 ] ] ) axis_cam = np . matmul ( rotation , axis_length * axis_world . T ) . T + translation x = axis_cam [ ... , 0 ] y = axis_cam [ ... , 1 ] z = axis_cam [ ... , 2 ] # Project 3D points to NDC space. fx , fy = focal_length px , py = principal_point x_ndc = np . clip ( - fx * x / ( z + 1e-5 ) + px , - 1. , 1. ) y_ndc = np . clip ( - fy * y / ( z + 1e-5 ) + py , - 1. , 1. ) # Convert from NDC space to image space. x_im = np . int32 ( ( 1 + x_ndc ) * 0.5 * image_cols ) y_im = np . int32 ( ( 1 - y_ndc ) * 0.5 * image_rows ) # Draw xyz axis on the image. origin = ( x_im [ 0 ] , y_im [ 0 ] ) x_axis = ( x_im [ 1 ] , y_im [ 1 ] ) y_axis = ( x_im [ 2 ] , y_im [ 2 ] ) z_axis = ( x_im [ 3 ] , y_im [ 3 ] ) cv2 . arrowedLine ( image , origin , x_axis , RED_COLOR , axis_drawing_spec . thickness ) cv2 . arrowedLine ( image , origin , y_axis , GREEN_COLOR , axis_drawing_spec . thickness ) cv2 . arrowedLine ( image , origin , z_axis , BLUE_COLOR , axis_drawing_spec . thickness )