ppf_normal_computation.cpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. //
  2. // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  3. //
  4. // By downloading, copying, installing or using the software you agree to this license.
  5. // If you do not agree to this license, do not download, install,
  6. // copy or use the software.
  7. //
  8. //
  9. // License Agreement
  10. // For Open Source Computer Vision Library
  11. //
  12. // Copyright (C) 2014, OpenCV Foundation, all rights reserved.
  13. // Third party copyrights are property of their respective owners.
  14. //
  15. // Redistribution and use in source and binary forms, with or without modification,
  16. // are permitted provided that the following conditions are met:
  17. //
  18. // * Redistribution's of source code must retain the above copyright notice,
  19. // this list of conditions and the following disclaimer.
  20. //
  21. // * Redistribution's in binary form must reproduce the above copyright notice,
  22. // this list of conditions and the following disclaimer in the documentation
  23. // and/or other materials provided with the distribution.
  24. //
  25. // * The name of the copyright holders may not be used to endorse or promote products
  26. // derived from this software without specific prior written permission.
  27. //
  28. // This software is provided by the copyright holders and contributors "as is" and
  29. // any express or implied warranties, including, but not limited to, the implied
  30. // warranties of merchantability and fitness for a particular purpose are disclaimed.
  31. // In no event shall the Intel Corporation or contributors be liable for any direct,
  32. // indirect, incidental, special, exemplary, or consequential damages
  33. // (including, but not limited to, procurement of substitute goods or services;
  34. // loss of use, data, or profits; or business interruption) however caused
  35. // and on any theory of liability, whether in contract, strict liability,
  36. // or tort (including negligence or otherwise) arising in any way out of
  37. // the use of this software, even if advised of the possibility of such damage.
  38. #include <iostream>
  39. #include "opencv2/surface_matching.hpp"
  40. #include "opencv2/surface_matching/ppf_helpers.hpp"
  41. using namespace std;
  42. static void help(const string& errorMessage)
  43. {
  44. cout << "Program init error : " << errorMessage << endl;
  45. cout << "\nUsage : ppf_normal_computation [input model file] [output model file]" << endl;
  46. cout << "\nPlease start again with new parameters" << endl;
  47. }
  48. int main(int argc, char** argv)
  49. {
  50. if (argc < 3)
  51. {
  52. help("Not enough input arguments");
  53. exit(1);
  54. }
  55. string modelFileName = (string)argv[1];
  56. string outputFileName = (string)argv[2];
  57. cv::Mat points, pointsAndNormals;
  58. cout << "Loading points\n";
  59. cv::ppf_match_3d::loadPLYSimple(modelFileName.c_str(), 1).copyTo(points);
  60. cout << "Computing normals\n";
  61. cv::Vec3d viewpoint(0, 0, 0);
  62. cv::ppf_match_3d::computeNormalsPC3d(points, pointsAndNormals, 6, false, viewpoint);
  63. std::cout << "Writing points\n";
  64. cv::ppf_match_3d::writePLY(pointsAndNormals, outputFileName.c_str());
  65. //the following function can also be used for debugging purposes
  66. //cv::ppf_match_3d::writePLYVisibleNormals(pointsAndNormals, outputFileName.c_str());
  67. std::cout << "Done\n";
  68. return 0;
  69. }