1
// Copyright (c) 2010 libmv authors.
3
// Permission is hereby granted, free of charge, to any person obtaining a copy
4
// of this software and associated documentation files (the "Software"), to
5
// deal in the Software without restriction, including without limitation the
6
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7
// sell copies of the Software, and to permit persons to whom the Software is
8
// furnished to do so, subject to the following conditions:
10
// The above copyright notice and this permission notice shall be included in
11
// all copies or substantial portions of the Software.
13
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21
#ifndef LIBMV_MULTIVIEW_EUCLIDEAN_RESECTION_H_
22
#define LIBMV_MULTIVIEW_EUCLIDEAN_RESECTION_H_
24
#include "libmv/numeric/numeric.h"
25
#include "libmv/multiview/projection.h"
28
namespace euclidean_resection {
30
enum ResectionMethod {
31
RESECTION_ANSAR_DANIILIDIS,
36
* Computes the extrinsic parameters, R and t for a calibrated camera
37
* from 4 or more 3D points and their normalized images.
39
* \param x_camera Image points in normalized camera coordinates e.g. x_camera
41
* \param X_world 3D points in the world coordinate system
42
* \param R Solution for the camera rotation matrix
43
* \param t Solution for the camera translation vector
44
* \param method The resection method to use.
46
bool EuclideanResection(const Mat2X &x_camera,
49
ResectionMethod method = RESECTION_EPNP);
52
* Computes the extrinsic parameters, R and t for a calibrated camera
53
* from 4 or more 3D points and their images.
55
* \param x_image Image points in non-normalized image coordinates. The
56
* coordates are laid out one per row. The matrix can be Nx2
57
* or Nx3 for euclidean or homogenous 2D coordinates.
58
* \param X_world 3D points in the world coordinate system
59
* \param K Intrinsic parameters camera matrix
60
* \param R Solution for the camera rotation matrix
61
* \param t Solution for the camera translation vector
62
* \param method Resection method
64
bool EuclideanResection(const Mat &x_image,
68
ResectionMethod method = RESECTION_EPNP);
71
* The absolute orientation algorithm recovers the transformation between a set
72
* of 3D points, X and Xp such that:
76
* The recovery of the absolute orientation is implemented after this article:
77
* Horn, Hilden, "Closed-form solution of absolute orientation using
78
* orthonormal matrices"
80
void AbsoluteOrientation(const Mat3X &X,
86
* Computes the extrinsic parameters, R and t for a calibrated camera from 4 or
87
* more 3D points and their images.
89
* \param x_camera Image points in normalized camera coordinates, e.g.
90
* x_camera=inv(K)*x_image
91
* \param X_world 3D points in the world coordinate system
92
* \param R Solution for the camera rotation matrix
93
* \param t Solution for the camera translation vector
95
* This is the algorithm described in: "Linear Pose Estimation from Points or
96
* Lines", by Ansar, A. and Daniilidis, PAMI 2003. vol. 25, no. 5.
98
void EuclideanResectionAnsarDaniilidis(const Mat2X &x_camera,
102
* Computes the extrinsic parameters, R and t for a calibrated camera from 4 or
103
* more 3D points and their images.
105
* \param x_camera Image points in normalized camera coordinates,
106
* e.g. x_camera = inv(K) * x_image
107
* \param X_world 3D points in the world coordinate system
108
* \param R Solution for the camera rotation matrix
109
* \param t Solution for the camera translation vector
111
* This is the algorithm described in:
112
* "{EP$n$P: An Accurate $O(n)$ Solution to the P$n$P Problem", by V. Lepetit
113
* and F. Moreno-Noguer and P. Fua, IJCV 2009. vol. 81, no. 2
114
* \note: the non-linear optimization is not implemented here.
116
bool EuclideanResectionEPnP(const Mat2X &x_camera,
117
const Mat3X &X_world,
120
} // namespace euclidean_resection
124
#endif /* LIBMV_MULTIVIEW_EUCLIDEAN_RESECTION_H_ */