Skip to content

Commit 66a5ed2

Browse files
author
Tsing
committed
Separated graycode generation and displaying.
1 parent 19a18f7 commit 66a5ed2

File tree

3 files changed

+14
-11
lines changed

3 files changed

+14
-11
lines changed

src/app/generateGraycode.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,16 @@ int main()
44
{
55
// Generate gray code based on the resolution of the projector.
66
SLS::GrayCode gc(1024, 768);
7-
// Show the image sequence.
8-
// This function can be called when projecting patterns to the
9-
// reconstruction object.
10-
gc.generateGrayCode();
7+
std::vector<cv::Mat> grayCodeImages = gc.generateGrayCode();
8+
9+
// Display graycode
10+
std::cout<<"Press 'q' to exit\n";
11+
std::cout<<"Press any key to show next image\n";
12+
for (const auto & image: grayCodeImages)
13+
{
14+
cv::imshow("GrayCode", image);
15+
if (cv::waitKey(0) == 'q')
16+
break;
17+
}
1118
return 0;
1219
}

src/lib/GrayCode/GrayCode.cpp

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GrayCode::GrayCode(size_t projW, size_t projH):
88
numRowBits = (size_t)std::ceil(std::log2((float) height_));
99
grayCodes_.resize(numColBits*2+numRowBits*2+2);
1010
}
11-
void GrayCode::generateGrayCode()
11+
const std::vector<cv::Mat>& GrayCode::generateGrayCode()
1212
{
1313
// Init rest of the mat
1414
for (auto &mat: grayCodes_)
@@ -76,10 +76,6 @@ void GrayCode::generateGrayCode()
7676
prevRem=rem;
7777
}
7878
}
79-
for (size_t i=0; i<grayCodes_.size(); i++)
80-
{
81-
cv::imshow("test",grayCodes_[i]);
82-
cv::waitKey(0);
83-
}
79+
return grayCodes_;
8480
}
8581
} // namespace SLS

src/lib/GrayCode/GrayCode.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class GrayCode
2222
* The binary are encoded separately for columns and rows. i.e. for a projector pixel (x, y)
2323
* we have (BitSeqX, BitSeqY).
2424
*/
25-
void generateGrayCode();
25+
const std::vector<cv::Mat>& generateGrayCode();
2626
private:
2727
//! Projector width and height
2828
size_t width_, height_;

0 commit comments

Comments
 (0)