Subversion Repositories seema-scanner

Rev

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

Rev 70 Rev 78
Line 206... Line 206...
206
        cv::remap(temp, frames0Rect[i], map0X, map0Y, CV_INTER_CUBIC);
206
        cv::remap(temp, frames0Rect[i], map0X, map0Y, CV_INTER_CUBIC);
207
        cv::cvtColor(frames1[i], temp, CV_RGB2GRAY);
207
        cv::cvtColor(frames1[i], temp, CV_RGB2GRAY);
208
        cv::remap(temp, frames1Rect[i], map1X, map1Y, CV_INTER_CUBIC);
208
        cv::remap(temp, frames1Rect[i], map1X, map1Y, CV_INTER_CUBIC);
209
    }
209
    }
210
 
210
 
-
 
211
//    cvtools::writeMat(frames0Rect[0], "frames0Rect_0.mat", "frames0Rect_0");
-
 
212
//    cvtools::writeMat(frames0Rect[1], "frames0Rect_1.mat", "frames0Rect_1");
-
 
213
 
-
 
214
//    cvtools::writeMat(frames0Rect[22], "frames0Rect_22.mat", "frames0Rect_22");
-
 
215
//    cvtools::writeMat(frames0Rect[23], "frames0Rect_23.mat", "frames0Rect_23");
211
 
216
 
212
//    cv::imwrite("frames0[0].png", frames0[0]);
217
//    cv::imwrite("frames0[0].png", frames0[0]);
213
//    cv::imwrite("frames0Rect[0].png", frames0Rect[0]);
218
//    cv::imwrite("frames0Rect[0].png", frames0Rect[0]);
214
 
219
 
215
//    cv::imwrite("frames1[0].png", frames1[0]);
220
//    cv::imwrite("frames1[0].png", frames1[0]);
Line 238... Line 243...
238
 
243
 
239
//cvtools::writeMat(occlusion0Rect, "occlusion0Rect.mat", "occlusion0Rect");
244
//cvtools::writeMat(occlusion0Rect, "occlusion0Rect.mat", "occlusion0Rect");
240
//cvtools::writeMat(occlusion1Rect, "occlusion1Rect.mat", "occlusion1Rect");
245
//cvtools::writeMat(occlusion1Rect, "occlusion1Rect.mat", "occlusion1Rect");
241
 
246
 
242
    // decode patterns
247
    // decode patterns
243
    cv::Mat code0Rect(frameRectRows, frameRectCols, CV_32S, cv::Scalar(-1));
248
    cv::Mat code0Rect(frameRectRows, frameRectCols, CV_32S, cv::Scalar(0));
244
    cv::Mat code1Rect(frameRectRows, frameRectCols, CV_32S, cv::Scalar(-1));
249
    cv::Mat code1Rect(frameRectRows, frameRectCols, CV_32S, cv::Scalar(0));
245
    cv::add(code0Rect, 1, code0Rect, occlusion0Rect, CV_32S);
-
 
246
    cv::add(code1Rect, 1, code1Rect, occlusion1Rect, CV_32S);
-
 
247
 
250
 
248
    // into gray code
251
    // into gray code
249
    for(int i=0; i<Nbits; i++){
252
    for(int i=0; i<Nbits; i++){
250
        cv::Mat bit0;
253
        cv::Mat bit0;
251
        cv::subtract(frames0Rect[i*2+2], frames0Rect[i*2+3], bit0);
254
        cv::subtract(frames0Rect[i*2+2], frames0Rect[i*2+3], bit0);
252
        bit0 = bit0 > 0;
255
        bit0 = bit0 > 0;
253
        bit0.convertTo(bit0, CV_32S, 1.0/255.0);
256
        bit0.convertTo(bit0, CV_32S, 1.0/255.0);
254
//      cvtools::writeMat(bit0, "bit0.mat", "bit0");
257
//      cvtools::writeMat(bit0, "bit0.mat", "bit0");
255
        cv::add(code0Rect, bit0*twopowi(Nbits-i-1), code0Rect, occlusion0Rect, CV_32S);
258
        cv::add(code0Rect, bit0*twopowi(Nbits-i-1), code0Rect, cv::Mat(), CV_32S);
256
        cv::Mat bit1;
259
        cv::Mat bit1;
257
        cv::subtract(frames1Rect[i*2+2], frames1Rect[i*2+3], bit1);
260
        cv::subtract(frames1Rect[i*2+2], frames1Rect[i*2+3], bit1);
258
        bit1 = bit1 > 0;
261
        bit1 = bit1 > 0;
259
        bit1.convertTo(bit1, CV_32S, 1.0/255.0);
262
        bit1.convertTo(bit1, CV_32S, 1.0/255.0);
260
        cv::add(code1Rect, bit1*twopowi(Nbits-i-1), code1Rect, occlusion1Rect, CV_32S);
263
        cv::add(code1Rect, bit1*twopowi(Nbits-i-1), code1Rect, cv::Mat(), CV_32S);
261
    }
264
    }
