| 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 | |
| 12 | /** |
| 13 | * @file timeCalibratedCamera.cpp |
| 14 | * @brief time CalibratedCamera derivatives |
| 15 | * @author Frank Dellaert |
| 16 | */ |
| 17 | |
| 18 | #include <gtsam/geometry/Point2.h> |
| 19 | #include <gtsam/geometry/CalibratedCamera.h> |
| 20 | #include <ctime> |
| 21 | #include <iostream> |
| 22 | |
| 23 | using namespace std; |
| 24 | using namespace gtsam; |
| 25 | |
| 26 | int main() |
| 27 | { |
| 28 | int n = 100000; |
| 29 | |
| 30 | const Pose3 pose1(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5)); |
| 31 | |
| 32 | const CalibratedCamera camera(pose1); |
| 33 | const Point3 point1(-0.08,-0.08, 0.0); |
| 34 | |
| 35 | // Aug 8, iMac 3.06GHz Core i3 |
| 36 | // 371153 calls/second |
| 37 | // 2.69431 musecs/call |
| 38 | // AFTER collapse: |
| 39 | // 1.10733e+06 calls/second |
| 40 | // 0.90307 musecs/call |
| 41 | { |
| 42 | Matrix computed1, computed2; |
| 43 | long timeLog = clock(); |
| 44 | for(int i = 0; i < n; i++) |
| 45 | camera.project(point: point1, Dcamera: computed1, Dpoint: computed2); |
| 46 | long timeLog2 = clock(); |
| 47 | double seconds = (double)(timeLog2-timeLog)/CLOCKS_PER_SEC; |
| 48 | cout << ((double)n/seconds) << " calls/second" << endl; |
| 49 | cout << ((double)seconds*1000000/n) << " musecs/call" << endl; |
| 50 | } |
| 51 | |
| 52 | return 0; |
| 53 | } |
| 54 | |