Subversion Repositories seema-scanner

Rev

Rev 125 | Rev 127 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 125 Rev 126
Line 172... Line 172...
172
//    cvtools::writeMat(codeScanLine, "codeScanLine.mat", "codeScanLine");
172
//    cvtools::writeMat(codeScanLine, "codeScanLine.mat", "codeScanLine");
173
//    cvtools::writeMat(linesScanLine, "linesScanLine.mat", "linesScanLine");
173
//    cvtools::writeMat(linesScanLine, "linesScanLine.mat", "linesScanLine");
174
//    cvtools::writeMat(der, "der.mat", "der");
174
//    cvtools::writeMat(der, "der.mat", "der");
175
 
175
 
176
    for(int i=0; i<nCols; i++){
176
    for(int i=0; i<nCols; i++){
-
 
177
        int code = codeScanLine.at<int>(0, i);
177
 
178
 
178
        if(der.at<float>(0, i) < 0.0 && der.at<unsigned char>(0, i+1) > 0.0){
179
        if((code != -1) && (der.at<float>(0, i) < 0.0) && (der.at<float>(0, i+1) > 0.0) && ((der.at<float>(0, i+1) - der.at<float>(0, i)) > 20.0)){
179
 
180
 
180
            lineCenters.push_back(cv::Vec2f(i, codeScanLine.at<unsigned char>(0, i)));
181
            lineCenters.push_back(cv::Vec2f(i, code));
181
            // TODO: subpixel interpolation, non-max suppression
182
            // TODO: subpixel interpolation, non-max suppression
182
        }
183
        }
183
 
184
 
184
    }
185
    }
185
 
186
 
Line 307... Line 308...
307
            if(occlusion1Rect.at<unsigned char>(r,c) == 0)
308
            if(occlusion1Rect.at<unsigned char>(r,c) == 0)
308
                code1Binary.at<int>(r,c) = -1;
309
                code1Binary.at<int>(r,c) = -1;
309
        }
310
        }
310
    }
311
    }
311
 
312
 
312
cvtools::writeMat(code0Gray, "code0Gray.mat", "code0Gray");
313
//cvtools::writeMat(code0Gray, "code0Gray.mat", "code0Gray");
313
cvtools::writeMat(code1Gray, "code1Gray.mat", "code1Gray");
314
//cvtools::writeMat(code1Gray, "code1Gray.mat", "code1Gray");
314
cvtools::writeMat(code0Binary, "code0Binary.mat", "code0Binary");
315
//cvtools::writeMat(code0Binary, "code0Binary.mat", "code0Binary");
315
cvtools::writeMat(code1Binary, "code1Binary.mat", "code1Binary");
316
//cvtools::writeMat(code1Binary, "code1Binary.mat", "code1Binary");
316
 
-
 
317
    // TODO: iterate through all line frames
-
 
318
    cv::Mat lines0 = frames0LineShift[0];
-
 
319
    cv::Mat lines1 = frames1LineShift[0];
-
 
320
 
317
 
321
    // matching
318
    // matching
322
    std::vector<cv::Vec2f> q0Rect, q1Rect;
319
    std::vector<cv::Vec2f> q0Rect, q1Rect;
-
 
320
    for(int s=0; s<nLineShifts; s++){
-
 
321
 
-
 
322
        cv::Mat lines0 = frames0LineShift[s];
-
 
323
        cv::Mat lines1 = frames1LineShift[s];
-
 
324
 
323
    for(int row=0; row<frameRectRows; row++){
325
        for(int row=0; row<frameRectRows; row++){
324
 
326
 
325
        // line center data structure containing [x-coordinate (sub-px), region-code]
327
            // line center data structure containing [x-coordinate (sub-px), region-code]
326
        std::vector<cv::Vec2f> lineCenters0, lineCenters1;
328
            std::vector<cv::Vec2f> lineCenters0, lineCenters1;
327
 
329
 
328
        // sorted, unique line centers
330
            // sorted, unique line centers
329
        getlineCenters(lines0.row(row), code0Binary.row(row), lineCenters0);
331
            getlineCenters(lines0.row(row), code0Binary.row(row), lineCenters0);
330
        getlineCenters(lines1.row(row), code1Binary.row(row), lineCenters1);
332
            getlineCenters(lines1.row(row), code1Binary.row(row), lineCenters1);
331
 
333
 
-
 
334
//         if(s==0 && row==1300){
-
 
335
//            std::cout << cv::Mat(lineCenters0) << std::endl;
-
 
336
//            std::cout << cv::Mat(lineCenters1) << std::endl;
-
 
337
 
-
 
338
//            cvtools::writeMat(lines0.row(row), "lines0.mat", "lines0");
-
 
339
//            cvtools::writeMat(lines1.row(row), "lines1.mat", "lines1");
-
 
340
//            cvtools::writeMat(code0Binary.row(row), "code0Binary.mat", "code0Binary");
-
 
341
//            cvtools::writeMat(code1Binary.row(row), "code1Binary.mat", "code1Binary");
-
 
342
//         }
-
 
343
 
332
        // match and store
344
            // match and store
333
        int i=0, j=0;
345
            int i=0, j=0;
334
        while(i<lineCenters0.size() && j<lineCenters1.size()){
346
            while(i<lineCenters0.size() && j<lineCenters1.size()){
335
 
347
 
336
            if(lineCenters0[i][1] == lineCenters1[j][1]){
348
                if(lineCenters0[i][1] == lineCenters1[j][1]){
337
                q0Rect.push_back(cv::Point2f(lineCenters0[0][0], row));
349
                    q0Rect.push_back(cv::Point2f(lineCenters0[i][0], row));
338
                q1Rect.push_back(cv::Point2f(lineCenters1[0][0], row));
350
                    q1Rect.push_back(cv::Point2f(lineCenters1[j][0], row));
339
                i += 1;
351
                    i += 1;
340
                j += 1;
352
                    j += 1;
341
            } else if(lineCenters0[i][1] < lineCenters1[j][1]){
353
                } else if(lineCenters0[i][1] < lineCenters1[j][1]){
342
                i += 1;
354
                    i += 1;
343
            } else if(lineCenters0[i][1] > lineCenters1[j][1]){
355
                } else if(lineCenters0[i][1] > lineCenters1[j][1]){
344
                j += 1;
356
                    j += 1;
345
            }
357
                }
346
        }
358
            }
347
 
359
 
348
    }
360
        }
-
 
361
    }
349
 
362
 
350
    int nMatches = q0Rect.size();
363
    int nMatches = q0Rect.size();
351
 
364
 
352
    if(nMatches < 1){
365
    if(nMatches < 1){
353
        Q.resize(0);
366
        Q.resize(0);