vector_to_poseVectorToPoseVectorToPosevector_to_poseT_vector_to_pose
Short description
vector_to_poseVectorToPoseVectorToPosevector_to_poseT_vector_to_pose โ Compute an absolute pose out of point correspondences between
world and image coordinates.
Signature
vector_to_pose( number WorldX, number WorldY, number WorldZ, number ImageRow, number ImageColumn, campar CameraParam, string Method, string QualityType, out pose Pose, out number Quality )void VectorToPose( const HTuple& WorldX, const HTuple& WorldY, const HTuple& WorldZ, const HTuple& ImageRow, const HTuple& ImageColumn, const HTuple& CameraParam, const HTuple& Method, const HTuple& QualityType, HTuple* Pose, HTuple* Quality )static void HOperatorSet.VectorToPose( HTuple worldX, HTuple worldY, HTuple worldZ, HTuple imageRow, HTuple imageColumn, HTuple cameraParam, HTuple method, HTuple qualityType, out HTuple pose, out HTuple quality )def vector_to_pose( world_x: Sequence[Union[float, int]], world_y: Sequence[Union[float, int]], world_z: Sequence[Union[float, int]], image_row: Sequence[Union[float, int]], image_column: Sequence[Union[float, int]], camera_param: Sequence[Union[float, int, str]], method: str, quality_type: MaybeSequence[str] ) -> Tuple[Sequence[Union[float, int]], Sequence[Union[float, int]]]
def vector_to_pose_s( world_x: Sequence[Union[float, int]], world_y: Sequence[Union[float, int]], world_z: Sequence[Union[float, int]], image_row: Sequence[Union[float, int]], image_column: Sequence[Union[float, int]], camera_param: Sequence[Union[float, int, str]], method: str, quality_type: MaybeSequence[str] ) -> Tuple[Sequence[Union[float, int]], Union[float, int]]Herror T_vector_to_pose( const Htuple WorldX, const Htuple WorldY, const Htuple WorldZ, const Htuple ImageRow, const Htuple ImageColumn, const Htuple CameraParam, const Htuple Method, const Htuple QualityType, Htuple* Pose, Htuple* Quality )
static HPose HImage::VectorToPose( const HTuple& WorldX, const HTuple& WorldY, const HTuple& WorldZ, const HTuple& ImageRow, const HTuple& ImageColumn, const HCamPar& CameraParam, const HString& Method, const HTuple& QualityType, HTuple* Quality )
static HPose HImage::VectorToPose( const HTuple& WorldX, const HTuple& WorldY, const HTuple& WorldZ, const HTuple& ImageRow, const HTuple& ImageColumn, const HCamPar& CameraParam, const HString& Method, const HString& QualityType, double* Quality )
static HPose HImage::VectorToPose( const HTuple& WorldX, const HTuple& WorldY, const HTuple& WorldZ, const HTuple& ImageRow, const HTuple& ImageColumn, const HCamPar& CameraParam, const char* Method, const char* QualityType, double* Quality )
static HPose HImage::VectorToPose( const HTuple& WorldX, const HTuple& WorldY, const HTuple& WorldZ, const HTuple& ImageRow, const HTuple& ImageColumn, const HCamPar& CameraParam, const wchar_t* Method, const wchar_t* QualityType, double* Quality ) (Windows only)
HPose HCamPar::VectorToPose( const HTuple& WorldX, const HTuple& WorldY, const HTuple& WorldZ, const HTuple& ImageRow, const HTuple& ImageColumn, const HString& Method, const HTuple& QualityType, HTuple* Quality ) const
HPose HCamPar::VectorToPose( const HTuple& WorldX, const HTuple& WorldY, const HTuple& WorldZ, const HTuple& ImageRow, const HTuple& ImageColumn, const HString& Method, const HString& QualityType, double* Quality ) const
HPose HCamPar::VectorToPose( const HTuple& WorldX, const HTuple& WorldY, const HTuple& WorldZ, const HTuple& ImageRow, const HTuple& ImageColumn, const char* Method, const char* QualityType, double* Quality ) const
HPose HCamPar::VectorToPose( const HTuple& WorldX, const HTuple& WorldY, const HTuple& WorldZ, const HTuple& ImageRow, const HTuple& ImageColumn, const wchar_t* Method, const wchar_t* QualityType, double* Quality ) const (Windows only)
HTuple HPose::VectorToPose( const HTuple& WorldX, const HTuple& WorldY, const HTuple& WorldZ, const HTuple& ImageRow, const HTuple& ImageColumn, const HCamPar& CameraParam, const HString& Method, const HTuple& QualityType )
double HPose::VectorToPose( const HTuple& WorldX, const HTuple& WorldY, const HTuple& WorldZ, const HTuple& ImageRow, const HTuple& ImageColumn, const HCamPar& CameraParam, const HString& Method, const HString& QualityType )
double HPose::VectorToPose( const HTuple& WorldX, const HTuple& WorldY, const HTuple& WorldZ, const HTuple& ImageRow, const HTuple& ImageColumn, const HCamPar& CameraParam, const char* Method, const char* QualityType )
double HPose::VectorToPose( const HTuple& WorldX, const HTuple& WorldY, const HTuple& WorldZ, const HTuple& ImageRow, const HTuple& ImageColumn, const HCamPar& CameraParam, const wchar_t* Method, const wchar_t* QualityType ) (Windows only)
static HPose HImage.VectorToPose( HTuple worldX, HTuple worldY, HTuple worldZ, HTuple imageRow, HTuple imageColumn, HCamPar cameraParam, string method, HTuple qualityType, out HTuple quality )
static HPose HImage.VectorToPose( HTuple worldX, HTuple worldY, HTuple worldZ, HTuple imageRow, HTuple imageColumn, HCamPar cameraParam, string method, string qualityType, out double quality )
HPose HCamPar.VectorToPose( HTuple worldX, HTuple worldY, HTuple worldZ, HTuple imageRow, HTuple imageColumn, string method, HTuple qualityType, out HTuple quality )
HPose HCamPar.VectorToPose( HTuple worldX, HTuple worldY, HTuple worldZ, HTuple imageRow, HTuple imageColumn, string method, string qualityType, out double quality )
HTuple HPose.VectorToPose( HTuple worldX, HTuple worldY, HTuple worldZ, HTuple imageRow, HTuple imageColumn, HCamPar cameraParam, string method, HTuple qualityType )
double HPose.VectorToPose( HTuple worldX, HTuple worldY, HTuple worldZ, HTuple imageRow, HTuple imageColumn, HCamPar cameraParam, string method, string qualityType )
Description
The operator vector_to_poseVectorToPose computes a pose out of at least
three or four (depending on Methodmethodmethod) point correspondences
of 3D world coordinates (WorldXworldXworld_x, WorldYworldYworld_y,
WorldZworldZworld_z), given in meters, and 2D image coordinates
(ImageRowimageRowimage_row, ImageColumnimageColumnimage_column), given in pixels, as well as
the internal camera parameters (CameraParamcameraParamcamera_param).
Thereby the pose (the external camera parameters) is in the form
\(\mvPoseVar{{ccs}}{wcs}\), where
ccs denotes the camera coordinate system and
wcs the world coordinate system
(see Transformations / Poses
and โSolution Guide III-C - 3D Visionโ).
Parameter Method
By setting the parameter Methodmethodmethod, it is possible to choose
what kind of algorithm is used for the pose computation.
Methods supported for perspective area scan cameras:
Methodmethodmethod |
When to use |
Minimum number of point correspondences |
| 'analytic'"analytic" [1] |
Default method for general cases |
4 |
| 'iterative'"iterative" [2] |
If only three or four point correspondences are used or if the world points are close to being planar |
3 |
| 'planar_analytic'"planar_analytic" [4] |
If the world points lie in a horizontal plane (\(\textrm{WorldZ} = 0\)) |
4 |
The numbers in square brackets in the table above refer to the publications
the implementations of the corresponding methods are based on.
Methods supported for telecentric area or line scan cameras:
Methodmethodmethod |
When to use |
Minimum number of point correspondences |
| 'telecentric'"telecentric" [3] |
Default method for general cases |
4 |
| 'telecentric_robust'"telecentric_robust" [3] |
For very ill-posed point configurations where Qualityqualityquality has an unlikely large value |
4 |
| 'telecentric_planar'"telecentric_planar" [3] |
If the world points lie in a horizontal plane (\(\textrm{WorldZ} = 0\)) |
3 |
| 'telecentric_planar_robust'"telecentric_planar_robust" [3] |
For very ill-posed point configurations where the world points lie in a horizontal plane (\(\textrm{WorldZ} = 0\)) and Qualityqualityquality has an unlikely large value |
3 |
The numbers in square brackets in the table above refer to the publications
the implementations of the corresponding methods are based on.
Methods supported for perspective line scan cameras:
Methodmethodmethod |
When to use |
Minimum number of point correspondences |
| 'line_scan'"line_scan" |
Default method for general cases |
3 |
Parameters CameraParam and Quality
All methods need the inner camera parameters obtained from
camera_calibrationCameraCalibration to solve the pose estimation problem.
They must be passed in CameraParamcameraParamcamera_param.
The user can specify in QualityTypequalityTypequality_type one or more quality
measures of the pose to be evaluated. The resulting quality
evaluations are returned concatenated in Qualityqualityquality.
Currently, only 'error'"error" is supported. It corresponds to
the root-mean-square error in pixels of the projected 3D world
coordinates.
If a method for planar world points is chosen, all world points are
assumed to lie in the plane \(\textrm{WorldZ} = 0\). Therefore, the z-component of the world coordinates can be
left empty (WorldZworldZworld_z = [][]) since only 2D
correspondences are used in this case.
For telecentric cameras, the translation in z obviously
cannot be determined. It is set to 00 in Poseposepose.
For planar world points and telecentric cameras, there are always
two possible equivalent poses. This ambiguity can only be resolved
by some additional knowledge. vector_to_poseVectorToPose returns an
arbitrary solution of the two possible solutions in this case. The
other solution can be calculated easily by replacing the values of
\(\alpha\) and \(\beta\) in Poseposepose by
\(360-\alpha\) and \(360-\beta\).
For perspective line scan cameras, the call to
vector_to_poseVectorToPose corresponds to the following operator
sequence:
| ย |
get_line_of_sight(ImageRow, ImageColumn, CameraParam, PX, PY, PZ, QX, QY, QZ)GetLineOfSight(ImageRow, ImageColumn, CameraParam, PX, PY, PZ, QX, QY, QZ)GetLineOfSight(ImageRow, ImageColumn, CameraParam, PX, PY, PZ, QX, QY, QZ)get_line_of_sight(ImageRow, ImageColumn, CameraParam, PX, PY, PZ, QX, QY, QZ)get_line_of_sight(ImageRow, ImageColumn, CameraParam, PX, PY, PZ, QX, QY, QZ) |
points_to_pluecker_line(PX, PY, PZ, QX, QY, QZ, LX, LY, LZ, MX, MY, MZ)PointsToPlueckerLine(PX, PY, PZ, QX, QY, QZ, LX, LY, LZ, MX, MY, MZ)PointsToPlueckerLine(PX, PY, PZ, QX, QY, QZ, LX, LY, LZ, MX, MY, MZ)points_to_pluecker_line(PX, PY, PZ, QX, QY, QZ, LX, LY, LZ, MX, MY, MZ)points_to_pluecker_line(PX, PY, PZ, QX, QY, QZ, LX, LY, LZ, MX, MY, MZ) |
point_pluecker_line_to_hom_mat3d('rigid', WorldX, WorldY, WorldZ, LX, LY, LZ, MX, MY, MZ, HomMat3D)PointPlueckerLineToHomMat3d("rigid", WorldX, WorldY, WorldZ, LX, LY, LZ, MX, MY, MZ, HomMat3D)PointPlueckerLineToHomMat3d("rigid", WorldX, WorldY, WorldZ, LX, LY, LZ, MX, MY, MZ, HomMat3D)point_pluecker_line_to_hom_mat3d("rigid", WorldX, WorldY, WorldZ, LX, LY, LZ, MX, MY, MZ, HomMat3D)point_pluecker_line_to_hom_mat3d("rigid", WorldX, WorldY, WorldZ, LX, LY, LZ, MX, MY, MZ, HomMat3D) |
hom_mat3d_to_pose(HomMat3D, Pose)HomMat3dToPose(HomMat3D, Pose)HomMat3dToPose(HomMat3D, Pose)hom_mat3d_to_pose(HomMat3D, Pose)hom_mat3d_to_pose(HomMat3D, Pose) |
In contrast to the methods for other camera types, an error in 3D
space is minimized in this case (see
point_pluecker_line_to_hom_mat3dPointPlueckerLineToHomMat3d). However, like for all
other methods, the quality evaluation is performed in pixels. If it
is essential that a pixel error is optimized, this can be done as
shown in the example below.
Attention
The method 'analytic'"analytic" only allows a maximum number of 32767
point correspondences.
Execution information
-
Multithreading type: reentrant (runs in parallel with non-exclusive operators).
-
Multithreading scope: global (may be called from any thread).
-
Processed without parallelization.
Parameters
WorldXworldXworld_x (input_control) number-array โ (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Sequence[Union[float, int]]Htuple (double / Hlong)
X-Component of world coordinates.
Number of elements: WorldX >= 4
WorldYworldYworld_y (input_control) number-array โ (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Sequence[Union[float, int]]Htuple (double / Hlong)
Y-Component of world coordinates.
Number of elements: WorldY == WorldX
WorldZworldZworld_z (input_control) number-array โ (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Sequence[Union[float, int]]Htuple (double / Hlong)
Z-Component of world coordinates.
Number of elements: WorldZ == WorldX || WorldZ == 0
ImageRowimageRowimage_row (input_control) number-array โ (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Sequence[Union[float, int]]Htuple (double / Hlong)
Row-Component of image coordinates.
Number of elements: ImageRow == WorldX
ImageColumnimageColumnimage_column (input_control) number-array โ (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Sequence[Union[float, int]]Htuple (double / Hlong)
Column-Component of image coordinates.
Number of elements: ImageColumn == WorldX
CameraParamcameraParamcamera_param (input_control) campar โ (real / integer / string)HTuple (double / Hlong / HString)HCamPar, HTuple (double / int / long / string)Sequence[Union[float, int, str]]Htuple (double / Hlong / char*)
The inner camera parameters from camera calibration.
Methodmethodmethod (input_control) string โ (string)HTuple (HString)HTuple (string)strHtuple (char*)
Kind of algorithm
Default: 'iterative'"iterative"
List of values: 'analytic', 'iterative', 'line_scan', 'planar_analytic', 'telecentric', 'telecentric_planar', 'telecentric_planar_robust', 'telecentric_robust'"analytic", "iterative", "line_scan", "planar_analytic", "telecentric", "telecentric_planar", "telecentric_planar_robust", "telecentric_robust"
QualityTypequalityTypequality_type (input_control) string(-array) โ (string)HTuple (HString)HTuple (string)MaybeSequence[str]Htuple (char*)
Type of pose quality to be returned in Quality.
Default: 'error'"error"
List of values: 'error'"error"
Poseposepose (output_control) pose โ (real / integer)HTuple (double / Hlong)HPose, HTuple (double / int / long)Sequence[Union[float, int]]Htuple (double / Hlong)
Pose.
Qualityqualityquality (output_control) number(-array) โ (real / integer)HTuple (double / Hlong)HTuple (double / int / long)Sequence[Union[float, int]]Htuple (double / Hlong)
Pose quality.
Example
(HDevelop)
* Optimize the pixel error line scan cameras. We assume that the
* point correspondences (Row, Col) - (PX, PY, PZ) have already been
* computed and the internal camera parameters CamParam have already
* been calibrated.
vector_to_pose (PX, PY, PZ, Row, Col, CamParam, 'line_scan', \
'error', PoseObjectSpace, RMS)
* Use PoseObjectSpace as the starting value for a camera calibration
* that only optimizes the pose.
create_calib_data ('calibration_object', 1, 1, CalibDataID)
set_calib_data_cam_param (CalibDataID, 0, [], CamParam)
set_calib_data_calib_object (CalibDataID, 0, [PX, PY, PZ])
set_calib_data (CalibDataID, 'camera', 0, \
'excluded_settings', 'params')
set_calib_data_observ_points (CalibDataID, 0, 0, 0, Row, Col, \
'all', PoseObjectSpace)
calibrate_cameras (CalibDataID, Error)
get_calib_data (CalibDataID, 'calib_obj_pose', [0, 0], 'pose', Pose)
clear_calib_data (CalibDataID)
* As an alternative, the following one-line code can be used.
camera_calibration (PX, PY, PZ, Row, Col, CamParam, PoseObjectSpace, \
'pose', _, Pose, Error)
Result
vector_to_poseVectorToPose returns 2 (H_MSG_TRUE) if all parameter values are
correct.
Combinations with other operators
Combinations
See also
proj_hom_mat2d_to_poseProjHomMat2dToPose, vector_to_rel_poseVectorToRelPose, camera_calibrationCameraCalibration
References
[1] Francesc Moreno-Noguer, Vincent Lepetit, and Pascal Fua:
โAccurate Non-Iterative O(n) Solution to the PnP Problemโ;
Eleventh IEEE International Conference on Computer Vision, 2007.
[2] Gerald Schweighofer, and Axel Pinz: ``Robust Pose Estimation from a Planar
Targetโโ; Transactions on Pattern Analysis and Machine Intelligence (PAMI),
28(12):2024-2030, 2006.
[3] Carsten Steger: โAlgorithms for the Orthographic-n-Point
Problemโ; Journal of Mathematical Imaging and Vision, vol. 60,
no. 2, pp. 246-266, 2018.
[4] Zhengyou Zhang: โA flexible new technique for camera calibration.โ;
Transactions on Pattern Analysis and Machine Intelligence (PAMI),
22(11):1330-1334, 2000.
Module
Calibration