timePinholeCamera.cpp
Go to the documentation of this file.
1 /* ----------------------------------------------------------------------------
2 
3  * GTSAM Copyright 2010, Georgia Tech Research Corporation,
4  * Atlanta, Georgia 30332-0415
5  * All Rights Reserved
6  * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
7 
8  * See LICENSE for the license information
9 
10  * -------------------------------------------------------------------------- */
11 
18 #include <time.h>
19 #include <iostream>
20 
23 
24 using namespace std;
25 using namespace gtsam;
26 
27 int main()
28 {
29  int n = 1e6;
30 
31  const Pose3 pose1(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5));
32 
33  static Cal3Bundler K(500, 1e-3, 2.0*1e-3);
34  const PinholeCamera<Cal3Bundler> camera(pose1,K);
35  const Point3 point1(-0.08,-0.08, 0.0);
36 
42  // Oct 12 2013, iMac 3.06GHz Core i3
43  // Original: 0.14737 musecs/call
44  // After collapse: 0.11469 musecs/call
45  // Cal3DS2: 0.14201 musecs/call
46  // After Cal3DS2 fix: 0.12231 musecs/call
47  // Cal3Bundler: 0.12000 musecs/call
48  // Cal3Bundler fix: 0.14637 musecs/call
49  // June 24 2014, Macbook Pro 2.3GHz Core i7
50  // GTSAM 3.1: 0.04295 musecs/call
51  // After project fix: 0.04193 musecs/call
52 
53  {
54  long timeLog = clock();
55  for(int i = 0; i < n; i++)
56  camera.project(point1);
57  long timeLog2 = clock();
58  double seconds = (double)(timeLog2-timeLog)/CLOCKS_PER_SEC;
59  cout << ((double)seconds*1e9/n) << " nanosecs/call" << endl;
60  }
61 
62  // Oct 12 2014, Macbook Air
63  {
64  long timeLog = clock();
65  Point2 measurement(0,0);
66  for(int i = 0; i < n; i++)
67  camera.project(point1)-measurement;
68  long timeLog2 = clock();
69  double seconds = (double)(timeLog2-timeLog)/CLOCKS_PER_SEC;
70  cout << ((double)seconds*1e9/n) << " nanosecs/call" << endl;
71  }
72 
73  // Oct 12 2013, iMac 3.06GHz Core i3
74  // Original: 3.8720 musecs/call
75  // After collapse: 2.6269 musecs/call
76  // Cal3DS2: 4.3330 musecs/call
77  // After Cal3DS2 fix: 3.2857 musecs/call
78  // Cal3Bundler: 2.6556 musecs/call
79  // Cal3Bundler fix: 2.1613 musecs/call
80  // June 24 2014, Macbook Pro 2.3GHz Core i7
81  // GTSAM 3.1: 0.2322 musecs/call
82  // After project fix: 0.2094 musecs/call
83  {
84  Matrix Dpose, Dpoint;
85  long timeLog = clock();
86  for(int i = 0; i < n; i++)
87  camera.project(point1, Dpose, Dpoint, boost::none);
88  long timeLog2 = clock();
89  double seconds = (double)(timeLog2-timeLog)/CLOCKS_PER_SEC;
90  cout << ((double)seconds*1e9/n) << " nanosecs/call" << endl;
91  }
92 
93  // Oct 12 2013, iMac 3.06GHz Core i3
94  // Original: 4.0119 musecs/call
95  // After collapse: 2.5698 musecs/call
96  // Cal3DS2: 4.8325 musecs/call
97  // After Cal3DS2 fix: 3.4483 musecs/call
98  // Cal3Bundler: 2.5112 musecs/call
99  // Cal3Bundler fix: 2.0946 musecs/call
100  // June 24 2014, Macbook Pro 2.3GHz Core i7
101  // GTSAM 3.1: 0.2294 musecs/call
102  // After project fix: 0.2093 nanosecs/call
103  {
104  Matrix Dpose, Dpoint, Dcal;
105  long timeLog = clock();
106  for(int i = 0; i < n; i++)
107  camera.project(point1, Dpose, Dpoint, Dcal);
108  long timeLog2 = clock();
109  double seconds = (double)(timeLog2-timeLog)/CLOCKS_PER_SEC;
110  cout << ((double)seconds*1e9/n) << " nanosecs/call" << endl;
111  }
112 
113  return 0;
114 }
Eigen::Vector3d Vector3
Definition: Vector.h:43
Vector2 Point2
Definition: Point2.h:27
int n
Eigen::MatrixXd Matrix
Definition: base/Matrix.h:43
static Cal3_S2 K(500, 500, 0.1, 640/2, 480/2)
double measurement(10.0)
Definition: Half.h:150
Base class for all pinhole cameras.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
static const Pose3 pose1(Rot3(), Point3(0, 1, 0.5))
traits
Definition: chartTesting.h:28
Point2 project(const Point3 &pw, OptionalJacobian< 2, 6 > Dpose=boost::none, OptionalJacobian< 2, 3 > Dpoint=boost::none, OptionalJacobian< 2, DimK > Dcal=boost::none) const
project a 3D point from world coordinates into the image
Definition: PinholePose.h:118
const Point3 point1(3.0, 4.0, 2.0)
Vector3 Point3
Definition: Point3.h:35
int main()
static const CalibratedCamera camera(kDefaultPose)
Calibration used by Bundler.


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:50:38