Subversion Repositories seema-scanner

Rev

Rev 27 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 27 Rev 36
Line 83... Line 83...
83
cv::Mat EncoderPhaseShift::getEncodingPattern(unsigned int depth){
83
cv::Mat EncoderPhaseShift::getEncodingPattern(unsigned int depth){
84
    return patterns[depth];
84
    return patterns[depth];
85
}
85
}
86
 
86
 
87
// Decoder
87
// Decoder
88
DecoderPhaseShift::DecoderPhaseShift(CodecDir _dir) : Decoder(_dir){
88
DecoderPhaseShift::DecoderPhaseShift(CodecDir _dir, int _screenCols, int _screenRows) : Decoder(_dir, _screenRows, _screenCols){
89
 
89
 
90
}
90
}
91
 
91
 
92
static cv::Mat absolutePhase(cv::Mat _I1, cv::Mat _I2, cv::Mat _I3){
92
static cv::Mat absolutePhase(cv::Mat _I1, cv::Mat _I2, cv::Mat _I3){
93
 
93
 
Line 109... Line 109...
109
 
109
 
110
    //absPhase.addref();
110
    //absPhase.addref();
111
    return absPhase;
111
    return absPhase;
112
}
112
}
113
 
113
 
114
void DecoderPhaseShift::decodeFrames(const std::vector<cv::Mat> frames, cv::Mat &up, cv::Mat &vp, cv::Mat &mask, cv::Mat &shading){
114
void DecoderPhaseShift::getCorrespondences(const std::vector<cv::Mat>& frames0, const std::vector<cv::Mat>& frames1, std::vector<cv::Point2f>& q0, std::vector<cv::Point2f>& q1, std::vector<cv::Point3f>& color){
115
 
115
 
116
    const float pi = M_PI;
-
 
117
 
-
 
118
    if(dir & CodecDirHorizontal){
-
 
119
        std::vector<cv::Mat> framesHorz(frames.begin(), frames.begin()+6);
-
 
120
 
-
 
121
        // Horizontal decoding
-
 
122
        up = absolutePhase(framesHorz[0], framesHorz[1], framesHorz[2]);
-
 
123
 
-
 
124
        cv::Mat upPhaseCue = absolutePhase(framesHorz[3], framesHorz[4], framesHorz[5]);
-
 
125
        upPhaseCue = (upPhaseCue*nPhases-up)/(2*pi);
-
 
126
        upPhaseCue.convertTo(upPhaseCue, CV_8U);
-
 
127
        upPhaseCue.convertTo(upPhaseCue, CV_32F);
-
 
128
 
-
 
129
        // unwrap absolute phase using phase cue
-
 
130
        up += upPhaseCue*2*pi;
-
 
131
 
-
 
132
    }
-
 
133
    if(dir & CodecDirVertical){
-
 
134
        std::vector<cv::Mat> framesVert(frames.end()-6, frames.end());
-
 
135
 
-
 
136
        // Vertical decoding
-
 
137
        vp = absolutePhase(framesVert[0], framesVert[1], framesVert[2]);
-
 
138
 
-
 
139
        cv::Mat vpPhaseCue = absolutePhase(framesVert[3], framesVert[4], framesVert[5]);
-
 
140
        vpPhaseCue = (vpPhaseCue*nPhases-vp)/(2*pi);
-
 
141
        vpPhaseCue.convertTo(vpPhaseCue, CV_8U);
-
 
142
        vpPhaseCue.convertTo(vpPhaseCue, CV_32F);
-
 
143
 
-
 
144
        // unwrap absolute phase using phase cue
-
 
145
        vp += vpPhaseCue*2*pi;
-
 
146
 
-
 
147
    }
-
 
148
 
-
 
149
    // Calculate modulation
-
 
150
    cv::Mat I1, I2, I3;
-
 
151
    frames[3].convertTo(I1, CV_32F);
-
 
152
    frames[4].convertTo(I2, CV_32F);
-
 
153
    frames[5].convertTo(I3, CV_32F);
-
 
154
    cv::Mat modulation;
-
 
155
    modulation = 3.0*(I1-I3).mul(I1-I3) + (2.0*I2-I1-I3).mul(2.0*I2-I1-I3);
-
 
156
    cv::sqrt(modulation, modulation);
-
 
157
    modulation.convertTo(shading, CV_8U);
-
 
158
    //shading = (1.0/3.0)*(framesHorz[3]+framesHorz[4]+framesHorz[5]);
-
 
159
 
-
 
160
    // Threshold modulation image for mask
-
 
161
    mask = shading > 50;
-
 
162
 
-
 
163
    cv::Mat element = cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(7,7));
-
 
164
    cv::erode(mask, mask, element);
-
 
165
}
116
}