@@ -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+
7582void 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 ;
0 commit comments