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 42 #ifndef __OPENCV_SINUSOIDAL_PATTERN_HPP__ 43 #define __OPENCV_SINUSOIDAL_PATTERN_HPP__ 44 45 #include "opencv2/core.hpp" 46 #include "opencv2/imgproc.hpp" 47 #include "opencv2/structured_light/structured_light.hpp" 48 #include <opencv2/phase_unwrapping.hpp> 49 #include <opencv2/calib3d.hpp> 50 51 namespace cv { 52 namespace structured_light { 53 //! @addtogroup structured_light 54 //! @{ 55 56 //! Type of sinusoidal pattern profilometry methods. 57 enum{ 58 FTP = 0, 59 PSP = 1, 60 FAPS = 2 61 }; 62 /** 63 * @brief Class implementing Fourier transform profilometry (FTP) , phase-shifting profilometry (PSP) 64 * and Fourier-assisted phase-shifting profilometry (FAPS) based on @cite faps. 65 66 * This class generates sinusoidal patterns that can be used with FTP, PSP and FAPS. 67 */ 68 class CV_EXPORTS_W SinusoidalPattern : public StructuredLightPattern 69 { 70 public: 71 /** 72 * @brief Parameters of SinusoidalPattern constructor 73 * @param width Projector's width. 74 * @param height Projector's height. 75 * @param nbrOfPeriods Number of period along the patterns direction. 76 * @param shiftValue Phase shift between two consecutive patterns. 77 * @param methodId Allow to choose between FTP, PSP and FAPS. 78 * @param nbrOfPixelsBetweenMarkers Number of pixels between two consecutive markers on the same row. 79 * @param setMarkers Allow to set markers on the patterns. 80 * @param markersLocation vector used to store markers location on the patterns. 81 */ 82 struct CV_EXPORTS_W Params 83 { 84 CV_WRAP Params(); 85 CV_PROP_RW int width; 86 CV_PROP_RW int height; 87 CV_PROP_RW int nbrOfPeriods; 88 CV_PROP_RW float shiftValue; 89 CV_PROP_RW int methodId; 90 CV_PROP_RW int nbrOfPixelsBetweenMarkers; 91 CV_PROP_RW bool horizontal; 92 CV_PROP_RW bool setMarkers; 93 std::vector<Point2f> markersLocation; 94 }; 95 /** 96 * @brief Constructor. 97 * @param parameters SinusoidalPattern parameters SinusoidalPattern::Params: width, height of the projector and patterns parameters. 98 * 99 */ 100 CV_WRAP static Ptr<SinusoidalPattern> create( Ptr<SinusoidalPattern::Params> parameters = 101 makePtr<SinusoidalPattern::Params>() ); 102 /** 103 * @brief Compute a wrapped phase map from sinusoidal patterns. 104 * @param patternImages Input data to compute the wrapped phase map. 105 * @param wrappedPhaseMap Wrapped phase map obtained through one of the three methods. 106 * @param shadowMask Mask used to discard shadow regions. 107 * @param fundamental Fundamental matrix used to compute epipolar lines and ease the matching step. 108 */ 109 CV_WRAP 110 virtual void computePhaseMap( InputArrayOfArrays patternImages, 111 OutputArray wrappedPhaseMap, 112 OutputArray shadowMask = noArray(), 113 InputArray fundamental = noArray()) = 0; 114 /** 115 * @brief Unwrap the wrapped phase map to remove phase ambiguities. 116 * @param wrappedPhaseMap The wrapped phase map computed from the pattern. 117 * @param unwrappedPhaseMap The unwrapped phase map used to find correspondences between the two devices. 118 * @param camSize Resolution of the camera. 119 * @param shadowMask Mask used to discard shadow regions. 120 */ 121 CV_WRAP 122 virtual void unwrapPhaseMap( InputArray wrappedPhaseMap, 123 OutputArray unwrappedPhaseMap, 124 cv::Size camSize, 125 InputArray shadowMask = noArray() ) = 0; 126 /** 127 * @brief Find correspondences between the two devices thanks to unwrapped phase maps. 128 * @param projUnwrappedPhaseMap Projector's unwrapped phase map. 129 * @param camUnwrappedPhaseMap Camera's unwrapped phase map. 130 * @param matches Images used to display correspondences map. 131 */ 132 CV_WRAP 133 virtual void findProCamMatches( InputArray projUnwrappedPhaseMap, InputArray camUnwrappedPhaseMap, 134 OutputArrayOfArrays matches ) = 0; 135 136 /** 137 * @brief compute the data modulation term. 138 * @param patternImages captured images with projected patterns. 139 * @param dataModulationTerm Mat where the data modulation term is saved. 140 * @param shadowMask Mask used to discard shadow regions. 141 */ 142 CV_WRAP 143 virtual void computeDataModulationTerm( InputArrayOfArrays patternImages, 144 OutputArray dataModulationTerm, 145 InputArray shadowMask ) = 0; 146 147 }; 148 //! @} 149 } 150 } 151 #endif 152