timeStereoCamera.cpp 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /* ----------------------------------------------------------------------------
  2. * GTSAM Copyright 2010, Georgia Tech Research Corporation,
  3. * Atlanta, Georgia 30332-0415
  4. * All Rights Reserved
  5. * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
  6. * See LICENSE for the license information
  7. * -------------------------------------------------------------------------- */
  8. /**
  9. * @file timeStereoCamera.cpp
  10. * @brief time StereoCamera derivatives
  11. * @author Frank Dellaert
  12. */
  13. #include <time.h>
  14. #include <iostream>
  15. #include <gtsam/geometry/StereoCamera.h>
  16. using namespace std;
  17. using namespace gtsam;
  18. int main()
  19. {
  20. int n = 100000;
  21. const Pose3 pose1(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5));
  22. const Cal3_S2Stereo::shared_ptr K(new Cal3_S2Stereo(1500, 1500, 0, 320, 240, 0.5));
  23. const StereoCamera camera(pose1, K);
  24. const Point3 point1(-0.08,-0.08, 0.0);
  25. Matrix computed1, computed2;
  26. long timeLog = clock();
  27. for(int i = 0; i < n; i++)
  28. camera.project(point1, computed1, computed2);
  29. long timeLog2 = clock();
  30. double seconds = (double)(timeLog2-timeLog)/CLOCKS_PER_SEC;
  31. cout << ((double)n/seconds) << " calls/second" << endl;
  32. cout << ((double)seconds*1000000/n) << " musecs/call" << endl;
  33. return 0;
  34. }