-
Notifications
You must be signed in to change notification settings - Fork 114
/
Copy pathApp.cpp
80 lines (63 loc) · 3.16 KB
/
App.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <core/ImageFileProcessor.h>
#include <core/Reconstructor.h>
#include <core/Log.hpp>
#include <glm/gtx/string_cast.hpp>
#include <core/ReconstructorCPU.h>
#include <memory>
#include "cmdline.h"
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);
p.add<std::string>("leftconfig", 'L',"Left camera configuration file", true);
p.add<std::string>("rightconfig", 'R',"Right camera configuration file", true);
p.add<std::string>("output", 'o',"Output folder", true);
p.add<std::string>("format", 'f',"Suffix of image files, e.g. jpg", true);
p.add<size_t>("width", 'w',"Projector width", true);
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");
// 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::ImageFileProcessor rightCamProcessor("rightCamProcessor");
SLS::ImageFileProcessor leftCamProcessor("leftCamProcessor");
// Load images
// void loadImages( const std::string &folder, std::string prefix, size_t numDigits, size_t startIdx, std::string suffix )
rightCamProcessor.loadImages(rightCameraFolder, "", 4, 1,suffix);
leftCamProcessor.loadImages(leftCameraFolder, "", 4, 1, suffix);
// Load configurations, mainly calibration parameters
rightCamProcessor.loadConfig(rightConfigFile);
leftCamProcessor.loadConfig(leftConfigFile);
// Construct a projector parameter provider
SLS::Projector proj(p.get<size_t>("width"),p.get<size_t>("height"));
// Generate reconstruction buckets from image processors.
// generateBuckets function requires parameter extracted from the `Projector` object,
// namely projector width, height and number of frames required to reconstruct with the
// projected patterns.
std::vector<SLS::Buckets> bucketsVec
{
rightCamProcessor.generateBuckets(proj.getWidth(), proj.getHeight(), proj.getRequiredNumFrames()),
leftCamProcessor.generateBuckets(proj.getWidth(), proj.getHeight(), proj.getRequiredNumFrames())
};
// Initialize a reconstruct
SLS::ReconstructorCPU reconstruct;
// Run reconstruction and get the point cloud
auto pointCloud = reconstruct.reconstruct(bucketsVec);
// 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);
LOG::writeLog("DONE!\n");
return 0;
}