1
+ #include < atomic>
2
+ #include < thread>
3
+ #include < vector>
1
4
#include < iostream>
2
5
#include < librealsense2/rs.hpp>
3
6
#include < spectacularAI/realsense/plugin.hpp>
@@ -17,6 +20,7 @@ void showUsage() {
17
20
<< " --saturation <value>" << std::endl
18
21
<< " --sharpness <value>" << std::endl
19
22
<< " --white_balance <value>" << std::endl
23
+ << " --print" << std::endl
20
24
<< std::endl;
21
25
}
22
26
@@ -35,6 +39,7 @@ struct ColorCameraConfig {
35
39
int main (int argc, char ** argv) {
36
40
spectacularAI::rsPlugin::Configuration config;
37
41
ColorCameraConfig colorConfig;
42
+ bool print = false ;
38
43
39
44
std::vector<std::string> arguments (argv, argv + argc);
40
45
for (size_t i = 1 ; i < arguments.size (); ++i) {
@@ -63,6 +68,8 @@ int main(int argc, char** argv) {
63
68
colorConfig.sharpness = std::stoi (arguments.at (++i));
64
69
else if (argument == " --white_balance" )
65
70
colorConfig.whiteBalance = std::stoi (arguments.at (++i));
71
+ else if (argument == " --print" )
72
+ print = true ;
66
73
else if (argument == " --help" || argument == " -h" ) {
67
74
showUsage ();
68
75
return EXIT_SUCCESS;
@@ -112,13 +119,31 @@ int main(int argc, char** argv) {
112
119
// Start pipeline
113
120
rs2::config rsConfig;
114
121
vioPipeline.configureStreams (rsConfig);
115
- auto vioSession = vioPipeline.startSession (rsConfig);
122
+ auto session = vioPipeline.startSession (rsConfig);
116
123
117
- std::cout << " Recording, use Ctrl+C to stop" << std::endl;
124
+ std::atomic<bool > shouldQuit (false );
125
+ std::thread inputThread ([&]() {
126
+ std::cout << " Press Enter to quit." << std::endl << std::endl;
127
+ getchar ();
128
+ shouldQuit = true ;
129
+ });
118
130
119
- while (true ) {
120
- vioSession->waitForOutput ();
131
+ while (!shouldQuit) {
132
+ if (session->hasOutput ()) {
133
+ auto out = session->getOutput ();
134
+ if (print) {
135
+ std::cout << " Vio API pose: " << out->pose .time << " , " << out->pose .position .x
136
+ << " , " << out->pose .position .y << " , " << out->pose .position .z << " , "
137
+ << out->pose .orientation .x << " , " << out->pose .orientation .y << " , "
138
+ << out->pose .orientation .z << " , " << out->pose .orientation .w
139
+ << std::endl;
140
+ }
141
+ }
142
+ std::this_thread::sleep_for (std::chrono::milliseconds (1 ));
121
143
}
122
144
145
+ std::cout << " Exiting." << std::endl;
146
+ if (shouldQuit) inputThread.join ();
147
+
123
148
return 0 ;
124
149
}
0 commit comments