Blender V4.3
intersect_test.cc
Go to the documentation of this file.
1// Copyright (c) 2007, 2008 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
22
23#include <iostream>
24
28#include "testing/testing.h"
29
30namespace libmv {
31
33 Mat3 K1 = Mat3::Identity();
34 // K1 << 320, 0, 160,
35 // 0, 320, 120,
36 // 0, 0, 1;
37 Mat3 K2 = Mat3::Identity();
38 // K2 << 360, 0, 170,
39 // 0, 360, 110,
40 // 0, 0, 1;
41 Mat3 R1 = RotationAroundZ(-0.1);
42 Mat3 R2 = RotationAroundX(-0.1);
43 Vec3 t1;
44 t1 << 1, 1, 10;
45 Vec3 t2;
46 t2 << -2, -1, 10;
47 Mat34 P1, P2;
48 P_From_KRt(K1, R1, t1, &P1);
49 P_From_KRt(K2, R2, t2, &P2);
50
51 // Mat3 F; FundamentalFromProjections(P1, P2, &F);
52
53 Mat3X X;
54 X.resize(3, 30);
55 X.setRandom();
56
57 Mat2X X1, X2;
58 Project(P1, X, &X1);
59 Project(P2, X, &X2);
60
61 for (int i = 0; i < X.cols(); ++i) {
62 Vec2 x1, x2;
63 MatrixColumn(X1, i, &x1);
64 MatrixColumn(X2, i, &x2);
65 Vec3 expected;
66 MatrixColumn(X, i, &expected);
67
71
73 Marker a = {1, 0, x1.x(), x1.y(), 1.0};
74 markers.push_back(a);
75 Marker b = {2, 0, x2.x(), x2.y(), 1.0};
76 markers.push_back(b);
77
79 Vec3 estimated = reconstruction.PointForTrack(0)->X;
80 EXPECT_NEAR(0, DistanceLInfinity(estimated, expected), 1e-8);
81 }
82}
83} // namespace libmv
#define X
#define X1
Definition RandGen.cpp:24
#define X2
Definition RandGen.cpp:25
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
DBVT_INLINE bool Intersect(const btDbvtAabbMm &a, const btDbvtAabbMm &b)
Definition btDbvt.h:621
ProjectivePoint * PointForTrack(int track)
Returns a pointer to the point corresponding to track.
local_group_size(16, 16) .push_constant(Type b
const vector< Marker > & markers
const ProjectiveReconstruction & reconstruction
Definition intersect.cc:198
double DistanceLInfinity(const TVec &x, const TVec &y)
Definition numeric.h:216
Eigen::Matrix< double, 3, 3 > Mat3
Definition numeric.h:72
Eigen::Vector2d Vec2
Definition numeric.h:105
Mat3 RotationAroundX(double angle)
Definition numeric.cc:25
TEST(PolynomialCameraIntrinsics2, ApplyOnFocalCenter)
void MatrixColumn(const Mat &A, int i, Vec2 *v)
Definition numeric.cc:127
Vec2 Project(const Mat34 &P, const Vec3 &X)
bool EuclideanIntersect(const vector< Marker > &markers, EuclideanReconstruction *reconstruction)
Definition intersect.cc:69
Eigen::Matrix< double, 3, 4 > Mat34
Definition numeric.h:73
Eigen::Vector3d Vec3
Definition numeric.h:106
Eigen::Matrix< double, 3, Eigen::Dynamic > Mat3X
Definition numeric.h:92
Mat3 RotationAroundZ(double angle)
Definition numeric.cc:49
Eigen::Matrix< double, 2, Eigen::Dynamic > Mat2X
Definition numeric.h:91
void P_From_KRt(const Mat3 &K, const Mat3 &R, const Vec3 &t, Mat34 *P)
Definition projection.cc:26