Subversion Repositories seema-scanner

Rev

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

Rev 181 Rev 182
Line 2... Line 2...
2
// Two Frequency Phase Shifting using the Heterodyne Principle
2
// Two Frequency Phase Shifting using the Heterodyne Principle
3
//
3
//
4
// This implementation follows "Reich, Ritter, Thesing, White light heterodyne principle for 3D-measurement", SPIE (1997)
4
// This implementation follows "Reich, Ritter, Thesing, White light heterodyne principle for 3D-measurement", SPIE (1997)
5
// Different from the paper, it uses only two different frequencies.
5
// Different from the paper, it uses only two different frequencies.
6
//
6
//
7
// The number of periods in the primary (higher frequency) can in principle be chosen freely, but small changes can have a considerable impact on quality.
7
// The number of periods in the primary frequency can be chosen freely, but small changes can have a considerable impact on quality.
8
// The number of phase shifts can be chosen freely (min. 3), and higher values reduce the effects of image noise. They also allow us to filter bad points based on energy at non-primary frequencies.
8
// The number of phase shifts can be chosen freely (min. 3), and higher values reduce the effects of image noise. They also allow us to filter bad points based on energy at non-primary frequencies.
9
//
9
//
10
 
10
 
11
#include "AlgorithmPhaseShiftTwoFreq.h"
11
#include "AlgorithmPhaseShiftTwoFreq.h"
12
#include <math.h>
12
#include <math.h>
13
 
13
 
14
#include "cvtools.h"
14
#include "cvtools.h"
-
 
15
#include "algorithmtools.h"
15
 
16
 
16
#ifndef M_PI
17
#ifndef M_PI
17
    #define M_PI 3.14159265358979323846
18
    #define M_PI 3.14159265358979323846
18
#endif
19
#endif
19
 
20
 
20
static unsigned int nStepsPrimary = 16; // number of shifts/steps in primary
21
static unsigned int nStepsPrimary = 16; // number of shifts/steps in primary
21
static unsigned int nStepsSecondary = 8; // number of shifts/steps in secondary
22
static unsigned int nStepsSecondary = 8; // number of shifts/steps in secondary
22
static float periodPrimary = 48; // primary period
23
static float nPeriodsPrimary = 48; // primary period
23
 
-
 
24
// Algorithm
-
 
25
static cv::Mat computePhaseVector(unsigned int length, float phase, float pitch){
-
 
26
 
-
 
27
    cv::Mat phaseVector(length, 1, CV_8UC3);
-
 
28
    //phaseVector.setTo(0);
-
 
29
 
-
 
30
    const float pi = M_PI;
-
 
31
 
-
 
32
    // Loop through vector
-
 
33
    for(int i=0; i<phaseVector.rows; i++){
-
 
34
        // Amplitude of channels
-
 
35
        float amp = 0.5*(1+cos(2*pi*i/pitch - phase));
-
 
36
        phaseVector.at<cv::Vec3b>(i, 0) = cv::Vec3b(255.0*amp,255.0*amp,255.0*amp);
-
 
37
    }
-
 
38
 
-
 
39
    return phaseVector;
-
 
40
}
-
 
41
 
24
 
