Skip to content

Commit e6ce4ff

Browse files
author
tsing
committedMar 20, 2017
Docs in app
1 parent 42427ed commit e6ce4ff

File tree

5 files changed

+62
-25
lines changed

5 files changed

+62
-25
lines changed
 

‎src/app/App.cpp

+20-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
int main(int argc, char** argv)
1010
{
1111

12+
// Parsing parameters
1213
cmdline::parser p;
1314
p.add<std::string>("leftcam", 'l',"Left camera image folder", true);
1415
p.add<std::string>("rightcam", 'r',"Right camera image folder", true);
@@ -20,33 +21,49 @@ int main(int argc, char** argv)
2021
p.add<size_t>("height", 'h',"Projector height", true);
2122
p.parse_check(argc, argv);
2223

24+
// Start logging, this function will clear log file and start a new logging.
2325
LOG::restartLog();
26+
27+
// Setup left camera image folder
2428
std::string leftCameraFolder = p.get<std::string>("leftcam");
25-
std::string rightCameraFolder = p.get<std::string>("rightcam");
29+
// Setup left camera calibration parameters
2630
std::string leftConfigFile = p.get<std::string>("leftconfig");
31+
32+
// Setup right camera
33+
std::string rightCameraFolder = p.get<std::string>("rightcam");
2734
std::string rightConfigFile = p.get<std::string>("rightconfig");
35+
2836
std::string output = p.get<std::string>("output");
2937
std::string suffix = p.get<std::string>("format");
3038

31-
39+
// Initialize two file readers to load images from file
3240
SLS::FileReader rightCam("rightCam");
3341
SLS::FileReader leftCam("rightCam");
3442

43+
// Load images
44+
// void loadImages( const std::string &folder, std::string prefix, size_t numDigits, size_t startIdx, std::string suffix )
3545
rightCam.loadImages(rightCameraFolder, "", 4, 0,suffix);
3646
leftCam.loadImages(leftCameraFolder, "", 4, 0, suffix);
3747

48+
// Load configurations, mainly calibration parameters
3849
rightCam.loadConfig(rightConfigFile);
3950
leftCam.loadConfig(leftConfigFile);
4051

52+
// Initialize a reconstructor with the resolution of the projection to project patterns
4153
SLS::ReconstructorCPU reconstruct(p.get<size_t>("width"), p.get<size_t>("height"));
54+
55+
// Add cameras to reconstructor
4256
reconstruct.addCamera(&rightCam);
4357
reconstruct.addCamera(&leftCam);
4458

59+
// Run reconstructio and get the point cloud
4560
auto pointCloud = reconstruct.reconstruct();
4661

62+
// Get extension of output file
4763
auto extension = output.substr(output.find_last_of(".")+1);
64+
65+
// Export point cloud to file
4866
pointCloud.exportPointCloud( p.get<std::string>("output"), extension);
49-
//SLS::exportPointCloud(output, extension, reconstruct);
5067

5168
LOG::writeLog("DONE!\n");
5269

‎src/app/App_CUDA.cu

+21-4
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,46 @@ int main(int argc, char** argv)
1515
p.add<size_t>("height", 'h',"Projector height", true);
1616
p.parse_check(argc, argv);
1717

18+
// Start logging, this function will clear log file and start a new logging.
1819
LOG::restartLog();
20+
21+
// Setup left camera image folder
1922
std::string leftCameraFolder = p.get<std::string>("leftcam");
20-
std::string rightCameraFolder = p.get<std::string>("rightcam");
23+
// Setup left camera calibration parameters
2124
std::string leftConfigFile = p.get<std::string>("leftconfig");
25+
26+
// Setup right camera
27+
std::string rightCameraFolder = p.get<std::string>("rightcam");
2228
std::string rightConfigFile = p.get<std::string>("rightconfig");
29+
2330
std::string output = p.get<std::string>("output");
2431
std::string suffix = p.get<std::string>("format");
2532

26-
LOG::restartLog();
33+
// Initialize two file readers to load images from file
2734
SLS::FileReaderCUDA rightCam("rightCamera");
2835
SLS::FileReaderCUDA leftCam("leftCamera");
2936

30-
rightCam.loadImages(rightCameraFolder, suffix);
31-
leftCam.loadImages(leftCameraFolder, suffix);
37+
// Load images
38+
// void loadImages( const std::string &folder, std::string prefix, size_t numDigits, size_t startIdx, std::string suffix )
39+
rightCam.loadImages(rightCameraFolder, "", 4, 0,suffix);
40+
leftCam.loadImages(leftCameraFolder, "", 4, 0, suffix);
3241

42+
// Load configurations, mainly calibration parameters
3343
rightCam.loadConfig(rightConfigFile);
3444
leftCam.loadConfig(leftConfigFile);
3545

46+
// Initialize a reconstructor with the resolution of the projection to project patterns
3647
SLS::ReconstructorCUDA reconstruct(p.get<size_t>("width"), p.get<size_t>("height"));
48+
49+
// Add cameras to reconstructor
3750
reconstruct.addCamera(&rightCam);
3851
reconstruct.addCamera(&leftCam);
52+
53+
// Run reconstructio and get the point cloud
3954
auto pointCloud = reconstruct.reconstruct();
55+
// Get extension of output file
4056
auto extension = output.substr(output.find_last_of(".")+1);
57+
// Export point cloud to file
4158
pointCloud.exportPointCloud(output, extension);
4259
LOG::writeLog("DONE\n");
4360
return 0;

‎src/lib/ReconstructorCUDA/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,5 @@ file(GLOB CUDA_SOURCES
44
)
55
#cuda_compile(SLS_OBJ ${CUDA_SOURCES})
66
cuda_add_library( sls_gpu ${CUDA_SOURCES})
7+
target_link_libraries( sls_gpu core)
78

‎src/lib/core/Log.cpp

+16-16
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ namespace LOG {
77
bool writeLog(const char* message, ...)
88
{
99
va_list argptr;
10-
FILE* file = fopen(GL_LOG_FILE, "a");
10+
FILE* file = fopen(LOG_FILE, "a");
1111
if (!file) {
1212
fprintf(stderr,
13-
"ERROR: could not open GL_LOG_FILE %s file for appending\n",
14-
GL_LOG_FILE);
13+
"ERROR: could not open LOG_FILE %s file for appending\n",
14+
LOG_FILE);
1515
return false;
1616
}
1717
va_start(argptr, message);
@@ -23,11 +23,11 @@ bool writeLog(const char* message, ...)
2323
bool writeLogErr(const char* message, ...)
2424
{
2525
va_list argptr;
26-
FILE* file = fopen(GL_LOG_FILE, "a");
26+
FILE* file = fopen(LOG_FILE, "a");
2727
if (!file) {
2828
fprintf(stderr,
29-
"ERROR: could not open GL_LOG_FILE %s file for appending\n",
30-
GL_LOG_FILE);
29+
"ERROR: could not open LOG_FILE %s file for appending\n",
30+
LOG_FILE);
3131
return false;
3232
}
3333
va_start(argptr, message);
@@ -41,27 +41,27 @@ bool writeLogErr(const char* message, ...)
4141
}
4242
bool restartLog()
4343
{
44-
FILE* file = fopen(GL_LOG_FILE, "w");
44+
FILE* file = fopen(LOG_FILE, "w");
4545
if (!file) {
4646
fprintf(stderr,
47-
"ERROR: could not open GL_LOG_FILE log file %s for writing\n",
48-
GL_LOG_FILE);
47+
"ERROR: could not open LOG_FILE log file %s for writing\n",
48+
LOG_FILE);
4949
return false;
5050
}
5151
time_t now = time(NULL);
5252
char* date = ctime(&now);
53-
fprintf(file, "GL_LOG_FILE log. local time %s\n", date);
53+
fprintf(file, "LOG_FILE log. local time %s\n", date);
5454
fclose(file);
5555
return true;
5656
}
5757
bool startTimer(const char* message, ...)
5858
{
5959
va_list argptr;
60-
FILE* file = fopen(GL_LOG_FILE, "a");
60+
FILE* file = fopen(LOG_FILE, "a");
6161
if (!file) {
6262
fprintf(stderr,
63-
"ERROR: could not open GL_LOG_FILE %s file for appending\n",
64-
GL_LOG_FILE);
63+
"ERROR: could not open LOG_FILE %s file for appending\n",
64+
LOG_FILE);
6565
return false;
6666
}
6767
va_start(argptr, message);
@@ -80,11 +80,11 @@ bool startTimer()
8080
bool endTimer(const char* message, ...)
8181
{
8282
va_list argptr;
83-
FILE* file = fopen(GL_LOG_FILE, "a");
83+
FILE* file = fopen(LOG_FILE, "a");
8484
if (!file) {
8585
fprintf(stderr,
86-
"ERROR: could not open GL_LOG_FILE %s file for appending\n",
87-
GL_LOG_FILE);
86+
"ERROR: could not open LOG_FILE %s file for appending\n",
87+
LOG_FILE);
8888
return false;
8989
}
9090
va_start(argptr, message);

‎src/lib/core/Log.hpp

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
#include <chrono>
33
#include <iostream>
44
#include <ctime>
5-
#define GL_LOG_FILE "sls.log" // !< Define log file
5+
6+
#ifndef LOG_FILE
7+
#define LOG_FILE "sls.log" // !< Define log file
8+
#endif
69

710
/*! System wide log to output message to terminal and file
811
*/
@@ -30,7 +33,6 @@ namespace LOG
3033
* foo();
3134
* endTimer('s');
3235
* ```
33-
*
3436
*/
3537
//! Start timer with a log
3638
bool startTimer(const char* message, ...);

0 commit comments

Comments
 (0)
Please sign in to comment.