Line 127... |
Line 127... |
127 |
cv::phase(F0Tertiary[2], -F0Tertiary[3], up0Tertiary);
|
127 |
cv::phase(F0Tertiary[2], -F0Tertiary[3], up0Tertiary);
|
128 |
|
128 |
|
129 |
cv::Mat up0EquivalentPS = up0Primary - up0Secondary;
|
129 |
cv::Mat up0EquivalentPS = up0Primary - up0Secondary;
|
130 |
up0EquivalentPS = cvtools::modulo(up0EquivalentPS, 2.0*pi);
|
130 |
up0EquivalentPS = cvtools::modulo(up0EquivalentPS, 2.0*pi);
|
131 |
|
131 |
|
132 |
cv::Mat up0EquivalentST = up0Secondary - up0Tertiary;
|
132 |
cv::Mat up0EquivalentPT = up0Primary - up0Tertiary;
|
133 |
up0EquivalentST = cvtools::modulo(up0EquivalentST, 2.0*pi);
|
133 |
up0EquivalentPT = cvtools::modulo(up0EquivalentPT, 2.0*pi);
|
134 |
|
134 |
|
135 |
cv::Mat up0Equivalent = up0EquivalentPS - up0EquivalentST;
|
135 |
cv::Mat up0Equivalent = up0EquivalentPS - up0EquivalentPT;
|
136 |
up0Equivalent = cvtools::modulo(up0Equivalent, 2.0*pi);
|
136 |
up0Equivalent = cvtools::modulo(up0Equivalent, 2.0*pi);
|
137 |
|
137 |
|
138 |
cv::Mat up0 = unwrapWithCue(up0Primary, up0Equivalent, (float)screenCols/nPeriodsPrimary);
|
138 |
cv::Mat up0 = unwrapWithCue(up0Primary, up0Equivalent, (float)screenCols/nPeriodsPrimary);
|
139 |
up0 *= screenCols/(2.0*pi);
|
139 |
up0 *= screenCols/(2.0*pi);
|
140 |
cv::Mat amplitude0;
|
140 |
cv::Mat amplitude0;
|
Line 162... |
Line 162... |
162 |
up1EquivalentST = cvtools::modulo(up1EquivalentST, 2.0*pi);
|
162 |
up1EquivalentST = cvtools::modulo(up1EquivalentST, 2.0*pi);
|
163 |
|
163 |
|
164 |
cv::Mat up1Equivalent = up1EquivalentPS - up1EquivalentST;
|
164 |
cv::Mat up1Equivalent = up1EquivalentPS - up1EquivalentST;
|
165 |
up1Equivalent = cvtools::modulo(up1Equivalent, 2.0*pi);
|
165 |
up1Equivalent = cvtools::modulo(up1Equivalent, 2.0*pi);
|
166 |
|
166 |
|
- |
|
167 |
// TODO: we should use backward phase unwrapping (Song Zhang term)...
|
- |
|
168 |
|
167 |
cv::Mat up1 = unwrapWithCue(up1Primary, up1Equivalent, (float)screenCols/nPeriodsPrimary);
|
169 |
cv::Mat up1 = unwrapWithCue(up1Primary, up1Equivalent, (float)screenCols/nPeriodsPrimary);
|
168 |
up1 *= screenCols/(2.0*pi);
|
170 |
up1 *= screenCols/(2.0*pi);
|
169 |
cv::Mat amplitude1;
|
171 |
cv::Mat amplitude1;
|
170 |
cv::magnitude(F1Primary[2], -F1Primary[3], amplitude1);
|
172 |
cv::magnitude(F1Primary[2], -F1Primary[3], amplitude1);
|
171 |
|
173 |
|
172 |
#ifdef QT_DEBUG
|
174 |
#ifdef QT_DEBUG
|
173 |
cvtools::writeMat(up0Primary, "up0Primary.mat", "up0Primary");
|
175 |
cvtools::writeMat(up0Primary, "up0Primary.mat", "up0Primary");
|
174 |
cvtools::writeMat(up0Secondary, "up0Secondary.mat", "up0Secondary");
|
176 |
cvtools::writeMat(up0Secondary, "up0Secondary.mat", "up0Secondary");
|
175 |
cvtools::writeMat(up0Tertiary, "up0Tertiary.mat", "up0Tertiary");
|
177 |
cvtools::writeMat(up0Tertiary, "up0Tertiary.mat", "up0Tertiary");
|
176 |
cvtools::writeMat(up0EquivalentPS, "up0EquivalentPS.mat", "up0EquivalentPS");
|
178 |
cvtools::writeMat(up0EquivalentPS, "up0EquivalentPS.mat", "up0EquivalentPS");
|
177 |
cvtools::writeMat(up0EquivalentST, "up0EquivalentST.mat", "up0EquivalentST");
|
179 |
cvtools::writeMat(up0EquivalentPT, "up0EquivalentPT.mat", "up0EquivalentPT");
|
- |
|
180 |
cvtools::writeMat(up0Equivalent, "up0Equivalent.mat", "up0Equivalent");
|
178 |
cvtools::writeMat(up0, "up0.mat", "up0");
|
181 |
cvtools::writeMat(up0, "up0.mat", "up0");
|
179 |
cvtools::writeMat(up1, "up1.mat", "up1");
|
182 |
cvtools::writeMat(up1, "up1.mat", "up1");
|
180 |
cvtools::writeMat(amplitude0, "amplitude0.mat", "amplitude0");
|
183 |
cvtools::writeMat(amplitude0, "amplitude0.mat", "amplitude0");
|
181 |
|
184 |
|
182 |
cvtools::writeMat(amplitude0, "amplitude0.mat", "amplitude0");
|
185 |
cvtools::writeMat(amplitude0, "amplitude0.mat", "amplitude0");
|
183 |
cvtools::writeMat(amplitude1, "amplitude1.mat", "amplitude1");
|
186 |
cvtools::writeMat(amplitude1, "amplitude1.mat", "amplitude1");
|
184 |
#endif
|
187 |
#endif
|
185 |
|
188 |
|
186 |
// Color debayer and remap
|
189 |
// color debayer and remap
|
187 |
cv::Mat color0, color1;
|
190 |
cv::Mat color0, color1;
|
188 |
cv::cvtColor(frames0[0], color0, CV_BayerBG2RGB);
|
191 |
cv::cvtColor(frames0[0], color0, CV_BayerBG2RGB);
|
- |
|
192 |
cv::remap(color0, color0, map0X, map0Y, CV_INTER_LINEAR);
|
- |
|
193 |
|
189 |
cv::cvtColor(frames1[0], color1, CV_BayerBG2RGB);
|
194 |
cv::cvtColor(frames1[0], color1, CV_BayerBG2RGB);
|
- |
|
195 |
cv::remap(color1, color1, map1X, map1Y, CV_INTER_LINEAR);
|
190 |
|
196 |
|
191 |
#ifdef QT_DEBUG
|
197 |
#ifdef QT_DEBUG
|
192 |
cvtools::writeMat(color0, "color0.mat", "color0");
|
198 |
cvtools::writeMat(color0, "color0.mat", "color0");
|
193 |
cvtools::writeMat(color1, "color1.mat", "color1");
|
199 |
cvtools::writeMat(color1, "color1.mat", "color1");
|
194 |
#endif
|
200 |
#endif
|
Line 198... |
Line 204... |
198 |
cv::subtract(frames0Rect[0], frames0Rect[1], occlusion0);
|
204 |
cv::subtract(frames0Rect[0], frames0Rect[1], occlusion0);
|
199 |
occlusion0 = (occlusion0 > 5) & (occlusion0 < 250);
|
205 |
occlusion0 = (occlusion0 > 5) & (occlusion0 < 250);
|
200 |
cv::subtract(frames1Rect[0], frames1Rect[1], occlusion1);
|
206 |
cv::subtract(frames1Rect[0], frames1Rect[1], occlusion1);
|
201 |
occlusion1 = (occlusion1 > 5) & (occlusion1 < 250);
|
207 |
occlusion1 = (occlusion1 > 5) & (occlusion1 < 250);
|
202 |
|
208 |
|
203 |
#ifdef QT_DEBUG
|
- |
|
204 |
// Erode occlusion masks
|
- |
|
205 |
cv::Mat strel = cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(5,5));
|
- |
|
206 |
cv::erode(occlusion0, occlusion0, strel);
|
- |
|
207 |
cv::erode(occlusion1, occlusion1, strel);
|
- |
|
208 |
#endif
|
- |
|
209 |
|
- |
|
210 |
// Threshold on gradient of phase
|
209 |
// Threshold on gradient of phase
|
211 |
cv::Mat edges0;
|
210 |
cv::Mat edges0;
|
212 |
cv::Sobel(up0, edges0, -1, 1, 1, 5);
|
211 |
cv::Sobel(up0, edges0, -1, 1, 1, 5);
|
213 |
occlusion0 = occlusion0 & (abs(edges0) < 150);
|
212 |
occlusion0 = occlusion0 & (abs(edges0) < 150);
|
214 |
cv::Mat edges1;
|
213 |
cv::Mat edges1;
|
Line 218... |
Line 217... |
218 |
#ifdef QT_DEBUG
|
217 |
#ifdef QT_DEBUG
|
219 |
cvtools::writeMat(edges0, "edges0.mat", "edges0");
|
218 |
cvtools::writeMat(edges0, "edges0.mat", "edges0");
|
220 |
cvtools::writeMat(edges1, "edges1.mat", "edges1");
|
219 |
cvtools::writeMat(edges1, "edges1.mat", "edges1");
|
221 |
#endif
|
220 |
#endif
|
222 |
|
221 |
|
- |
|
222 |
#ifdef QT_DEBUG
|
- |
|
223 |
cvtools::writeMat(occlusion0, "occlusion0.mat", "occlusion0");
|
- |
|
224 |
cvtools::writeMat(occlusion1, "occlusion1.mat", "occlusion1");
|
- |
|
225 |
#endif
|
- |
|
226 |
|
223 |
// Match phase maps
|
227 |
// Match phase maps
|
224 |
int frameRectRows = map0X.rows;
|
228 |
int frameRectRows = map0X.rows;
|
225 |
int frameRectCols = map0X.cols;
|
229 |
int frameRectCols = map0X.cols;
|
226 |
|
230 |
|
227 |
// camera0 against camera1
|
231 |
// camera0 against camera1
|