diff --git a/src/visualizer/base_visualizer.h b/src/visualizer/base_visualizer.h index b98c6d9..bd585b6 100644 --- a/src/visualizer/base_visualizer.h +++ b/src/visualizer/base_visualizer.h @@ -18,7 +18,6 @@ struct VisFrame { PointCloudPtr cloud = nullptr; }; -template class Visualizer { public: Visualizer(const std::string &name, size_t max_history_size) @@ -50,7 +49,7 @@ class Visualizer { } } - void Render(const std::shared_ptr &frame) { + void Render(const std::shared_ptr &frame) { std::lock_guard lock(mutex_); while (history_frames_.size() > max_history_size_) { history_frames_.pop_back(); @@ -78,7 +77,7 @@ class Visualizer { * @brief Draw objects. This method should be overrided for customization. * * virtual void Draw() { - * FrameT frame = GetCurrentFrame(); + * VisFrame frame* = GetCurrentFrame(); * { // Update cloud * std::string id = "point cloud"; * DrawPointCloud(*frame.cloud, {255, 255, 255}, id, viewer_.get()); @@ -128,9 +127,10 @@ class Visualizer { viewer_->removeAllShapes(); } + template FrameT GetCurrentFrame() const { std::lock_guard lock(mutex_); - return *(*curr_frame_iter_); + return *static_cast((*curr_frame_iter_).get()); } // visualizer name @@ -147,10 +147,10 @@ class Visualizer { std::atomic_bool is_updated_{false}; // The visualizer frame list - std::deque> history_frames_; + std::deque> history_frames_; // The current displayed frame iter. - typename std::deque>::const_iterator curr_frame_iter_; + typename std::deque>::iterator curr_frame_iter_; // The rendered cloud ids. std::vector rendered_cloud_ids_; diff --git a/src/visualizer/extractor_visualizer.cc b/src/visualizer/extractor_visualizer.cc index 708a20b..1d076d1 100644 --- a/src/visualizer/extractor_visualizer.cc +++ b/src/visualizer/extractor_visualizer.cc @@ -3,7 +3,7 @@ namespace oh_my_loam { void ExtractorVisualizer::Draw() { - auto frame = GetCurrentFrame(); + auto frame = GetCurrentFrame(); { // add raw point cloud std::string id = "raw point cloud"; DrawPointCloud(*frame.cloud, WHITE, id, viewer_.get()); diff --git a/src/visualizer/extractor_visualizer.h b/src/visualizer/extractor_visualizer.h index ff1195d..d9486f2 100644 --- a/src/visualizer/extractor_visualizer.h +++ b/src/visualizer/extractor_visualizer.h @@ -9,11 +9,11 @@ struct ExtractorVisFrame : public VisFrame { FeaturePoints feature_pts; }; -class ExtractorVisualizer : public Visualizer { +class ExtractorVisualizer : public Visualizer { public: explicit ExtractorVisualizer(const std::string &name = "ExtractorVisualizer", size_t max_history_size = 10) - : Visualizer(name, max_history_size) {} + : Visualizer(name, max_history_size) {} private: void Draw() override;