Skip to content

Commit 15b7e80

Browse files
authored
Merge pull request #218 from Joilnen/b_00
allow you to interact with point cloud window while running,
2 parents 5bc9b2d + 9924920 commit 15b7e80

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

opensplat.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,8 @@ int main(int argc, char *argv[]){
188188
visualizer.SetGaussians(model.means, model.scales, model.featuresDc,
189189
model.opacities);
190190
visualizer.SetImage(rgb, gt);
191+
if (visualizer.QuitApp())
192+
step = numIters + 1;
191193
visualizer.Draw();
192194
}
193195
#endif

visualizer.cpp

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ bool Visualizer::Initialize(int iter_num) {
1010
pangolin::CreateWindowAndBind("OpenSplat", 1200, 1000);
1111
glEnable(GL_DEPTH_TEST);
1212
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
13+
iter_num_ = iter_num;
1314

1415
cam_state_ = std::make_unique<pangolin::OpenGlRenderState>(
1516
pangolin::ProjectionMatrix(1200, 1000, 420, 420, 600, 500, 0.1f, 1000),
@@ -43,7 +44,9 @@ bool Visualizer::Initialize(int iter_num) {
4344
gaussian_num_ = std::make_unique<pangolin::Var<int>>("panel.gaussian num", 0);
4445
loss_ = std::make_unique<pangolin::Var<float>>("panel.loss", 0.0f);
4546
pause_button_ =
46-
std::make_unique<pangolin::Var<bool>>("panel.Start/Pause", false, false);
47+
std::make_unique<pangolin::Var<bool>>("panel.Start/Pause", true, false);
48+
quit_button_ =
49+
std::make_unique<pangolin::Var<bool>>("panel.Quit", false, false);
4750

4851
return true;
4952
}
@@ -72,6 +75,10 @@ void Visualizer::SetInitialGaussianNum(int num) {
7275
}
7376
}
7477

78+
bool Visualizer::QuitApp() {
79+
return quit_;
80+
}
81+
7582
void Visualizer::SetGaussians(const torch::Tensor& means,
7683
const torch::Tensor& covariances,
7784
const torch::Tensor& colors,
@@ -92,18 +99,31 @@ void Visualizer::SetImage(const torch::Tensor& rendered_img,
9299
gt_img_ = (gt_img.cpu() * 255).to(torch::kUInt8);
93100
}
94101

95-
void Visualizer::Draw() {
102+
void Visualizer::DrawInern() {
96103
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
97104

98105
DrawGaussians();
99106
DrawImage();
100107

101108
pangolin::FinishFrame();
109+
if (iter_num_ == *step_)
110+
*pause_button_ = true;
111+
if (*quit_button_) {
112+
quit_ = true;;
113+
}
114+
}
115+
116+
void Visualizer::Draw() {
117+
pangolin::WindowInterface* window = pangolin::GetBoundWindow();
118+
119+
DrawInern();
102120

103121
while (*pause_button_) {
122+
123+
DrawInern();
104124
std::this_thread::sleep_for(std::chrono::milliseconds(100));
105-
pangolin::WindowInterface* window = pangolin::GetBoundWindow();
106-
if (window) {
125+
126+
if (!quit_ && window) {
107127
window->ProcessEvents();
108128
} else {
109129
break;

visualizer.hpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,15 @@ class Visualizer {
2929

3030
void Draw();
3131

32+
bool QuitApp();
33+
3234
private:
3335
bool DrawGaussians();
3436

3537
bool DrawImage();
3638

39+
void DrawInern();
40+
3741
private:
3842
std::unique_ptr<pangolin::OpenGlRenderState> cam_state_;
3943
std::unique_ptr<pangolin::View> point_cloud_viewer_;
@@ -46,6 +50,7 @@ class Visualizer {
4650
std::unique_ptr<pangolin::Var<int>> gaussian_num_;
4751
std::unique_ptr<pangolin::Var<float>> loss_;
4852
std::unique_ptr<pangolin::Var<bool>> pause_button_;
53+
std::unique_ptr<pangolin::Var<bool>> quit_button_;
4954

5055
torch::Tensor means_;
5156
torch::Tensor covariances_;
@@ -54,6 +59,9 @@ class Visualizer {
5459

5560
torch::Tensor rendered_img_;
5661
torch::Tensor gt_img_;
62+
63+
int iter_num_;
64+
bool quit_ {false};
5765
};
5866

5967
#endif

0 commit comments

Comments
 (0)