Skip to content

Commit

Permalink
Docs in app
Browse files Browse the repository at this point in the history
  • Loading branch information
tsing committed Mar 20, 2017
1 parent 42427ed commit e6ce4ff
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 25 deletions.
23 changes: 20 additions & 3 deletions src/app/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
int main(int argc, char** argv)
{

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

// Start logging, this function will clear log file and start a new logging.
LOG::restartLog();

// Setup left camera image folder
std::string leftCameraFolder = p.get<std::string>("leftcam");
std::string rightCameraFolder = p.get<std::string>("rightcam");
// Setup left camera calibration parameters
std::string leftConfigFile = p.get<std::string>("leftconfig");

// Setup right camera
std::string rightCameraFolder = p.get<std::string>("rightcam");
std::string rightConfigFile = p.get<std::string>("rightconfig");

std::string output = p.get<std::string>("output");
std::string suffix = p.get<std::string>("format");


// Initialize two file readers to load images from file
SLS::FileReader rightCam("rightCam");
SLS::FileReader leftCam("rightCam");

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

// Load configurations, mainly calibration parameters
rightCam.loadConfig(rightConfigFile);
leftCam.loadConfig(leftConfigFile);

// Initialize a reconstructor with the resolution of the projection to project patterns
SLS::ReconstructorCPU reconstruct(p.get<size_t>("width"), p.get<size_t>("height"));

// Add cameras to reconstructor
reconstruct.addCamera(&rightCam);
reconstruct.addCamera(&leftCam);

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

// Get extension of output file
auto extension = output.substr(output.find_last_of(".")+1);

// Export point cloud to file
pointCloud.exportPointCloud( p.get<std::string>("output"), extension);
//SLS::exportPointCloud(output, extension, reconstruct);

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

Expand Down
25 changes: 21 additions & 4 deletions src/app/App_CUDA.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,46 @@ int main(int argc, char** argv)
p.add<size_t>("height", 'h',"Projector height", true);
p.parse_check(argc, argv);

// Start logging, this function will clear log file and start a new logging.
LOG::restartLog();

// Setup left camera image folder
std::string leftCameraFolder = p.get<std::string>("leftcam");
std::string rightCameraFolder = p.get<std::string>("rightcam");
// Setup left camera calibration parameters
std::string leftConfigFile = p.get<std::string>("leftconfig");

// Setup right camera
std::string rightCameraFolder = p.get<std::string>("rightcam");
std::string rightConfigFile = p.get<std::string>("rightconfig");

std::string output = p.get<std::string>("output");
std::string suffix = p.get<std::string>("format");

LOG::restartLog();
// Initialize two file readers to load images from file
SLS::FileReaderCUDA rightCam("rightCamera");
SLS::FileReaderCUDA leftCam("leftCamera");

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

// Load configurations, mainly calibration parameters
rightCam.loadConfig(rightConfigFile);
leftCam.loadConfig(leftConfigFile);

// Initialize a reconstructor with the resolution of the projection to project patterns
SLS::ReconstructorCUDA reconstruct(p.get<size_t>("width"), p.get<size_t>("height"));

// Add cameras to reconstructor
reconstruct.addCamera(&rightCam);
reconstruct.addCamera(&leftCam);

// Run reconstructio and get the point cloud
auto pointCloud = reconstruct.reconstruct();
// Get extension of output file
auto extension = output.substr(output.find_last_of(".")+1);
// Export point cloud to file
pointCloud.exportPointCloud(output, extension);
LOG::writeLog("DONE\n");
return 0;
Expand Down
1 change: 1 addition & 0 deletions src/lib/ReconstructorCUDA/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ file(GLOB CUDA_SOURCES
)
#cuda_compile(SLS_OBJ ${CUDA_SOURCES})
cuda_add_library( sls_gpu ${CUDA_SOURCES})
target_link_libraries( sls_gpu core)

32 changes: 16 additions & 16 deletions src/lib/core/Log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ namespace LOG {
bool writeLog(const char* message, ...)
{
va_list argptr;
FILE* file = fopen(GL_LOG_FILE, "a");
FILE* file = fopen(LOG_FILE, "a");
if (!file) {
fprintf(stderr,
"ERROR: could not open GL_LOG_FILE %s file for appending\n",
GL_LOG_FILE);
"ERROR: could not open LOG_FILE %s file for appending\n",
LOG_FILE);
return false;
}
va_start(argptr, message);
Expand All @@ -23,11 +23,11 @@ bool writeLog(const char* message, ...)
bool writeLogErr(const char* message, ...)
{
va_list argptr;
FILE* file = fopen(GL_LOG_FILE, "a");
FILE* file = fopen(LOG_FILE, "a");
if (!file) {
fprintf(stderr,
"ERROR: could not open GL_LOG_FILE %s file for appending\n",
GL_LOG_FILE);
"ERROR: could not open LOG_FILE %s file for appending\n",
LOG_FILE);
return false;
}
va_start(argptr, message);
Expand All @@ -41,27 +41,27 @@ bool writeLogErr(const char* message, ...)
}
bool restartLog()
{
FILE* file = fopen(GL_LOG_FILE, "w");
FILE* file = fopen(LOG_FILE, "w");
if (!file) {
fprintf(stderr,
"ERROR: could not open GL_LOG_FILE log file %s for writing\n",
GL_LOG_FILE);
"ERROR: could not open LOG_FILE log file %s for writing\n",
LOG_FILE);
return false;
}
time_t now = time(NULL);
char* date = ctime(&now);
fprintf(file, "GL_LOG_FILE log. local time %s\n", date);
fprintf(file, "LOG_FILE log. local time %s\n", date);
fclose(file);
return true;
}
bool startTimer(const char* message, ...)
{
va_list argptr;
FILE* file = fopen(GL_LOG_FILE, "a");
FILE* file = fopen(LOG_FILE, "a");
if (!file) {
fprintf(stderr,
"ERROR: could not open GL_LOG_FILE %s file for appending\n",
GL_LOG_FILE);
"ERROR: could not open LOG_FILE %s file for appending\n",
LOG_FILE);
return false;
}
va_start(argptr, message);
Expand All @@ -80,11 +80,11 @@ bool startTimer()
bool endTimer(const char* message, ...)
{
va_list argptr;
FILE* file = fopen(GL_LOG_FILE, "a");
FILE* file = fopen(LOG_FILE, "a");
if (!file) {
fprintf(stderr,
"ERROR: could not open GL_LOG_FILE %s file for appending\n",
GL_LOG_FILE);
"ERROR: could not open LOG_FILE %s file for appending\n",
LOG_FILE);
return false;
}
va_start(argptr, message);
Expand Down
6 changes: 4 additions & 2 deletions src/lib/core/Log.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
#include <chrono>
#include <iostream>
#include <ctime>
#define GL_LOG_FILE "sls.log" // !< Define log file

#ifndef LOG_FILE
#define LOG_FILE "sls.log" // !< Define log file
#endif

/*! System wide log to output message to terminal and file
*/
Expand Down Expand Up @@ -30,7 +33,6 @@ namespace LOG
* foo();
* endTimer('s');
* ```
*
*/
//! Start timer with a log
bool startTimer(const char* message, ...);
Expand Down

0 comments on commit e6ce4ff

Please sign in to comment.