Blender  V3.3
test_data_sets.h
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 
21 #ifndef LIBMV_MULTIVIEW_TEST_DATA_SETS_H_
22 #define LIBMV_MULTIVIEW_TEST_DATA_SETS_H_
23 
24 #include "libmv/base/vector.h"
27 #include "libmv/numeric/numeric.h"
28 
29 namespace libmv {
30 
32  Mat3 K1, K2; // Internal parameters.
33  Mat3 R1, R2; // Rotation.
34  Vec3 t1, t2; // Translation.
35  Mat34 P1, P2; // Projection matrix, P = K(R|t)
36  Mat3 F; // Fundamental matrix.
37  Mat3X X; // 3D points.
38  Mat2X x1, x2; // Projected points.
39 };
40 
41 // Two cameras at (-1,-1,-10) and (2,1,-10) looking approximately towards z+.
42 TwoViewDataSet TwoRealisticCameras(bool same_K = false);
43 
44 // An N-view metric dataset . An important difference between this
45 // and the other reconstruction data types is that all points are seen by all
46 // cameras.
47 struct NViewDataSet {
48  vector<Mat3> K; // Internal parameters (fx, fy, etc).
49  vector<Mat3> R; // Rotation.
50  vector<Vec3> t; // Translation.
51  vector<Vec3> C; // Camera centers.
52  Mat3X X; // 3D points.
53  vector<Mat2X> x; // Projected points; may have noise added.
54  vector<Vecu> x_ids; // Indexes of points corresponding to the projections
55 
56  int n; // Actual number of cameras.
57 
58  Mat34 P(int i) {
59  assert(i < n);
60  return K[i] * HStack(R[i], t[i]);
61  }
62  Mat3 F(int i, int j) {
63  Mat3 F_;
64  FundamentalFromProjections(P(i), P(j), &F_);
65  return F_;
66  }
67  void Reproject() {
68  for (int i = 0; i < n; ++i) {
69  x[i] = Project(P(i), X);
70  }
71  }
72  // TODO(keir): Add gaussian jitter functions.
73 };
74 
77  int _fx;
78  int _fy;
79  int _cx;
80  int _cy;
81 
83  double _dist;
85 
86  nViewDatasetConfigator(int fx = 1000,
87  int fy = 1000,
88  int cx = 500,
89  int cy = 500,
90  double distance = 1.5,
91  double jitter_amount = 0.01);
92 };
93 
95  int nviews,
96  int npoints,
98 
99 // Generates sparse projections (not all points are projected)
101  int nviews,
102  int npoints,
103  float view_ratio = 0.6,
104  unsigned min_projections = 3,
106 
107 } // namespace libmv
108 
109 #endif // LIBMV_MULTIVIEW_TEST_DATA_SETS_H_
T distance(const T &a, const T &b)
NViewDataSet NRealisticCamerasSparse(int nviews, int npoints, float view_ratio, unsigned min_projections, const nViewDatasetConfigator config)
void FundamentalFromProjections(const Mat34 &P1, const Mat34 &P2, Mat3 *F)
Definition: fundamental.cc:54
Eigen::Matrix< double, 3, 3 > Mat3
Definition: numeric.h:72
TwoViewDataSet TwoRealisticCameras(bool same_K)
Eigen::Matrix< T, ROWS, COLS > HStack(const Eigen::Matrix< T, RowsLeft, ColsLeft > &left, const Eigen::Matrix< T, RowsRight, ColsRight > &right)
Definition: numeric.h:376
Vec2 Project(const Mat34 &P, const Vec3 &X)
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
NViewDataSet NRealisticCamerasFull(int nviews, int npoints, const nViewDatasetConfigator config)
Eigen::Matrix< double, 2, Eigen::Dynamic > Mat2X
Definition: numeric.h:91
Mat3 F(int i, int j)
vector< Vec3 > t
vector< Mat2X > x
vector< Vec3 > C
vector< Mat3 > K
vector< Vecu > x_ids
vector< Mat3 > R
double _dist
Camera random position parameters.
int _fx
Internal camera parameters.
nViewDatasetConfigator(int fx=1000, int fy=1000, int cx=500, int cy=500, double distance=1.5, double jitter_amount=0.01)