@@ -39,25 +39,21 @@ void ReconstructorCPU::generateBuckets()
39
39
xTimesY = x * y;
40
40
41
41
// For each camera pixel
42
- // assert(dynamic_cast<FileReader*>(cam)->getNumFrames() == projector_->getRequiredNumFrames()*2+2);
43
-
44
42
for (size_t i = 0 ; i < xTimesY; i++) {
45
43
if (!cam->queryMask (i)) // No need to process if in shadow
46
44
continue ;
47
45
48
46
cam->getNextFrame ();
49
- cam->getNextFrame ();// skip first two frames
47
+ cam->getNextFrame (); // skip first two frames
50
48
51
49
Dynamic_Bitset bits (projector_->getRequiredNumFrames ());
52
50
53
51
bool discard = false ;
52
+
54
53
// for each frame
55
54
for (int bitIdx = projector_->getRequiredNumFrames () - 1 ; bitIdx >= 0 ; bitIdx--) {
56
- // for (int bitIdx = 0; bitIdx <projector_->getRequiredNumFrames(); bitIdx++) {
57
55
58
- // std::cout<<((FileReader*)cam)->getCurrentIdx()<<std::endl;
59
56
auto frame = cam->getNextFrame ();
60
- // std::cout<<((FileReader*)cam)->getCurrentIdx()<<std::endl;
61
57
auto invFrame = cam->getNextFrame ();
62
58
unsigned char pixel = frame.at <uchar>(i % y, i / y);
63
59
unsigned char invPixel = invFrame.at <uchar>(i % y, i / y);
@@ -68,11 +64,6 @@ void ReconstructorCPU::generateBuckets()
68
64
// No need to do anything since the array is initialized as all zeros
69
65
bits.clearBit ((size_t ) bitIdx);
70
66
continue ;
71
- // std::cout<<"-----\n"<<bits<<std::endl;
72
- // bits.clearBit(bitIdx);
73
- // std::cout<<std::setw(bits.size()-bitIdx)<<"c"<<std::endl;
74
- // std::cout<<bits<<std::endl;
75
-
76
67
}
77
68
else if (pixel > invPixel && pixel - invPixel >
78
69
((FileReader*)cam)->getWhiteThreshold (i)) {
@@ -85,22 +76,23 @@ void ReconstructorCPU::generateBuckets()
85
76
continue ;
86
77
}
87
78
} // end for each frame
88
- if (!discard) {
89
79
80
+ // if the pixel is valid, add to bucket.
81
+ if (!discard)
82
+ {
90
83
auto vec2Idx = bits.to_uint_gray ();
91
84
if ( projector_->getWidth () > vec2Idx.x &&
92
85
vec2Idx.y < projector_->getHeight ()) {
93
86
buckets_[camIdx][vec2Idx.x * projector_->getHeight () + vec2Idx.y ].push_back (i);
94
87
}
95
88
}
96
89
}
97
-
98
90
// Keep track of maximum number of pixels in a grid
99
- unsigned maxCount = 0 ;
100
- for (const auto &bucket: buckets_[camIdx]){
101
- if (bucket.size () > maxCount)
102
- maxCount = bucket.size ();
103
- }
91
+ // unsigned maxCount = 0;
92
+ // for (const auto &bucket: buckets_[camIdx]){
93
+ // if (bucket.size() > maxCount)
94
+ // maxCount = bucket.size();
95
+ // }
104
96
}
105
97
106
98
}
@@ -112,10 +104,8 @@ PointCloud ReconstructorCPU::reconstruct()
112
104
size_t x,y;
113
105
cameras_[0 ]->getResolution (x,y);
114
106
initBuckets ();
115
-
116
107
LOG::startTimer ();
117
-
118
- for ( size_t i=0 ; i<buckets_[0 ].size (); i++) // 1024*768
108
+ for ( size_t i=0 ; i<buckets_[0 ].size (); i++)
119
109
{
120
110
const auto &cam0bucket = buckets_[0 ][i];
121
111
const auto &cam1bucket = buckets_[1 ][i];
@@ -150,7 +140,6 @@ PointCloud ReconstructorCPU::reconstruct()
150
140
}
151
141
midPointAvg = midPointAvg/ptCount;
152
142
{
153
- // pointCloud_.push_back(1);
154
143
auto color0 = cameras_[0 ]->getColor (minCam0Idx);
155
144
auto color1 = cameras_[1 ]->getColor (minCam1Idx);
156
145
res.pushPoint ( glm::vec3 (midPointAvg), (color0 + color1) / 2 .0f );
0 commit comments