262
 
265
 
263
//cvtools::writeMat(code0Rect, "code0Rect.mat", "code0Rect");
266
//cvtools::writeMat(code0Rect, "code0Rect.mat", "code0Rect");
264
//cvtools::writeMat(code1Rect, "code1Rect.mat", "code1Rect");
267
//cvtools::writeMat(code1Rect, "code1Rect.mat", "code1Rect");
265
 
268
 
-
 
269
 
266
//    // convert to standard binary
270
//    // convert to standard binary
-
 
271
//    cv::Mat code0Binary(code0Rect.rows, code0Rect.cols, CV_32F);
-
 
272
//    cv::Mat code1Binary(code1Rect.rows, code1Rect.cols, CV_32F);
267
//    for(int r=0; r<frameRectRows; r++){
273
//    for(int r=0; r<frameRectRows; r++){
268
//        for(int c=0; c<frameRectCols; c++){
274
//        for(int c=0; c<frameRectCols; c++){
269
//            if(code0Rect.at<int>(r,c) != -1)
275
//            if(code0Rect.at<int>(r,c) != -1)
270
//                code0Rect.at<int>(r,c) = grayToBinary(code0Rect.at<int>(r,c));
276
//                code0Binary.at<float>(r,c) = grayToBinary(code0Rect.at<int>(r,c));
271
//            if(code1Rect.at<int>(r,c) != -1)
277
//            if(code1Rect.at<int>(r,c) != -1)
272
//                code1Rect.at<int>(r,c) = grayToBinary(code1Rect.at<int>(r,c));
278
//                code1Binary.at<float>(r,c) = grayToBinary(code1Rect.at<int>(r,c));
273
//        }
279
//        }
274
//    }
280
//    }
275
 
281
 
276
//cvtools::writeMat(code0Rect, "code0Rect.mat", "code0Rect");
282
//cvtools::writeMat(code0Binary, "code0Binary.mat", "code0Binary");
277
//cvtools::writeMat(code1Rect, "code1Rect.mat", "code1Rect");
283
//cvtools::writeMat(code1Binary, "code1Binary.mat", "code1Binary");
-
 
284
 
-
 
285
//    // threshold on vertical discontinuities (due to imperfect rectification)
-
 
286
//    cv::Mat edges0;
-
 
287
//    cv::Sobel(code0Binary, edges0, -1, 0, 1, 5);
-
 
288
//    occlusion0Rect = occlusion0Rect & (abs(edges0) < 50);
-
 
289
 
-
 
290
//    cv::Mat edges1;
-
 
291
//    cv::Sobel(code1Binary, edges1, -1, 0, 1, 5);
-
 
292
//    occlusion1Rect = occlusion1Rect & (abs(edges1) < 50);
-
 
293
 
-
 
294
//cvtools::writeMat(edges0, "edges0.mat", "edges0");
-
 
295
//cvtools::writeMat(edges1, "edges1.mat", "edges1");
-
 
296
 
-
 
297
    // set occluded pixels to -1
-
 
298
    for(int r=0; r<frameRectRows; r++){
-
 
299
        for(int c=0; c<frameRectCols; c++){
-
 
300
            if(occlusion0Rect.at<char>(r,c) == 0)
-
 
301
                code0Rect.at<float>(r,c) = -1;
-
 
302
            if(occlusion1Rect.at<char>(r,c) == 0)
-
 
303
                code1Rect.at<float>(r,c) = -1;
-
 
304
        }
-
 
305
    }
278
 
306
 
279
    // matching
307
    // matching
280
    std::vector<cv::Vec2f> q0Rect, q1Rect;
308
    std::vector<cv::Vec2f> q0Rect, q1Rect;
281
    for(int row=0; row<frameRectRows; row++){
309
    for(int row=0; row<frameRectRows; row++){
282
 
310