perf_undistort.cpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // This file is part of OpenCV project.
  2. // It is subject to the license terms in the LICENSE file found in the top-level directory
  3. // of this distribution and at http://opencv.org/license.html
  4. #include "perf_precomp.hpp"
  5. namespace opencv_test {
  6. PERF_TEST(Undistort, InitUndistortMap)
  7. {
  8. Size size_w_h(512 + 3, 512);
  9. Mat k(3, 3, CV_32FC1);
  10. Mat d(1, 14, CV_64FC1);
  11. Mat dst(size_w_h, CV_32FC2);
  12. declare.in(k, d, WARMUP_RNG).out(dst);
  13. TEST_CYCLE() initUndistortRectifyMap(k, d, noArray(), k, size_w_h, CV_32FC2, dst, noArray());
  14. SANITY_CHECK_NOTHING();
  15. }
  16. PERF_TEST(Undistort, DISABLED_InitInverseRectificationMap)
  17. {
  18. Size size_w_h(512 + 3, 512);
  19. Mat k(3, 3, CV_32FC1);
  20. Mat d(1, 14, CV_64FC1);
  21. Mat dst(size_w_h, CV_32FC2);
  22. declare.in(k, d, WARMUP_RNG).out(dst);
  23. TEST_CYCLE() initInverseRectificationMap(k, d, noArray(), k, size_w_h, CV_32FC2, dst, noArray());
  24. SANITY_CHECK_NOTHING();
  25. }
  26. PERF_TEST(Undistort, fisheye_undistortPoints_100k_10iter)
  27. {
  28. const int pointsNumber = 100000;
  29. const Size imageSize(1280, 800);
  30. /* Set camera matrix */
  31. const Matx33d K(558.478087865323, 0, 620.458515360843,
  32. 0, 560.506767351568, 381.939424848348,
  33. 0, 0, 1);
  34. /* Set distortion coefficients */
  35. const Matx14d D(2.81e-06, 1.31e-06, -4.42e-06, -1.25e-06);
  36. /* Create two-channel points matrix */
  37. Mat xy[2] = {};
  38. xy[0].create(pointsNumber, 1, CV_64F);
  39. theRNG().fill(xy[0], RNG::UNIFORM, 0, imageSize.width); // x
  40. xy[1].create(pointsNumber, 1, CV_64F);
  41. theRNG().fill(xy[1], RNG::UNIFORM, 0, imageSize.height); // y
  42. Mat points;
  43. merge(xy, 2, points);
  44. /* Set fixed iteration number to check only c++ code, not algo convergence */
  45. TermCriteria termCriteria(TermCriteria::MAX_ITER, 10, 0);
  46. Mat undistortedPoints;
  47. TEST_CYCLE() fisheye::undistortPoints(points, undistortedPoints, K, D, noArray(), noArray(), termCriteria);
  48. SANITY_CHECK_NOTHING();
  49. }
  50. } // namespace