Subversion Repositories seema-scanner

Rev

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

Rev 182 Rev 195
Line 11... Line 11...
11
#include "algorithmtools.h"
11
#include "algorithmtools.h"
12
 
12
 
13
// Algorithm
13
// Algorithm
14
AlgorithmGrayCodeHorzVert::AlgorithmGrayCodeHorzVert(unsigned int _screenCols, unsigned int _screenRows) : Algorithm(_screenCols, _screenRows){
14
AlgorithmGrayCodeHorzVert::AlgorithmGrayCodeHorzVert(unsigned int _screenCols, unsigned int _screenRows) : Algorithm(_screenCols, _screenRows){
15
 
15
 
16
    NbitsHorz = ceilf(log2f((float)screenCols));
16
    NbitsHorz = ceilf(log2f((float)screenCols)) - 1;
17
    NbitsVert =  ceilf(log2f((float)screenRows));
17
    NbitsVert =  ceilf(log2f((float)screenRows)) - 1;
18
    N = 2 + (NbitsHorz+NbitsVert)*2;
18
    N = 2 + (NbitsHorz+NbitsVert)*2;
19
 
19
 
20
    // all on pattern
20
    // all on pattern
21
    cv::Mat allOn(1, screenCols, CV_8UC3, cv::Scalar::all(255));
21
    cv::Mat allOn(1, screenCols, CV_8UC3, cv::Scalar::all(255));
22
    patterns.push_back(allOn);
22
    patterns.push_back(allOn);
Line 33... Line 33...
33
 
33
 
34
        for(unsigned int j=0; j<screenCols; j++){
34
        for(unsigned int j=0; j<screenCols; j++){
35
 
35
 
36
            unsigned int jGray = binaryToGray(j);
36
            unsigned int jGray = binaryToGray(j);
37
            // Amplitude of channels
37
            // Amplitude of channels
38
            int bit = (int)getBit(jGray, NbitsHorz-p);
38
            int bit = (int)getBit(jGray, NbitsHorz-p+1);
39
            pattern.at<cv::Vec3b>(0,j) = cv::Vec3b(255.0*bit,255.0*bit,255.0*bit);
39
            pattern.at<cv::Vec3b>(0,j) = cv::Vec3b(255.0*bit,255.0*bit,255.0*bit);
40
            int invBit = bit^1;
40
            int invBit = bit^1;
41
            patternInv.at<cv::Vec3b>(0,j) = cv::Vec3b(255.0*invBit,255.0*invBit,255.0*invBit);
41
            patternInv.at<cv::Vec3b>(0,j) = cv::Vec3b(255.0*invBit,255.0*invBit,255.0*invBit);
42
        }
42
        }
43
        patterns.push_back(pattern);
43
        patterns.push_back(pattern);
Line 51... Line 51...
51
 
51
 
52
        for(unsigned int j=0; j<screenRows; j++){
52
        for(unsigned int j=0; j<screenRows; j++){
53
 
53
 
54
            unsigned int jGray = binaryToGray(j);
54
            unsigned int jGray = binaryToGray(j);
55
            // Amplitude of channels
55
            // Amplitude of channels
56
            int bit = (int)getBit(jGray, NbitsVert-p);
56
            int bit = (int)getBit(jGray, NbitsVert-p+1);
57
            pattern.at<cv::Vec3b>(j,0) = cv::Vec3b(255.0*bit,255.0*bit,255.0*bit);
57
            pattern.at<cv::Vec3b>(j,0) = cv::Vec3b(255.0*bit,255.0*bit,255.0*bit);
58
            int invBit = bit^1;
58
            int invBit = bit^1;
59
            patternInv.at<cv::Vec3b>(j,0) = cv::Vec3b(255.0*invBit,255.0*invBit,255.0*invBit);
59
            patternInv.at<cv::Vec3b>(j,0) = cv::Vec3b(255.0*invBit,255.0*invBit,255.0*invBit);
60
        }
60
        }
61
        patterns.push_back(pattern);
61
        patterns.push_back(pattern);
Line 208... Line 208...
208
    cv::subtract(frames0[0], frames0[1], occlusion0);
208
    cv::subtract(frames0[0], frames0[1], occlusion0);
209
    occlusion0 = (occlusion0 > 20) & (occlusion0 < 250);
209
    occlusion0 = (occlusion0 > 20) & (occlusion0 < 250);
210
    cv::subtract(frames1[0], frames1[1], occlusion1);
210
    cv::subtract(frames1[0], frames1[1], occlusion1);
211
    occlusion1 = (occlusion1 > 20) & (occlusion1 < 250);
211
    occlusion1 = (occlusion1 > 20) & (occlusion1 < 250);
212
 
212
 
213
    // erode occlusion masks
213
//    // erode occlusion masks
214
    cv::Mat strel = cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(3,3));
214
//    cv::Mat strel = cv::getStructuringElement(cv::MORPH_ELLIPSE, cv::Size(3,3));
215
    cv::erode(occlusion0, occlusion0, strel);
215
//    cv::erode(occlusion0, occlusion0, strel);
216
    cv::erode(occlusion1, occlusion1, strel);
216
//    cv::erode(occlusion1, occlusion1, strel);
217
 
217
 
218
//cvtools::writeMat(occlusion0, "occlusion0.mat", "occlusion0");
218
//cvtools::writeMat(occlusion0, "occlusion0.mat", "occlusion0");
219
//cvtools::writeMat(occlusion1, "occlusion1.mat", "occlusion1");
219
//cvtools::writeMat(occlusion1, "occlusion1.mat", "occlusion1");
220
 
220
 
221
    // decode patterns
221
    // decode patterns