Subversion Repositories seema-scanner

Rev

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

Rev 4 Rev 27
Line 1... Line 1...
1
#include "CodecPhaseShift2x3.h"
1
#include "CodecPhaseShift.h"
2
#include <math.h>
2
#include <math.h>
3
 
3
 
4
#include "cvtools.h"
4
#include "cvtools.h"
5
 
5
 
6
#ifndef M_PI
6
#ifndef M_PI
Line 25... Line 25...
25
    }
25
    }
26
 
26
 
27
    return phaseVector;
27
    return phaseVector;
28
}
28
}
29
 
29
 
30
EncoderPhaseShift2x3::EncoderPhaseShift2x3(unsigned int _screenCols, unsigned int _screenRows, CodecDir _dir) : Encoder(_screenCols, _screenRows, _dir){
30
EncoderPhaseShift::EncoderPhaseShift(unsigned int _screenCols, unsigned int _screenRows, CodecDir _dir) : Encoder(_screenCols, _screenRows, _dir){
31
 
31
 
32
    // Set N
32
    // Set N
33
    if(dir == CodecDirBoth)
33
    if(dir == CodecDirBoth)
34
        this->N = 12;
34
        this->N = 12;
35
    else
35
    else
Line 78... Line 78...
78
            patterns.push_back(patternI);
78
            patterns.push_back(patternI);
79
        }
79
        }
80
    }
80
    }
81
}
81
}
82
 
82
 
83
cv::Mat EncoderPhaseShift2x3::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
DecoderPhaseShift2x3::DecoderPhaseShift2x3(unsigned int _screenCols, unsigned int _screenRows, CodecDir _dir) : Decoder(_screenCols, _screenRows, _dir){
88
DecoderPhaseShift::DecoderPhaseShift(CodecDir _dir) : Decoder(_dir){
89
 
89
 
90
    if(dir == CodecDirBoth)
-
 
91
        this->N = 12;
-
 
92
    else
-
 
93
        this->N = 6;
-
 
94
 
-
 
95
    frames.resize(N);
-
 
96
}
-
 
97
 
-
 
98
void DecoderPhaseShift2x3::setFrame(unsigned int depth, cv::Mat frame){
-
 
99
    frames[depth] = frame;
-
 
100
}
90
}
101
 
91
 
102
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){
103
 
93
 
104
    const float pi = M_PI;
94
    const float pi = M_PI;
Line 119... Line 109...
119
 
109
 
120
    //absPhase.addref();
110
    //absPhase.addref();
121
    return absPhase;
111
    return absPhase;
122
}
112
}
123
 
113
 
124
void DecoderPhaseShift2x3::decodeFrames(cv::Mat &up, cv::Mat &vp, cv::Mat &mask, cv::Mat &shading){
114
void DecoderPhaseShift::decodeFrames(const std::vector<cv::Mat> frames, cv::Mat &up, cv::Mat &vp, cv::Mat &mask, cv::Mat &shading){
125
 
115
 
126
    const float pi = M_PI;
116
    const float pi = M_PI;
127
 
117
 
128
    if(dir & CodecDirHorizontal){
118
    if(dir & CodecDirHorizontal){
129
        std::vector<cv::Mat> framesHorz(frames.begin(), frames.begin()+6);
119
        std::vector<cv::Mat> framesHorz(frames.begin(), frames.begin()+6);
Line 136... Line 126...
136
        upPhaseCue.convertTo(upPhaseCue, CV_8U);
126
        upPhaseCue.convertTo(upPhaseCue, CV_8U);
137
        upPhaseCue.convertTo(upPhaseCue, CV_32F);
127
        upPhaseCue.convertTo(upPhaseCue, CV_32F);
138
 
128
 
139
        // unwrap absolute phase using phase cue
129
        // unwrap absolute phase using phase cue
140
        up += upPhaseCue*2*pi;
130
        up += upPhaseCue*2*pi;
141
        up *= screenCols/(2*pi*nPhases);
-
 
-
 
131
 
142
    }
132
    }
143
    if(dir & CodecDirVertical){
133
    if(dir & CodecDirVertical){
144
        std::vector<cv::Mat> framesVert(frames.end()-6, frames.end());
134
        std::vector<cv::Mat> framesVert(frames.end()-6, frames.end());
145
 
135
 
146
        // Vertical decoding
136
        // Vertical decoding
Line 151... Line 141...
151
        vpPhaseCue.convertTo(vpPhaseCue, CV_8U);
141
        vpPhaseCue.convertTo(vpPhaseCue, CV_8U);
152
        vpPhaseCue.convertTo(vpPhaseCue, CV_32F);
142
        vpPhaseCue.convertTo(vpPhaseCue, CV_32F);
153
 
143
 
154
        // unwrap absolute phase using phase cue
144
        // unwrap absolute phase using phase cue
155
        vp += vpPhaseCue*2*pi;
145
        vp += vpPhaseCue*2*pi;
156
        vp *= screenRows/(2*pi*nPhases);
-
 
-
 
146
 
157
    }
147
    }
158
 
148
 
159
    // Calculate modulation
149
    // Calculate modulation
160
    cv::Mat I1, I2, I3;
150
    cv::Mat I1, I2, I3;
161
    frames[3].convertTo(I1, CV_32F);
151
    frames[3].convertTo(I1, CV_32F);