parameters: (H: np.ndarray)
return_statement: return focal
docstring: Solve for w = H w H^t, with w = diag(a, a, b)
  
      >>> K = np.diag([0.8, 0.8, 1])
      >>> R = cv2.Rodrigues(np.array([0.3, 0, 0]))[0]
      >>> H = K.dot(R).dot(np.linalg.inv(K))
      >>> f = focal_from_homography(3 * H)
      >>> np.allclose(f, 0.8)
      True
docstring_summary: Solve for w = H w H^t, with w = diag(a, a, b)
docstring_tokens: Solve for w = H w H^t with w = diag ( a a b )
function: def focal_from_homography(H: np.ndarray) -> np.ndarray:
      """Solve for w = H w H^t, with w = diag(a, a, b)
  
      >>> K = np.diag([0.8, 0.8, 1])
      >>> R = cv2.Rodrigues(np.array([0.3, 0, 0]))[0]
      >>> H = K.dot(R).dot(np.linalg.inv(K))
      >>> f = focal_from_homography(3 * H)
      >>> np.allclose(f, 0.8)
      True
      """
      H = H / np.linalg.det(H) ** (1.0 / 3.0)
      A = np.array(
          [
              [H[0, 0] * H[0, 0] + H[0, 1] * H[0, 1] - 1, H[0, 2] * H[0, 2]],
              [H[0, 0] * H[1, 0] + H[0, 1] * H[1, 1], H[0, 2] * H[1, 2]],
              [H[0, 0] * H[2, 0] + H[0, 1] * H[2, 1], H[0, 2] * H[2, 2]],
              [H[1, 0] * H[1, 0] + H[1, 1] * H[1, 1] - 1, H[1, 2] * H[1, 2]],
              [H[1, 0] * H[2, 0] + H[1, 1] * H[2, 1], H[1, 2] * H[2, 2]],
              [H[2, 0] * H[2, 0] + H[2, 1] * H[2, 1], H[2, 2] * H[2, 2] - 1],
          ]
      )
      _, (a, b) = nullspace(A)
      focal = np.sqrt(a / b)
      return focal
function_tokens: def focal_from_homography ( H : np . ndarray ) -> np . ndarray : H = H / np . linalg . det ( H ) ** ( 1.0 / 3.0 ) A = np . array ( [ [ H [ 0 , 0 ] * H [ 0 , 0 ] + H [ 0 , 1 ] * H [ 0 , 1 ] - 1 , H [ 0 , 2 ] * H [ 0 , 2 ] ] , [ H [ 0 , 0 ] * H [ 1 , 0 ] + H [ 0 , 1 ] * H [ 1 , 1 ] , H [ 0 , 2 ] * H [ 1 , 2 ] ] , [ H [ 0 , 0 ] * H [ 2 , 0 ] + H [ 0 , 1 ] * H [ 2 , 1 ] , H [ 0 , 2 ] * H [ 2 , 2 ] ] , [ H [ 1 , 0 ] * H [ 1 , 0 ] + H [ 1 , 1 ] * H [ 1 , 1 ] - 1 , H [ 1 , 2 ] * H [ 1 , 2 ] ] , [ H [ 1 , 0 ] * H [ 2 , 0 ] + H [ 1 , 1 ] * H [ 2 , 1 ] , H [ 1 , 2 ] * H [ 2 , 2 ] ] , [ H [ 2 , 0 ] * H [ 2 , 0 ] + H [ 2 , 1 ] * H [ 2 , 1 ] , H [ 2 , 2 ] * H [ 2 , 2 ] - 1 ] , ] ) _ , ( a , b ) = nullspace ( A ) focal = np . sqrt ( a / b ) return focal