solvePnP

fun solvePnP(objPoints: Tensor, imgPoints: Tensor, camMatrix: Tensor, rotationVecResult: Tensor? = null, translationVecResult: Tensor? = null)

Run the OpenCV solve PnP algorithm. Solve PnP reverses the camera projection procedure: given the projected result (2D points) of the vertices of a mesh, and the original 3D coordinates of the mesh vertices corresponding to the mesh's local space, inferring the most likely pose of the mesh corresponding to the camera space.

Parameters

objPoints

a tensor holding the 3D coordinates of N mesh vertices, all corresponding to the mesh's local space. The tensor must be an array of point3 ( Tensor.Point3ArrayInitInfo) of size N, or a multi-dimensional tensor with 3 channels and dimensions = 1xN or Nx1. Its data type must be 32-/64-bit float.

imgPoints

a tensor holding the projected 2D coordinates of N mesh vertices, all corresponding to the camera's projection plane. The tensor must be an array of point2 ( Tensor.Point2ArrayInitInfo) of size N, or a multi-dimensional tensor with 2 channels and dimensions = 1xN or Nx1. Its data type must be 32-/64-bit float.

camMatrix

a tensor holding the camera's intrinsic matrix. Hence, the tensor must be a multi-dimensional tensor of 1 channel, with dimension = 3x3. You can use the camera matrix output from the rectifiedVSTAccess directly. The data type must be 32-/64-bit float.

rotationVecResult

an optional result, storing the rotation part of the inferred pose from Solve PnP algorithm. The rotation is expressed as a rotation vector. Hence, it must be a multi-dimensional tensor of 1 channel, dimensions = 1x3 or 3x1. Due to the limitation of OpenCV compatibility, the tensor, if provided, must be of data type Tensor.DataType.FLOAT64.

translationVecResult

an optional result, storing the translation part of the inferred pose from Solve PnP algorithm. The rotation is expressed as a rotation vector. Hence, it must be a multi-dimensional tensor of 1 channel, dimensions = 1x3 or 3x1. Due to the limitation of OpenCV compatibility, the tensor, if provided, must be of data type Tensor.DataType.FLOAT64.

Throws

If the usage is not allowed by the SpatialML run-time Framework, or if the framework encounter internal error and cannot perform the requested behavior.