Subversion Repositories seema-scanner

Rev

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

Rev 39 Rev 41
Line 1... Line 1...
1
#include "CodecPhaseShift.h"
1
#include "AlgorithmPhaseShift.h"
2
#include <math.h>
2
#include <math.h>
3
 
3
 
4
#include "cvtools.h"
4
#include "cvtools.h"
5
 
5
 
6
#ifndef M_PI
6
#ifndef M_PI
7
    #define M_PI 3.14159265358979323846
7
    #define M_PI 3.14159265358979323846
8
#endif
8
#endif
9
 
9
 
10
static unsigned int nPhases = 8;
10
static unsigned int nPhases = 8;
11
 
11
 
12
// Encoder
12
// Algorithm
13
static cv::Mat computePhaseVector(unsigned int length, float phase, float pitch){
13
static cv::Mat computePhaseVector(unsigned int length, float phase, float pitch){
14
 
14
 
15
    cv::Mat phaseVector(length, 1, CV_8UC3);
15
    cv::Mat phaseVector(length, 1, CV_8UC3);
16
    //phaseVector.setTo(0);
16
    //phaseVector.setTo(0);
17
 
17
 
Line 25... Line 25...
25
    }
25
    }
26
 
26
 
27
    return phaseVector;
27
    return phaseVector;
28
}
28
}
29
 
29
 
30
EncoderPhaseShift::EncoderPhaseShift(unsigned int _screenCols, unsigned int _screenRows, CodecDir _dir) : Encoder(_screenCols, _screenRows, _dir){
30
AlgorithmPhaseShift::AlgorithmPhaseShift(unsigned int _screenCols, unsigned int _screenRows, CodingDir _dir) : Algorithm(_screenCols, _screenRows, _dir){
31
 
31
 
32
    // Set N
32
    // Set N
33
    if(dir == CodecDirBoth)
33
    if(dir == CodingDirBoth)
34
        this->N = 12;
34
        this->N = 12;
35
    else
35
    else
36
        this->N = 6;
36
        this->N = 6;
37
 
37
 
38
    // Precompute encoded patterns
38
    // Precompute encoded patterns
39
    const float pi = M_PI;
39
    const float pi = M_PI;
40
 
40
 
41
    if(dir & CodecDirHorizontal){
41
    if(dir & CodingDirHorizontal){
42
        // Horizontally encoding patterns
42
        // Horizontally encoding patterns
43
        for(unsigned int i=0; i<3; i++){
43
        for(unsigned int i=0; i<3; i++){
44
            float phase = 2.0*pi/3.0 * (1.0 - (float)i);
44
            float phase = 2.0*pi/3.0 * (1.0 - (float)i);
45
            float pitch = (float)screenCols/(float)nPhases;
45
            float pitch = (float)screenCols/(float)nPhases;
46
            cv::Mat patternI(1,1,CV_8U);
46
            cv::Mat patternI(1,1,CV_8U);
Line 57... Line 57...
57
            patternI = computePhaseVector(screenCols, phase, pitch);
57
            patternI = computePhaseVector(screenCols, phase, pitch);
58
            patternI = patternI.t();
58
            patternI = patternI.t();
59
            patterns.push_back(patternI);
59
            patterns.push_back(patternI);
60
        }
60
        }
61
    }
61
    }
62
    if(dir & CodecDirVertical){
62
    if(dir & CodingDirVertical){
63
        // Precompute vertically encoding patterns
63
        // Precompute vertically encoding patterns
64
        for(unsigned int i=0; i<3; i++){
64
        for(unsigned int i=0; i<3; i++){
65
            float phase = 2.0*pi/3.0 * (1.0 - (float)i);
65
            float phase = 2.0*pi/3.0 * (1.0 - (float)i);
66
            float pitch = (float)screenRows/(float)nPhases;
66
            float pitch = (float)screenRows/(float)nPhases;
67
            cv::Mat patternI;
67
            cv::Mat patternI;
Line 78... Line 78...
78
            patterns.push_back(patternI);
78
            patterns.push_back(patternI);
79
        }
79
        }
80
    }
80
    }
81
}
81
}
82
 
82
 
83
cv::Mat EncoderPhaseShift::getEncodingPattern(unsigned int depth){
83
cv::Mat AlgorithmPhaseShift::getEncodingPattern(unsigned int depth){
84
    return patterns[depth];
84
    return patterns[depth];
85
}
85
}
86
 
86
 
87
// Decoder
-
 
88
DecoderPhaseShift::DecoderPhaseShift(CodecDir _dir, int _screenCols, int _screenRows) : Decoder(_dir, _screenRows, _screenCols){
-
 
89
 
-
 
90
}
-
 
91
 
87
 
92
static cv::Mat absolutePhase(cv::Mat _I1, cv::Mat _I2, cv::Mat _I3){
88
static cv::Mat absolutePhase(cv::Mat _I1, cv::Mat _I2, cv::Mat _I3){
93
 
89
 
94
    const float pi = M_PI;
90
    const float pi = M_PI;
95
 
91
 
Line 109... Line 105...
109
 
105
 
110
    //absPhase.addref();
106
    //absPhase.addref();
111
    return absPhase;
107
    return absPhase;
112
}
108
}
113
 
109
 
114
void DecoderPhaseShift::getCorrespondences(const std::vector<cv::Mat>& frames0, const std::vector<cv::Mat>& frames1, std::vector<cv::Point2f>& q0, std::vector<cv::Point2f>& q1, std::vector<cv::Point3f>& color){
110
void AlgorithmPhaseShift::getCorrespondences(SMCalibrationParameters calibration, const std::vector<cv::Mat>& frames0, const std::vector<cv::Mat>& frames1, std::vector<cv::Point2f>& q0, std::vector<cv::Point2f>& q1, std::vector<cv::Point3f>& color){
115
 
111
 
116
}
112
}