sinusoidalpattern.hpp 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*M///////////////////////////////////////////////////////////////////////////////////////
  2. //
  3. // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
  4. //
  5. // By downloading, copying, installing or using the software you agree to this license.
  6. // If you do not agree to this license, do not download, install,
  7. // copy or use the software.
  8. //
  9. //
  10. // License Agreement
  11. // For Open Source Computer Vision Library
  12. //
  13. // Copyright (C) 2015, OpenCV Foundation, all rights reserved.
  14. // Third party copyrights are property of their respective owners.
  15. //
  16. // Redistribution and use in source and binary forms, with or without modification,
  17. // are permitted provided that the following conditions are met:
  18. //
  19. // * Redistribution's of source code must retain the above copyright notice,
  20. // this list of conditions and the following disclaimer.
  21. //
  22. // * Redistribution's in binary form must reproduce the above copyright notice,
  23. // this list of conditions and the following disclaimer in the documentation
  24. // and/or other materials provided with the distribution.
  25. //
  26. // * The name of the copyright holders may not be used to endorse or promote products
  27. // derived from this software without specific prior written permission.
  28. //
  29. // This software is provided by the copyright holders and contributors "as is" and
  30. // any express or implied warranties, including, but not limited to, the implied
  31. // warranties of merchantability and fitness for a particular purpose are disclaimed.
  32. // In no event shall the Intel Corporation or contributors be liable for any direct,
  33. // indirect, incidental, special, exemplary, or consequential damages
  34. // (including, but not limited to, procurement of substitute goods or services;
  35. // loss of use, data, or profits; or business interruption) however caused
  36. // and on any theory of liability, whether in contract, strict liability,
  37. // or tort (including negligence or otherwise) arising in any way out of
  38. // the use of this software, even if advised of the possibility of such damage.
  39. //
  40. //M*/
  41. #ifndef __OPENCV_SINUSOIDAL_PATTERN_HPP__
  42. #define __OPENCV_SINUSOIDAL_PATTERN_HPP__
  43. #include "opencv2/core.hpp"
  44. #include "opencv2/imgproc.hpp"
  45. #include "opencv2/structured_light/structured_light.hpp"
  46. #include <opencv2/phase_unwrapping.hpp>
  47. #include <opencv2/calib3d.hpp>
  48. namespace cv {
  49. namespace structured_light {
  50. //! @addtogroup structured_light
  51. //! @{
  52. //! Type of sinusoidal pattern profilometry methods.
  53. enum{
  54. FTP = 0,
  55. PSP = 1,
  56. FAPS = 2
  57. };
  58. /**
  59. * @brief Class implementing Fourier transform profilometry (FTP) , phase-shifting profilometry (PSP)
  60. * and Fourier-assisted phase-shifting profilometry (FAPS) based on @cite faps.
  61. * This class generates sinusoidal patterns that can be used with FTP, PSP and FAPS.
  62. */
  63. class CV_EXPORTS_W SinusoidalPattern : public StructuredLightPattern
  64. {
  65. public:
  66. /**
  67. * @brief Parameters of SinusoidalPattern constructor
  68. * @param width Projector's width.
  69. * @param height Projector's height.
  70. * @param nbrOfPeriods Number of period along the patterns direction.
  71. * @param shiftValue Phase shift between two consecutive patterns.
  72. * @param methodId Allow to choose between FTP, PSP and FAPS.
  73. * @param nbrOfPixelsBetweenMarkers Number of pixels between two consecutive markers on the same row.
  74. * @param setMarkers Allow to set markers on the patterns.
  75. * @param markersLocation vector used to store markers location on the patterns.
  76. */
  77. struct CV_EXPORTS_W Params
  78. {
  79. CV_WRAP Params();
  80. CV_PROP_RW int width;
  81. CV_PROP_RW int height;
  82. CV_PROP_RW int nbrOfPeriods;
  83. CV_PROP_RW float shiftValue;
  84. CV_PROP_RW int methodId;
  85. CV_PROP_RW int nbrOfPixelsBetweenMarkers;
  86. CV_PROP_RW bool horizontal;
  87. CV_PROP_RW bool setMarkers;
  88. std::vector<Point2f> markersLocation;
  89. };
  90. /**
  91. * @brief Constructor.
  92. * @param parameters SinusoidalPattern parameters SinusoidalPattern::Params: width, height of the projector and patterns parameters.
  93. *
  94. */
  95. CV_WRAP static Ptr<SinusoidalPattern> create( Ptr<SinusoidalPattern::Params> parameters =
  96. makePtr<SinusoidalPattern::Params>() );
  97. /**
  98. * @brief Compute a wrapped phase map from sinusoidal patterns.
  99. * @param patternImages Input data to compute the wrapped phase map.
  100. * @param wrappedPhaseMap Wrapped phase map obtained through one of the three methods.
  101. * @param shadowMask Mask used to discard shadow regions.
  102. * @param fundamental Fundamental matrix used to compute epipolar lines and ease the matching step.
  103. */
  104. CV_WRAP
  105. virtual void computePhaseMap( InputArrayOfArrays patternImages,
  106. OutputArray wrappedPhaseMap,
  107. OutputArray shadowMask = noArray(),
  108. InputArray fundamental = noArray()) = 0;
  109. /**
  110. * @brief Unwrap the wrapped phase map to remove phase ambiguities.
  111. * @param wrappedPhaseMap The wrapped phase map computed from the pattern.
  112. * @param unwrappedPhaseMap The unwrapped phase map used to find correspondences between the two devices.
  113. * @param camSize Resolution of the camera.
  114. * @param shadowMask Mask used to discard shadow regions.
  115. */
  116. CV_WRAP
  117. virtual void unwrapPhaseMap( InputArrayOfArrays wrappedPhaseMap,
  118. OutputArray unwrappedPhaseMap,
  119. cv::Size camSize,
  120. InputArray shadowMask = noArray() ) = 0;
  121. /**
  122. * @brief Find correspondences between the two devices thanks to unwrapped phase maps.
  123. * @param projUnwrappedPhaseMap Projector's unwrapped phase map.
  124. * @param camUnwrappedPhaseMap Camera's unwrapped phase map.
  125. * @param matches Images used to display correspondences map.
  126. */
  127. CV_WRAP
  128. virtual void findProCamMatches( InputArray projUnwrappedPhaseMap, InputArray camUnwrappedPhaseMap,
  129. OutputArrayOfArrays matches ) = 0;
  130. /**
  131. * @brief compute the data modulation term.
  132. * @param patternImages captured images with projected patterns.
  133. * @param dataModulationTerm Mat where the data modulation term is saved.
  134. * @param shadowMask Mask used to discard shadow regions.
  135. */
  136. CV_WRAP
  137. virtual void computeDataModulationTerm( InputArrayOfArrays patternImages,
  138. OutputArray dataModulationTerm,
  139. InputArray shadowMask ) = 0;
  140. };
  141. //! @}
  142. }
  143. }
  144. #endif