Class PoseSolver

Class Documentation

class PoseSolver

Public Functions

PoseSolver()

PoseSolver constructor.

~PoseSolver()

PoseSolver destructor.

void solveGeneric(cv::InputArray _objectPoints, cv::InputArray _imagePoints, cv::InputArray _cameraMatrix, cv::InputArray _distCoeffs, cv::OutputArray _rvec1, cv::OutputArray _tvec1, float &reprojErr1, cv::OutputArray _rvec2, cv::OutputArray _tvec2, float &reprojErr2)

Finds the two possible poses of a planar object given a set of correspondences and their respective reprojection errors. The poses are sorted with the first having the lowest reprojection error.

Parameters:
  • _objectPoints – Array of 4 or more coplanar object points defined in object coordinates. 1xN/Nx1 3-channel (float or double) where N is the number of points

  • _imagePoints – Array of corresponding image points, 1xN/Nx1 2-channel. This can either be in pixel coordinates or normalized pixel coordinates.

  • _cameraMatrix – Intrinsic camera matrix (same definition as OpenCV). If _imagePoints is in normalized pixel coordinates you must set _cameraMatrix = cv::noArray()

  • _distCoeffs – Intrinsic camera distortion vector (same definition as OpenCV). If _imagePoints is in normalized pixel coordinates you must set _cameraMatrix = cv::noArray()

  • _rvec1 – First rotation solution (3x1 rotation vector)

  • _tvec1 – First translation solution (3x1 vector)

  • reprojErr1 – Reprojection error of first solution

  • _rvec2 – Second rotation solution (3x1 rotation vector)

  • _tvec2 – Second translation solution (3x1 vector)

  • reprojErr2 – Reprojection error of second solution

void solveSquare(double squareLength, cv::InputArray _imagePoints, cv::InputArray _cameraMatrix, cv::InputArray _distCoeffs, cv::OutputArray _rvec1, cv::OutputArray _tvec1, float &reprojErr1, cv::OutputArray _rvec2, cv::OutputArray _tvec2, float &reprojErr2)

Finds the two possible poses of a square planar object and their respective reprojection errors using IPPE. These poses are sorted so that the first one is the one with the lowest reprojection error.

Parameters:
  • _squareLength – The square’s length (which is also it’s width) in object coordinate units (e.g. millimeters, meters, etc.)

  • _imagePoints – Array of corresponding image points, 1xN/Nx1 2-channel. This can either be in pixel coordinates or normalized pixel coordinates.

  • _cameraMatrix – Intrinsic camera matrix (same definition as OpenCV). If _imagePoints is in normalized pixel coordinates you must set _cameraMatrix = cv::noArray()

  • _distCoeffs – Intrinsic camera distortion vector (same definition as OpenCV). If _imagePoints is in normalized pixel coordinates you must set _cameraMatrix = cv::noArray()

  • _rvec1 – First rotation solution (3x1 rotation vector)

  • _tvec1 – First translation solution (3x1 vector)

  • reprojErr1 – Reprojection error of first solution

  • _rvec2 – Second rotation solution (3x1 rotation vector)

  • _tvec2 – Second translation solution (3x1 vector)

  • reprojErr2 – Reprojection error of second solution

void generateSquareObjectCorners3D(double squareLength, cv::OutputArray _objectPoints)

Generates the 4 object points of a square planar object.

Parameters:
  • squareLength – The square’s length (which is also it’s width) in object coordinate units (e.g. millimeters, meters, etc.)

  • _objectPoints – Set of 4 object points (1x4 3-channel double)

void generateSquareObjectCorners2D(double squareLength, cv::OutputArray _objectPoints)

Generates the 4 object points of a square planar object, without including the z-component (which is z=0 for all points).

Parameters:
  • squareLength – The square’s length (which is also it’s width) in object coordinate units (e.g. millimeters, meters, etc.)

  • _objectPoints – Set of 4 object points (1x4 2-channel double)

double meanSceneDepth(cv::InputArray objectPoints, cv::InputArray rvec, cv::InputArray tvec)

Computes the average depth of an object given its pose in camera coordinates.

Parameters:
  • objectPoints – Object points defined in 3D object space

  • rvec – Rotation component of pose

  • tvec – Translation component of pose

Returns:

: average depth of the object