forked from SpectacularAI/sdk-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvio_replay.cpp
38 lines (31 loc) · 1.05 KB
/
vio_replay.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
#include <spectacularAI/vio.hpp>
#include <spectacularAI/replay.hpp>
#include <iostream>
#ifdef EXAMPLE_USE_OPENCV
#include <opencv2/opencv.hpp>
#endif
int main(int argc, char** argv) {
if (argc < 2) return 1;
std::string dataFolder = argv[1];
spectacularAI::Vio::Builder vioBuilder = spectacularAI::Vio::builder();
auto replayApi = spectacularAI::Replay::builder(dataFolder, vioBuilder)
.build();
replayApi->setExtendedOutputCallback([&](spectacularAI::VioOutputPtr output, spectacularAI::FrameSet frames) {
std::cout << output->asJson() << std::endl;
#ifdef EXAMPLE_USE_OPENCV
for (int i = 0; i < frames.size(); i++) {
// Note: typically not main thread
auto &frame = frames[i];
if (frame->image) {
cv::Mat img = frame->image->asOpenCV();
cv::imshow("Video " + std::to_string(i), img);
cv::waitKey(1);
}
}
#else
(void)frames;
#endif
});
replayApi->runReplay();
return 0;
}