42
AlgorithmPhaseShiftTwoFreq::AlgorithmPhaseShiftTwoFreq(unsigned int _screenCols, unsigned int _screenRows) : Algorithm(_screenCols, _screenRows){
25
AlgorithmPhaseShiftTwoFreq::AlgorithmPhaseShiftTwoFreq(unsigned int _screenCols, unsigned int _screenRows) : Algorithm(_screenCols, _screenRows){
43
 
26
 
44
    // Set N
27
    // Set N
45
    N = 2+nStepsPrimary+nStepsSecondary;
28
    N = 2+nStepsPrimary+nStepsSecondary;
46
 
29
 
47
    // Determine the secondary (wider) period
30
    // Determine the secondary (wider) period
48
    float pSecondary = (screenCols*periodPrimary)/(screenCols-periodPrimary);
31
    float nPeriodsSecondary = (screenCols*nPeriodsPrimary)/(screenCols-nPeriodsPrimary);
49
 
32
 
50
    // all on pattern
33
    // all on pattern
51
    cv::Mat allOn(1, screenCols, CV_8UC3, cv::Scalar::all(255));
34
    cv::Mat allOn(1, screenCols, CV_8UC3, cv::Scalar::all(255));
52
    patterns.push_back(allOn);
35
    patterns.push_back(allOn);
53
 
36
 
Line 59... Line 42...
59
    const float pi = M_PI;
42
    const float pi = M_PI;
60
 
43
 
61
    // Primary encoding patterns
44
    // Primary encoding patterns
62
    for(unsigned int i=0; i<nStepsPrimary; i++){
45
    for(unsigned int i=0; i<nStepsPrimary; i++){
63
        float phase = 2.0*pi/nStepsPrimary * i;
46
        float phase = 2.0*pi/nStepsPrimary * i;
64
        float pitch = periodPrimary;
47
        float pitch = nPeriodsPrimary;
65
        cv::Mat patternI(1,1,CV_8U);
48
        cv::Mat patternI(1,1,CV_8U);
66
        patternI = computePhaseVector(screenCols, phase, pitch);
49
        patternI = computePhaseVector(screenCols, phase, pitch);
67
        patterns.push_back(patternI.t());
50
        patterns.push_back(patternI.t());
68
    }
51
    }
69
 
52
 
70
    // Secondary encoding patterns
53
    // Secondary encoding patterns
71
    for(unsigned int i=0; i<nStepsSecondary; i++){
54
    for(unsigned int i=0; i<nStepsSecondary; i++){
72
        float phase = 2.0*pi/nStepsSecondary * i;
55
        float phase = 2.0*pi/nStepsSecondary * i;
73
        float pitch = pSecondary;
56
        float pitch = nPeriodsSecondary;
74
        cv::Mat patternI(1,1,CV_8U);
57
        cv::Mat patternI(1,1,CV_8U);
75
        patternI = computePhaseVector(screenCols, phase, pitch);
58
        patternI = computePhaseVector(screenCols, phase, pitch);
76
        patterns.push_back(patternI.t());
59
        patterns.push_back(patternI.t());
77
    }
60
    }
78
 
61
 
Line 81... Line 64...
81
 
64
 
82
cv::Mat AlgorithmPhaseShiftTwoFreq::getEncodingPattern(unsigned int depth){
65
cv::Mat AlgorithmPhaseShiftTwoFreq::getEncodingPattern(unsigned int depth){
83
    return patterns[depth];
66
    return patterns[depth];
84
}
67
}
85
 
68
 
86
 
-
 
87
//// Absolute phase from 3 frames
-
 
88
//static cv::Mat getPhase(const cv::Mat I1, const cv::Mat I2, const cv::Mat I3){
-
 
89
 
-
 
90
//    cv::Mat_<float> I1_(I1);
-
 
91
//    cv::Mat_<float> I2_(I2);
-
 
92
//    cv::Mat_<float> I3_(I3);
-
 
93
 
-
 
94
//    cv::Mat phase;
-
 
95
 
-
 
96
//    // One call approach
-
 
97
//    cv::phase(2.0*I1_-I3_-I2_, sqrt(3.0)*(I2_-I3_), phase);
-
 
98
//    return phase;
-
 
99
 
-
 
100
//}
-
 
101
 
-
 
102
// Phase unwrapping by means of a phase cue
-
 
103
static cv::Mat unwrapWithCue(const cv::Mat up, const cv::Mat upCue, float nPhases){
-
 
104
 
-
 
105
    const float pi = M_PI;
-
 
106
 
-
 
107
    // Determine number of jumps
-
 
108
    cv::Mat P = (upCue*nPhases-up)/(2.0*pi);
-
 
109
 
-
 
110
    // Round to integers
-
 
111
    P.convertTo(P, CV_8U);
-
 
112
    P.convertTo(P, CV_32F);
-
 
113
 
-
 
114
    // Add to phase
-
 
115
    cv::Mat upUnwrapped = up + P*2*pi;
-
 
116
 
-
 
117
    // Scale to range [0; 2pi]
-
 
118
    upUnwrapped *= 1.0/nPhases;
-
 
119
 
-
 
120
    return upUnwrapped;
-
 
121
}
-
 
122
 
-
 
123
// Absolute phase and magnitude from N frames
-
 
124
static std::vector<cv::Mat> getDFTComponents(const std::vector<cv::Mat> frames){
-
 
125
 
-
 
126
    unsigned int N = frames.size();
-
 
127
 
-
 
128
//    std::vector<cv::Mat> framesReverse = frames;
-
 
129
//    std::reverse(framesReverse.begin(), framesReverse.end());
-
 
130
 
-
 
131
    // DFT approach
-
 
132
    cv::Mat I;
-
 
133
    cv::merge(frames, I);
-
 
134
    unsigned int w = I.cols;
-
 
135
    unsigned int h = I.rows;
-
 
136
    I = I.reshape(1, h*w);
-
 
137
    I.convertTo(I, CV_32F);
-
 
138
    cv::Mat fI;
-
 
139
    cv::dft(I, fI, cv::DFT_ROWS + cv::DFT_COMPLEX_OUTPUT);
-
 
140
    fI = fI.reshape(N*2, h);
-
 
141
 
-
 
142
    std::vector<cv::Mat> fIcomp;
-
 
143
    cv::split(fI, fIcomp);
-
 
144
 
-
 
145
    return fIcomp;
-
 
146
 
-
 
147
}
-
 
148
 
-
 
149
void AlgorithmPhaseShiftTwoFreq::get3DPoints(SMCalibrationParameters calibration, const std::vector<cv::Mat>& frames0, const std::vector<cv::Mat>& frames1, std::vector<cv::Point3f>& Q, std::vector<cv::Vec3b>& color){
69
void AlgorithmPhaseShiftTwoFreq::get3DPoints(SMCalibrationParameters calibration, const std::vector<cv::Mat>& frames0, const std::vector<cv::Mat>& frames1, std::vector<cv::Point3f>& Q, std::vector<cv::Vec3b>& color){
150
 
70
 
151
    const float pi = M_PI;
71
    const float pi = M_PI;
152
 
72
 
153
    assert(frames0.size() == N);
73
    assert(frames0.size() == N);
Line 168... Line 88...
168
    // Interpolation maps (lens distortion and rectification)
88
    // Interpolation maps (lens distortion and rectification)
169
    cv::Mat map0X, map0Y, map1X, map1Y;
89
    cv::Mat map0X, map0Y, map1X, map1Y;
170
    cv::initUndistortRectifyMap(calibration.K0, calibration.k0, R0, P0, frameSize, CV_32F, map0X, map0Y);
90
    cv::initUndistortRectifyMap(calibration.K0, calibration.k0, R0, P0, frameSize, CV_32F, map0X, map0Y);
171
    cv::initUndistortRectifyMap(calibration.K1, calibration.k1, R1, P1, frameSize, CV_32F, map1X, map1Y);
91
    cv::initUndistortRectifyMap(calibration.K1, calibration.k1, R1, P1, frameSize, CV_32F, map1X, map1Y);
172
 
92
 
-
 
93
    int frameRectRows = map0X.rows;
-
 
94
    int frameRectCols = map0X.cols;
-
 
95
 
173
    // Gray-scale and remap
96
    // Gray-scale and remap
174
    std::vector<cv::Mat> frames0Rect(N);
97
    std::vector<cv::Mat> frames0Rect(N);
175
    std::vector<cv::Mat> frames1Rect(N);
98
    std::vector<cv::Mat> frames1Rect(N);
176
    for(unsigned int i=0; i<N; i++){
99
    for(unsigned int i=0; i<N; i++){
177
        cv::Mat temp;
100
        cv::Mat temp;
Line 182... Line 105...
182
    }
105
    }
183
 
106
 
184
    // Decode camera0
107
    // Decode camera0
185
    std::vector<cv::Mat> frames0Primary(frames0Rect.begin()+2, frames0Rect.begin()+2+nStepsPrimary);
108
    std::vector<cv::Mat> frames0Primary(frames0Rect.begin()+2, frames0Rect.begin()+2+nStepsPrimary);
186
    std::vector<cv::Mat> frames0Secondary(frames0Rect.begin()+2+nStepsPrimary, frames0Rect.end());
109
    std::vector<cv::Mat> frames0Secondary(frames0Rect.begin()+2+nStepsPrimary, frames0Rect.end());
-
 
110
 
187
    std::vector<cv::Mat> F0Primary = getDFTComponents(frames0Primary);
111
    std::vector<cv::Mat> F0Primary = getDFTComponents(frames0Primary);
188
    cv::Mat up0Primary;
112
    cv::Mat up0Primary;
189
    cv::phase(F0Primary[2], -F0Primary[3], up0Primary);
113
    cv::phase(F0Primary[2], -F0Primary[3], up0Primary);
190
    //cv::Mat up0Secondary = getPhase(frames0Secondary[0], frames0Secondary[1], frames0Secondary[2]);
-
 
-
 
114
 
191
    std::vector<cv::Mat> F0Secondary = getDFTComponents(frames0Secondary);
115
    std::vector<cv::Mat> F0Secondary = getDFTComponents(frames0Secondary);
192
    cv::Mat up0Secondary;
116
    cv::Mat up0Secondary;
193
    cv::phase(F0Secondary[2], -F0Secondary[3], up0Secondary);
117
    cv::phase(F0Secondary[2], -F0Secondary[3], up0Secondary);
-
 
118
 
194
    cv::Mat up0Equivalent = up0Primary - up0Secondary;
119
    cv::Mat up0Equivalent = up0Primary - up0Secondary;
195
    up0Equivalent = cvtools::modulo(up0Equivalent, 2.0*pi);
120
    up0Equivalent = cvtools::modulo(up0Equivalent, 2.0*pi);
196
    cv::Mat up0 = unwrapWithCue(up0Primary, up0Equivalent, (float)screenCols/periodPrimary);
121
    cv::Mat up0 = unwrapWithCue(up0Primary, up0Equivalent, (float)screenCols/nPeriodsPrimary);
197
    up0 *= screenCols/(2.0*pi);
122
    up0 *= screenCols/(2.0*pi);
198
    cv::Mat amplitude0;
123
    cv::Mat amplitude0;
199
    cv::magnitude(F0Primary[2], -F0Primary[3], amplitude0);
124
    cv::magnitude(F0Primary[2], -F0Primary[3], amplitude0);
200
 
125
 
-
 
126
    // Collected signal energy at higher frequencies
-
 
127
    cv::Mat energy0Primary(frameRectRows, frameRectCols, CV_32F, cv::Scalar(0.0));
-
 
128
    for(unsigned int i=0; i<nStepsPrimary-1; i++){
-
 
129
        cv::Mat magnitude;
-
 
130
        cv::magnitude(F0Primary[i*2 + 2], F0Primary[i*2 + 3], magnitude);
-
 
131
        cv::add(energy0Primary, magnitude, energy0Primary, cv::noArray(), CV_32F);
-
 
132
    }
-
 
133
 
-
 
134
    cv::Mat energy0Secondary(frameRectRows, frameRectCols, CV_32F, cv::Scalar(0.0));
-
 
135
    for(unsigned int i=0; i<nStepsSecondary-1; i++){
-
 
136
        cv::Mat magnitude;
-
 
137
        cv::magnitude(F0Secondary[i*2 + 2], F0Secondary[i*2 + 3], magnitude);
-
 
138
        cv::add(energy0Secondary, magnitude, energy0Secondary, cv::noArray(), CV_32F);
-
 
139
    }
-
 
140
 
201
    // Decode camera1
141
    // Decode camera1
202
    std::vector<cv::Mat> frames1Primary(frames1Rect.begin()+2, frames1Rect.begin()+2+nStepsPrimary);
142
    std::vector<cv::Mat> frames1Primary(frames1Rect.begin()+2, frames1Rect.begin()+2+nStepsPrimary);
203
    std::vector<cv::Mat> frames1Secondary(frames1Rect.begin()+2+nStepsPrimary, frames1Rect.end());
143
    std::vector<cv::Mat> frames1Secondary(frames1Rect.begin()+2+nStepsPrimary, frames1Rect.end());
-
 
144
 
204
    std::vector<cv::Mat> F1Primary = getDFTComponents(frames1Primary);
145
    std::vector<cv::Mat> F1Primary = getDFTComponents(frames1Primary);
205
    cv::Mat up1Primary;
146
    cv::Mat up1Primary;
206
    cv::phase(F1Primary[2], -F1Primary[3], up1Primary);
147
    cv::phase(F1Primary[2], -F1Primary[3], up1Primary);
207
    //cv::Mat up1Secondary = getPhase(frames1Secondary[0], frames1Secondary[1], frames1Secondary[2]);
-
 
-
 
148
 
208
    std::vector<cv::Mat> F1Secondary = getDFTComponents(frames1Secondary);
149
    std::vector<cv::Mat> F1Secondary = getDFTComponents(frames1Secondary);
209
    cv::Mat up1Secondary;
150
    cv::Mat up1Secondary;
210
    cv::phase(F1Secondary[2], -F1Secondary[3], up1Secondary);
151
    cv::phase(F1Secondary[2], -F1Secondary[3], up1Secondary);
-
 
152
 
211
    cv::Mat up1Equivalent = up1Primary - up1Secondary;
153
    cv::Mat up1Equivalent = up1Primary - up1Secondary;
212
    up1Equivalent = cvtools::modulo(up1Equivalent, 2.0*pi);
154
    up1Equivalent = cvtools::modulo(up1Equivalent, 2.0*pi);
213
    cv::Mat up1 = unwrapWithCue(up1Primary, up1Equivalent, (float)screenCols/periodPrimary);
155
    cv::Mat up1 = unwrapWithCue(up1Primary, up1Equivalent, (float)screenCols/nPeriodsPrimary);
214
    up1 *= screenCols/(2.0*pi);
156
    up1 *= screenCols/(2.0*pi);
215
    cv::Mat amplitude1;
157
    cv::Mat amplitude1;
216
    cv::magnitude(F1Primary[2], -F1Primary[3], amplitude1);
158
    cv::magnitude(F1Primary[2], -F1Primary[3], amplitude1);
217
 
159
 
-
 
160
    #ifdef Q_DEBUG
218
cvtools::writeMat(up0Primary, "up0Primary.mat", "up0Primary");
161
        cvtools::writeMat(up0Primary, "up0Primary.mat", "up0Primary");
219
cvtools::writeMat(up0Secondary, "up0Secondary.mat", "up0Secondary");
162
        cvtools::writeMat(up0Secondary, "up0Secondary.mat", "up0Secondary");
220
cvtools::writeMat(up0Equivalent, "up0Equivalent.mat", "up0Equivalent");
163
        cvtools::writeMat(up0Equivalent, "up0Equivalent.mat", "up0Equivalent");
221
cvtools::writeMat(up0, "up0.mat", "up0");
164
        cvtools::writeMat(up0, "up0.mat", "up0");
222
cvtools::writeMat(amplitude0, "amplitude0.mat", "amplitude0");
165
        cvtools::writeMat(amplitude0, "amplitude0.mat", "amplitude0");
-
 
166
    #endif
-
 
167
 
-
 
168
    // Collected signal energy at higher frequencies
-
 
169
    cv::Mat energy1Primary(frameRectRows, frameRectCols, CV_32F, cv::Scalar(0.0));
-
 
170
    for(unsigned int i=0; i<nStepsPrimary-1; i++){
-
 
171
        cv::Mat magnitude;
-
 
172
        cv::magnitude(F1Primary[i*2 + 2], F1Primary[i*2 + 3], magnitude);
-
 
173
        cv::add(energy1Primary, magnitude, energy1Primary, cv::noArray(), CV_32F);
-
 
174
    }
-
 
175
 
-
 
176
    cv::Mat energy1Secondary(frameRectRows, frameRectCols, CV_32F, cv::Scalar(0.0));
-
 
177
    for(unsigned int i=0; i<nStepsSecondary-1; i++){
-
 
178
        cv::Mat magnitude;
-
 
179
        cv::magnitude(F1Secondary[i*2 + 2], F1Secondary[i*2 + 3], magnitude);
-
 
180
        cv::add(energy1Secondary, magnitude, energy1Secondary, cv::noArray(), CV_32F);
-
 
181
    }
223
 
182
 
224
    // color debayer and remap
183
    // color debayer and remap
225
    cv::Mat color0, color1;
184
    cv::Mat color0, color1;
226
//    frames0[0].convertTo(color0Rect, CV_8UC1, 1.0/256.0);
-
 
227
    cv::cvtColor(frames0[0], color0, CV_BayerBG2RGB);
185
    cv::cvtColor(frames0[0], color0, CV_BayerBG2RGB);
228
    cv::remap(color0, color0, map0X, map0Y, CV_INTER_LINEAR);
186
    cv::remap(color0, color0, map0X, map0Y, CV_INTER_LINEAR);
229
 
187
 
230
//    frames1[0].convertTo(color1Rect, CV_8UC1, 1.0/256.0);
-
 
231
    cv::cvtColor(frames1[0], color1, CV_BayerBG2RGB);
188
    cv::cvtColor(frames1[0], color1, CV_BayerBG2RGB);
232
    cv::remap(color1, color1, map1X, map1Y, CV_INTER_LINEAR);
189
    cv::remap(color1, color1, map1X, map1Y, CV_INTER_LINEAR);
233
 
190
 
-
 
191
    #ifdef Q_DEBUG
234
//cvtools::writeMat(color0, "color0.mat", "color0");
192
        cvtools::writeMat(color0, "color0.mat", "color0");
235
//cvtools::writeMat(color1, "color1.mat", "color1");
193
        cvtools::writeMat(color1, "color1.mat", "color1");
-
 
194
    #endif
236
 
195
 
237
    // Occlusion masks
196
    // Occlusion masks
238
    cv::Mat occlusion0, occlusion1;
197
    cv::Mat occlusion0, occlusion1;
239
    cv::subtract(frames0Rect[0], frames0Rect[1], occlusion0);
198
    cv::subtract(frames0Rect[0], frames0Rect[1], occlusion0);
240
    occlusion0 = (occlusion0 > 25) & (occlusion0 < 250);
199
    occlusion0 = (occlusion0 > 25) & (occlusion0 < 250);
Line 243... Line 202...
243
 
202
 
244
    // Threshold on energy at primary frequency
203
    // Threshold on energy at primary frequency
245
    occlusion0 = occlusion0 & (amplitude0 > 5.0*nStepsPrimary);
204
    occlusion0 = occlusion0 & (amplitude0 > 5.0*nStepsPrimary);
246
    occlusion1 = occlusion1 & (amplitude1 > 5.0*nStepsPrimary);
205
    occlusion1 = occlusion1 & (amplitude1 > 5.0*nStepsPrimary);
247
 
206
 
-
 
207
    // Threshold on energy ratios
-
 
208
    occlusion0 = occlusion0 & (amplitude0 > 0.85*energy0Primary);
-
 
209
    occlusion0 = occlusion0 & (amplitude0 > 0.85*energy0Secondary);
-
 
210
 
248
//cvtools::writeMat(occlusion1, "occlusion1.mat", "occlusion1");
211
    occlusion1 = occlusion1 & (amplitude1 > 0.85*energy1Primary);
249
//cvtools::writeMat(occlusion1, "occlusion1.mat", "occlusion1");
212
    occlusion1 = occlusion1 & (amplitude1 > 0.85*energy1Secondary);
250
 
213
 
251
    // Erode occlusion masks
214
//    // Erode occlusion masks
252
    cv::Mat strel = cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(5,5));
215
//    cv::Mat strel = cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(5,5));
253
    cv::erode(occlusion0, occlusion0, strel);
216
//    cv::erode(occlusion0, occlusion0, strel);
254
    cv::erode(occlusion1, occlusion1, strel);
217
//    cv::erode(occlusion1, occlusion1, strel);
255
 
218
 
256
    // Threshold on gradient of phase
219
//    // Threshold on gradient of phase
257
    cv::Mat edges0;
220
//    cv::Mat edges0;
258
    cv::Sobel(up0, edges0, -1, 1, 1, 5);
221
//    cv::Sobel(up0, edges0, -1, 1, 1, 5);
259
    occlusion0 = occlusion0 & (abs(edges0) < 150);
222
//    occlusion0 = occlusion0 & (abs(edges0) < 150);
260
 
223
 
261
    cv::Mat edges1;
224
//    cv::Mat edges1;
262
    cv::Sobel(up1, edges1, -1, 1, 1, 5);
225
//    cv::Sobel(up1, edges1, -1, 1, 1, 5);
263
    occlusion1 = occlusion1 & (abs(edges1) < 150);
226
//    occlusion1 = occlusion1 & (abs(edges1) < 150);
264
 
227
 
-
 
228
    #ifdef Q_DEBUG
265
//cvtools::writeMat(edges0, "edges0.mat", "edges0");
229
        cvtools::writeMat(occlusion1, "occlusion1.mat", "occlusion1");
266
//cvtools::writeMat(edges1, "edges1.mat", "edges1");
230
        cvtools::writeMat(occlusion1, "occlusion1.mat", "occlusion1");
-
 
231
    #endif
267
 
232
 
268
    // Match phase maps
233
    // Match phase maps
269
    int frameRectRows = map0X.rows;
-
 
270
    int frameRectCols = map0X.cols;
-
 
271
 
234
 
272
    // camera0 against camera1
235
    // camera0 against camera1
273
    std::vector<cv::Vec2f> q0, q1;
236
    std::vector<cv::Vec2f> q0, q1;
274
    for(int row=0; row<frameRectRows; row++){
237
    for(int row=0; row<frameRectRows; row++){
275
        for(int col=0; col<frameRectCols; col++){
238
        for(int col=0; col<frameRectCols; col++){