Blender V4.3
panography_kernel.cc
Go to the documentation of this file.
1// Copyright (c) 2008, 2009 libmv authors.
2//
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:
9//
10// The above copyright notice and this permission notice shall be included in
11// all copies or substantial portions of the Software.
12//
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
19// IN THE SOFTWARE.
20
23
24namespace libmv {
25namespace panography {
26namespace kernel {
27
28void TwoPointSolver::Solve(const Mat& x1, const Mat& x2, vector<Mat3>* Hs) {
29 // Solve for the focal lengths.
32
33 // Then solve for the rotations and homographies.
34 Mat x1h, x2h;
35 EuclideanToHomogeneous(x1, &x1h);
36 EuclideanToHomogeneous(x2, &x2h);
37 for (int i = 0; i < fs.size(); ++i) {
38 Mat3 K1 = Mat3::Identity() * fs[i];
39 K1(2, 2) = 1.0;
40
41 Mat3 R;
42 GetR_FixedCameraCenter(x1h, x2h, fs[i], &R);
43 R /= R(2, 2);
44
45 (*Hs).push_back(K1 * R * K1.inverse());
46 }
47}
48
49} // namespace kernel
50} // namespace panography
51} // namespace libmv
#define R
void EuclideanToHomogeneous(const Mat &X, Mat *H)
Eigen::Matrix< double, 3, 3 > Mat3
Definition numeric.h:72
void F_FromCorrespondance_2points(const Mat &x1, const Mat &x2, vector< double > *fs)
Definition panography.cc:73
Eigen::MatrixXd Mat
Definition numeric.h:60
void GetR_FixedCameraCenter(const Mat &x1, const Mat &x2, const double focal, Mat3 *R)
Definition panography.cc:99
std::vector< ElementType, Eigen::aligned_allocator< ElementType > > vector
static void Solve(const Mat &x1, const Mat &x2, vector< Mat3 > *Hs)