Welcome to mirror list, hosted at ThFree Co, Russian Federation.

homography.h « multiview « libmv « libmv « extern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 8d2dff930eb70ca9d31335fe119f8b4a5368f928 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
// Copyright (c) 2011 libmv authors.
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to
// deal in the Software without restriction, including without limitation the
// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
// sell copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
// IN THE SOFTWARE.

#ifndef LIBMV_MULTIVIEW_HOMOGRAPHY_H_
#define LIBMV_MULTIVIEW_HOMOGRAPHY_H_

#include "libmv/numeric/numeric.h"

namespace libmv {

/**
 * 2D homography transformation estimation.
 * 
 * This function estimates the homography transformation from a list of 2D
 * correspondences which represents either:
 *
 * - 3D points on a plane, with a general moving camera.
 * - 3D points with a rotating camera (pure rotation).
 * - 3D points + different planar projections
 * 
 * \param x1 The first 2xN or 3xN matrix of euclidean or homogeneous points.
 * \param x2 The second 2xN or 3xN matrix of euclidean or homogeneous points.
 * \param  H The 3x3 homography transformation matrix (8 dof) such that
 *               x2 = H * x1   with       |a b c| 
 *                                    H = |d e f|
 *                                        |g h 1| 
 * \param expected_precision The expected precision in order for instance 
 *                           to accept almost homography matrices.
 *
 * \return True if the transformation estimation has succeeded.
 * \note There must be at least 4 non-colinear points.
 */
bool Homography2DFromCorrespondencesLinear(const Mat &x1,
                                           const Mat &x2,
                                           Mat3 *H,
                                           double expected_precision =
                                             EigenDouble::dummy_precision());

/**
 * 3D Homography transformation estimation.
 *
 * This function can be used in order to estimate the homography transformation
 * from a list of 3D correspondences.
 *
 * \param[in] x1 The first 4xN matrix of homogeneous points
 * \param[in] x2 The second 4xN matrix of homogeneous points
 * \param[out] H The 4x4 homography transformation matrix (15 dof) such that
 *               x2 = H * x1   with       |a b c d| 
 *                                    H = |e f g h|
 *                                        |i j k l|
 *                                        |m n o 1| 
 * \param[in] expected_precision The expected precision in order for instance 
 *        to accept almost homography matrices.
 *
 * \return true if the transformation estimation has succeeded
 *
 * \note Need at least 5 non coplanar points 
 * \note Points coordinates must be in homogeneous coordinates
 */
bool Homography3DFromCorrespondencesLinear(const Mat &x1,
                                           const Mat &x2,
                                           Mat4 *H,
                                           double expected_precision =
                                             EigenDouble::dummy_precision());

/**
 * Calculate symmetric geometric cost:
 *
 * D(H * x1, x2)^2 + D(H^-1 * x2, x1)
 */
double SymmetricGeometricDistance(Mat3 &H, Vec2 &x1, Vec2 &x2);

}  // namespace libmv

#endif  // LIBMV_MULTIVIEW_HOMOGRAPHY_H_