Skip to content

Commit f807298

Browse files
committed
add --viz flag
1 parent 3ab4cd2 commit f807298

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

xrslam-pc/player/src/main.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,12 @@ void GetShowElements() {
4444

4545
SLAMData::Frame frame = SLAMData::Frame(cv::Mat(), intrinsics_v, pose_c_m);
4646

47-
viewer->data->update_frames({frame});
48-
viewer->data->update_points(points);
49-
viewer->data->update_poses(pose_c_m);
50-
viewer->data->update_image(feature_tracker_cvimage);
51-
47+
if(viewer){
48+
viewer->data->update_frames({frame});
49+
viewer->data->update_points(points);
50+
viewer->data->update_poses(pose_c_m);
51+
viewer->data->update_image(feature_tracker_cvimage);
52+
}
5253
}
5354

5455
typedef std::tuple<double, XRSLAMAcceleration, XRSLAMGyroscope> IMUData;
@@ -68,6 +69,10 @@ int main(int argc, char *argv[]) {
6869
.help("Start playing immediately.")
6970
.default_value(false)
7071
.implicit_value(true);
72+
program.add_argument("-v", "--viz")
73+
.help("Visualization with GUI.")
74+
.default_value(false)
75+
.implicit_value(true);
7176
program.add_argument("input").help("input file");
7277
program.parse_args(argc, argv);
7378
std::string data_path = program.get<std::string>("input");
@@ -77,6 +82,7 @@ int main(int argc, char *argv[]) {
7782
std::string csv_output = program.get<std::string>("--csv");
7883
std::string tum_output = program.get<std::string>("--tum");
7984
bool isRunning = program.get<bool>("-p");
85+
bool viz = program.get<bool>("-v");
8086

8187
// create slam with configuration files
8288
void *yaml_config = nullptr;
@@ -104,8 +110,10 @@ int main(int argc, char *argv[]) {
104110
// outputs.emplace_back(std::make_unique<ConsoleTrajectoryWriter>());
105111
DatasetReader::NextDataType next_type;
106112

107-
viewer = std::make_shared<SLAMViewer>("XRSLAM PC", 1280, 720);
108-
viewer->start();
113+
if(viz){
114+
viewer = std::make_shared<SLAMViewer>("XRSLAM PC", 1280, 720);
115+
viewer->start();
116+
}
109117

110118
std::unique_ptr<xrslam::InspectPainter> feature_tracker_painter;
111119
feature_tracker_painter = std::make_unique<OpenCvPainter>(feature_tracker_cvimage);
@@ -130,7 +138,7 @@ int main(int argc, char *argv[]) {
130138
} break;
131139
case DatasetReader::CAMERA: {
132140

133-
{
141+
if (viewer) {
134142
auto &notifier = viewer->notifier;
135143
std::unique_lock<std::mutex> lock(notifier->mtx);
136144
notifier->cv.wait(lock, [&notifier] { return notifier->ready;});
@@ -168,7 +176,6 @@ int main(int argc, char *argv[]) {
168176
}
169177
}
170178

171-
sleep(99999);
172179
XRSLAMDestroy();
173180

174181
return EXIT_SUCCESS;

0 commit comments

Comments
 (0)