From 912008792ba2063a6f97e9edd87c6a13bb24fee8 Mon Sep 17 00:00:00 2001 From: Igor Bogoslavskyi Date: Tue, 4 Feb 2020 21:24:23 +0100 Subject: [PATCH] Better viewer everywhere (#61) * Switch to convex hull visualization * Use the newer viewer everywhere but in ROS related viewer --- examples/simple_nodes/CMakeLists.txt | 6 +- examples/simple_nodes/show_objects_kitti.cpp | 15 ++-- .../simple_nodes/show_objects_moosmann.cpp | 16 ++-- src/clusterers/image_based_clusterer.h | 2 +- src/qt/drawables/CMakeLists.txt | 5 +- src/qt/drawables/bbox_painter.h | 46 ---------- src/qt/drawables/drawable.h | 1 + src/qt/drawables/drawable_cube.cpp | 8 +- src/qt/drawables/drawable_cube.h | 10 ++- src/qt/drawables/drawable_polygon3d.cpp | 44 ++++++++++ src/qt/drawables/drawable_polygon3d.h | 42 +++++++++ src/qt/drawables/object_painter.cpp | 87 +++++++++++++++++++ src/qt/drawables/object_painter.h | 63 +++++--------- src/qt/utils/utils.cpp | 10 +-- src/qt/utils/utils.h | 2 +- src/qt/viewer/viewer.cpp | 2 +- src/qt/widgets/opengl_folder_player.cpp | 9 +- src/qt/widgets/opengl_folder_player.h | 2 +- src/visualization/visualizer.cpp | 8 +- 19 files changed, 260 insertions(+), 118 deletions(-) delete mode 100644 src/qt/drawables/bbox_painter.h create mode 100644 src/qt/drawables/drawable_polygon3d.cpp create mode 100644 src/qt/drawables/drawable_polygon3d.h create mode 100644 src/qt/drawables/object_painter.cpp diff --git a/examples/simple_nodes/CMakeLists.txt b/examples/simple_nodes/CMakeLists.txt index 5593257..572b4cc 100644 --- a/examples/simple_nodes/CMakeLists.txt +++ b/examples/simple_nodes/CMakeLists.txt @@ -6,7 +6,8 @@ target_link_libraries(show_objects_kitti projections ground_remove folder_reader - visualization + viewer + drawable ${MY_QT_LIBRARIES} ${Boost_LIBRARIES} ${PCL_LIBRARIES} @@ -20,7 +21,8 @@ target_link_libraries(show_objects_moosmann projections ground_remove folder_reader - visualization + viewer + drawable ${MY_QT_LIBRARIES} ${Boost_LIBRARIES} ${PCL_LIBRARIES} diff --git a/examples/simple_nodes/show_objects_kitti.cpp b/examples/simple_nodes/show_objects_kitti.cpp index 40561fb..84e0541 100644 --- a/examples/simple_nodes/show_objects_kitti.cpp +++ b/examples/simple_nodes/show_objects_kitti.cpp @@ -25,12 +25,13 @@ #include "ground_removal/depth_ground_remover.h" #include "projections/projection_params.h" +#include "qt/drawables/drawable_cloud.h" +#include "qt/drawables/object_painter.h" #include "utils/cloud.h" #include "utils/folder_reader.h" #include "utils/radians.h" #include "utils/timer.h" #include "utils/velodyne_utils.h" -#include "visualization/visualizer.h" #include "tclap/CmdLine.h" @@ -39,7 +40,7 @@ using std::string; using namespace depth_clustering; void ReadData(const Radians& angle_tollerance, const string& in_path, - Visualizer* visualizer) { + Viewer* visualizer) { // delay reading for one second to allow GUI to load std::this_thread::sleep_for(std::chrono::milliseconds(500)); // now load the data @@ -63,8 +64,11 @@ void ReadData(const Radians& angle_tollerance, const string& in_path, angle_tollerance, min_cluster_size, max_cluster_size); clusterer.SetDiffType(DiffFactory::DiffType::ANGLES); + ObjectPainter object_painter{visualizer, + ObjectPainter::OutlineType::kPolygon3d}; + depth_ground_remover.AddClient(&clusterer); - clusterer.AddClient(visualizer->object_clouds_client()); + clusterer.AddClient(&object_painter); fprintf(stderr, "INFO: everything initialized\n"); @@ -72,7 +76,8 @@ void ReadData(const Radians& angle_tollerance, const string& in_path, time_utils::Timer timer; auto cloud = ReadKittiCloud(path); cloud->InitProjection(*proj_params_ptr); - visualizer->OnNewObjectReceived(*cloud, 0); + visualizer->Clear(); + visualizer->AddDrawable(DrawableCloud::FromCloud(cloud)); depth_ground_remover.OnNewObjectReceived(*cloud, 0); uint max_wait_time = 100; @@ -108,7 +113,7 @@ int main(int argc, char* argv[]) { QApplication application(argc, argv); // visualizer should be created from a gui thread - Visualizer visualizer; + Viewer visualizer; visualizer.show(); // create and run loader thread diff --git a/examples/simple_nodes/show_objects_moosmann.cpp b/examples/simple_nodes/show_objects_moosmann.cpp index eec5499..66fb9a8 100644 --- a/examples/simple_nodes/show_objects_moosmann.cpp +++ b/examples/simple_nodes/show_objects_moosmann.cpp @@ -25,12 +25,14 @@ #include "ground_removal/depth_ground_remover.h" #include "projections/projection_params.h" +#include "qt/drawables/object_painter.h" +#include "qt/drawables/drawable_cloud.h" +#include "qt/viewer/viewer.h" #include "utils/cloud.h" #include "utils/folder_reader.h" #include "utils/radians.h" #include "utils/timer.h" #include "utils/velodyne_utils.h" -#include "visualization/visualizer.h" #include "tclap/CmdLine.h" @@ -40,7 +42,7 @@ using std::to_string; using namespace depth_clustering; void ReadData(const Radians& angle_tollerance, const string& in_path, - Visualizer* visualizer) { + Viewer* visualizer) { // delay reading for one second to allow GUI to load std::this_thread::sleep_for(std::chrono::milliseconds(500)); // now load the data @@ -65,14 +67,18 @@ void ReadData(const Radians& angle_tollerance, const string& in_path, angle_tollerance, min_cluster_size, max_cluster_size); clusterer.SetDiffType(DiffFactory::DiffType::ANGLES); + ObjectPainter object_painter{visualizer, + ObjectPainter::OutlineType::kPolygon3d}; + depth_ground_remover.AddClient(&clusterer); - clusterer.AddClient(visualizer->object_clouds_client()); + clusterer.AddClient(&object_painter); for (const auto& path : image_reader.GetAllFilePaths()) { auto depth_image = MatFromDepthPng(path); auto cloud_ptr = Cloud::FromImage(depth_image, *proj_params_ptr); time_utils::Timer timer; - visualizer->OnNewObjectReceived(*cloud_ptr, 0); + visualizer->Clear(); + visualizer->AddDrawable(DrawableCloud::FromCloud(cloud_ptr)); depth_ground_remover.OnNewObjectReceived(*cloud_ptr, 0); auto current_millis = timer.measure(time_utils::Timer::Units::Milli); fprintf(stderr, "INFO: It took %lu ms to process and show everything.\n", @@ -108,7 +114,7 @@ int main(int argc, char* argv[]) { QApplication application(argc, argv); // visualizer should be created from a gui thread - Visualizer visualizer; + Viewer visualizer; visualizer.show(); // create and run loader thread diff --git a/src/clusterers/image_based_clusterer.h b/src/clusterers/image_based_clusterer.h index 9e3bba2..0e3379d 100644 --- a/src/clusterers/image_based_clusterer.h +++ b/src/clusterers/image_based_clusterer.h @@ -88,7 +88,7 @@ class ImageBasedClusterer : public AbstractClusterer { * @param[in] cloud The cloud to cluster * @param[in] sender_id The sender identifier */ - void OnNewObjectReceived(const Cloud& cloud, const int sender_id) override { + void OnNewObjectReceived(const Cloud& cloud, int) override { // generate a projection from a point cloud if (!cloud.projection_ptr()) { fprintf(stderr, "ERROR: projection not initialized in cloud.\n"); diff --git a/src/qt/drawables/CMakeLists.txt b/src/qt/drawables/CMakeLists.txt index 03f284f..b8e3e6c 100644 --- a/src/qt/drawables/CMakeLists.txt +++ b/src/qt/drawables/CMakeLists.txt @@ -1,6 +1,9 @@ add_library(drawable SHARED drawable_cloud.cpp + object_painter.cpp + drawable_polygon3d.cpp drawable_cube.cpp) target_link_libraries(drawable + ${OpenCV_LIBS} ${OPENGL_gl_LIBRARY} - ${OPENGL_glu_LIBRARY}) \ No newline at end of file + ${OPENGL_glu_LIBRARY}) diff --git a/src/qt/drawables/bbox_painter.h b/src/qt/drawables/bbox_painter.h deleted file mode 100644 index 80c2b1b..0000000 --- a/src/qt/drawables/bbox_painter.h +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright Igor Bogoslavskyi, year 2017. -// In case of any problems with the code please contact me. -// Email: igor.bogoslavskyi@uni-bonn.de. - -#ifndef SRC_QT_DRAWABLES_BBOX_PAINTER_H_ -#define SRC_QT_DRAWABLES_BBOX_PAINTER_H_ - -#include -#include -#include - -#include -#include -#include - -#include "qt/drawables/drawable_cube.h" -#include "qt/viewer/viewer.h" -#include "utils/bbox.h" - -namespace dc = depth_clustering; - -class BBoxPainter : public dc::AbstractClient> { - public: - void OnNewObjectReceived(const std::vector& bboxes, - int client_id) override { - dc::time_utils::Timer timer; - for (const auto& bbox : bboxes) { - if (_viewer) { - _viewer->AddDrawable(DrawableCube::Create(bbox.center(), bbox.scale())); - } - } - fprintf(stderr, "[TIMING]: Adding all boxes took %lu us\n", - timer.measure(dc::time_utils::Timer::Units::Micro)); - _viewer->update(); - fprintf(stderr, "[TIMING]: Viewer updated in %lu us\n", - timer.measure(dc::time_utils::Timer::Units::Micro)); - } - - explicit BBoxPainter(Viewer* viewer) : _viewer(viewer) {} - virtual ~BBoxPainter() {} - - private: - Viewer* _viewer = nullptr; -}; - -#endif // SRC_QT_DRAWABLES_BBOX_PAINTER_H_ diff --git a/src/qt/drawables/drawable.h b/src/qt/drawables/drawable.h index ab83fa8..3e25339 100644 --- a/src/qt/drawables/drawable.h +++ b/src/qt/drawables/drawable.h @@ -10,6 +10,7 @@ class Drawable { public: using Ptr = std::shared_ptr; + using UniquePtr = std::unique_ptr; virtual void Draw() const = 0; virtual ~Drawable() {} }; diff --git a/src/qt/drawables/drawable_cube.cpp b/src/qt/drawables/drawable_cube.cpp index 588d0d9..556fe84 100644 --- a/src/qt/drawables/drawable_cube.cpp +++ b/src/qt/drawables/drawable_cube.cpp @@ -5,8 +5,12 @@ #include "./drawable_cube.h" #include +namespace depth_clustering { + void DrawableCube::Draw() const { - if (_scale.z() < 0.3) { return; } + if (_scale.z() < 0.3) { + return; + } glPushMatrix(); glTranslatef(_center.x(), _center.y(), _center.z()); glScalef(_scale.x(), _scale.y(), _scale.z()); @@ -53,3 +57,5 @@ void DrawableCube::Draw() const { glEnd(); glPopMatrix(); } + +} // namespace depth_clustering diff --git a/src/qt/drawables/drawable_cube.h b/src/qt/drawables/drawable_cube.h index 43bc29b..efc1cc7 100644 --- a/src/qt/drawables/drawable_cube.h +++ b/src/qt/drawables/drawable_cube.h @@ -8,6 +8,9 @@ #include #include "qt/drawables/drawable.h" +#include "utils/mem_utils.h" + +namespace depth_clustering { class DrawableCube : public Drawable { public: @@ -16,10 +19,11 @@ class DrawableCube : public Drawable { : _center{center}, _scale{scale}, _color{color} {} void Draw() const override; - static DrawableCube::Ptr Create( + static DrawableCube::UniquePtr Create( const Eigen::Vector3f& center, const Eigen::Vector3f& scale, const Eigen::Vector3f& color = Eigen::Vector3f(1.0f, 0.5f, 0.2f)) { - return std::make_shared(DrawableCube(center, scale, color)); + return mem_utils::make_unique( + DrawableCube(center, scale, color)); } ~DrawableCube() override {} @@ -30,4 +34,6 @@ class DrawableCube : public Drawable { Eigen::Vector3f _color; }; +} // namespace depth_clustering + #endif // SRC_QT_DRAWABLES_DRAWABLE_CUBE_H_ diff --git a/src/qt/drawables/drawable_polygon3d.cpp b/src/qt/drawables/drawable_polygon3d.cpp new file mode 100644 index 0000000..df6a3a6 --- /dev/null +++ b/src/qt/drawables/drawable_polygon3d.cpp @@ -0,0 +1,44 @@ +// Copyright Igor Bogoslavskyi, year 2017. +// In case of any problems with the code please contact me. +// Email: igor.bogoslavskyi@uni-bonn.de. + +#include "./drawable_polygon3d.h" +#include + +namespace depth_clustering { + +void DrawablePolygon3d::Draw() const { + if (polygon_.empty()) { + return; + } + glPushMatrix(); + const auto start = polygon_.front(); + glColor3f(color_[0], color_[1], color_[2]); + glLineWidth(4.0f); + glBegin(GL_LINE_STRIP); + + // Bottom polygon + for (const auto& point : polygon_) { + glVertex3f(point.x(), point.y(), point.z()); + } + glVertex3f(start.x(), start.y(), start.z()); + + // Top polygon + for (const auto& point : polygon_) { + glVertex3f(point.x(), point.y(), point.z() + height_); + } + glVertex3f(start.x(), start.y(), start.z() + height_); + + glEnd(); + + glBegin(GL_LINES); + // For the Sides of the polygon + for (const auto& point : polygon_) { + glVertex3f(point.x(), point.y(), point.z()); + glVertex3f(point.x(), point.y(), point.z() + height_); + } + glEnd(); + glPopMatrix(); +} + +} // namespace depth_clustering diff --git a/src/qt/drawables/drawable_polygon3d.h b/src/qt/drawables/drawable_polygon3d.h new file mode 100644 index 0000000..f72967f --- /dev/null +++ b/src/qt/drawables/drawable_polygon3d.h @@ -0,0 +1,42 @@ +// Copyright Igor Bogoslavskyi, year 2017. +// In case of any problems with the code please contact me. +// Email: igor.bogoslavskyi@uni-bonn.de. + +#ifndef SRC_QT_DRAWABLES_DRAWABLE_POLYGON3D_H_ +#define SRC_QT_DRAWABLES_DRAWABLE_POLYGON3D_H_ + +#include +#include + +#include "qt/drawables/drawable.h" +#include "utils/mem_utils.h" + +namespace depth_clustering { + +class DrawablePolygon3d : public Drawable { + public: + using AlignedEigenVectors = + std::vector>; + DrawablePolygon3d(const AlignedEigenVectors& polygon, float height, + const Eigen::Vector3f& color) + : polygon_{polygon}, height_{height}, color_{color} {} + + void Draw() const override; + static DrawablePolygon3d::UniquePtr Create( + const AlignedEigenVectors& polygon, float height, + const Eigen::Vector3f& color = Eigen::Vector3f(1.0f, 0.5f, 0.2f)) { + return mem_utils::make_unique( + DrawablePolygon3d(polygon, height, color)); + } + + ~DrawablePolygon3d() override {} + + private: + AlignedEigenVectors polygon_; + float height_; + Eigen::Vector3f color_; +}; + +} // namespace depth_clustering + +#endif // SRC_QT_DRAWABLES_DRAWABLE_POLYGON3D_H_ diff --git a/src/qt/drawables/object_painter.cpp b/src/qt/drawables/object_painter.cpp new file mode 100644 index 0000000..016d1b9 --- /dev/null +++ b/src/qt/drawables/object_painter.cpp @@ -0,0 +1,87 @@ +// Copyright Igor Bogoslavskyi, year 2017. +// In case of any problems with the code please contact me. +// Email: igor.bogoslavskyi@uni-bonn.de. + +#include "./object_painter.h" + +namespace depth_clustering { + +void ObjectPainter::OnNewObjectReceived( + const std::unordered_map& clouds, int) { + if (!viewer_) { + return; + } + Timer timer; + for (const auto& kv : clouds) { + const auto& cluster = kv.second; + Drawable::UniquePtr drawable{nullptr}; + switch (outline_type_) { + case OutlineType::kBox: + drawable = CreateDrawableCube(cluster); + break; + case OutlineType::kPolygon3d: + drawable = CreateDrawablePolygon3d(cluster); + break; + } + if (drawable) { + viewer_->AddDrawable(std::move(drawable)); + } + } + fprintf(stderr, "[TIMING]: Adding all boxes took %lu us\n", + timer.measure(Timer::Units::Micro)); + viewer_->update(); + fprintf(stderr, "[TIMING]: Viewer updated in %lu us\n", + timer.measure(Timer::Units::Micro)); +} + +Drawable::UniquePtr ObjectPainter::CreateDrawableCube( + const depth_clustering::Cloud& cloud) { + Eigen::Vector3f center = Eigen::Vector3f::Zero(); + Eigen::Vector3f extent = Eigen::Vector3f::Zero(); + Eigen::Vector3f max_point(std::numeric_limits::lowest(), + std::numeric_limits::lowest(), + std::numeric_limits::lowest()); + Eigen::Vector3f min_point(std::numeric_limits::max(), + std::numeric_limits::max(), + std::numeric_limits::max()); + for (const auto& point : cloud.points()) { + center = center + point.AsEigenVector(); + min_point << std::min(min_point.x(), point.x()), + std::min(min_point.y(), point.y()), std::min(min_point.z(), point.z()); + max_point << std::max(max_point.x(), point.x()), + std::max(max_point.y(), point.y()), std::max(max_point.z(), point.z()); + } + center /= cloud.size(); + if (min_point.x() < max_point.x()) { + extent = max_point - min_point; + } + return DrawableCube::Create(center, extent); +} + +Drawable::UniquePtr ObjectPainter::CreateDrawablePolygon3d( + const depth_clustering::Cloud& cloud) { + float min_z{std::numeric_limits::max()}; + float max_z{std::numeric_limits::lowest()}; + std::vector cv_points; + cv_points.reserve(cloud.size()); + std::vector hull_indices; + for (const auto& point : cloud.points()) { + cv_points.emplace_back(cv::Point2f{point.x(), point.y()}); + min_z = std::min(min_z, point.z()); + max_z = std::max(max_z, point.z()); + } + cv::convexHull(cv_points, hull_indices); + DrawablePolygon3d::AlignedEigenVectors hull; + hull.reserve(cloud.size()); + for (int index : hull_indices) { + const auto& cv_point = cv_points[index]; + hull.emplace_back(cv_point.x, cv_point.y, min_z); + } + const float diff_z = max_z - min_z; + if (diff_z < 0.3) { + return nullptr; + } + return DrawablePolygon3d::Create(hull, diff_z); +} + +} // namespace depth_clustering diff --git a/src/qt/drawables/object_painter.h b/src/qt/drawables/object_painter.h index 9b294e5..a4818f4 100644 --- a/src/qt/drawables/object_painter.h +++ b/src/qt/drawables/object_painter.h @@ -5,7 +5,11 @@ #ifndef SRC_QT_DRAWABLES_OBJECT_PAINTER_H_ #define SRC_QT_DRAWABLES_OBJECT_PAINTER_H_ -#include +#include "communication/abstract_client.h" +#include "qt/drawables/drawable_cube.h" +#include "qt/drawables/drawable_polygon3d.h" +#include "qt/viewer/viewer.h" + #include #include @@ -14,8 +18,9 @@ #include #include -#include "qt/drawables/drawable_cube.h" -#include "qt/viewer/viewer.h" +#include + +namespace depth_clustering { class ObjectPainter : public depth_clustering::AbstractClient< @@ -24,45 +29,25 @@ class ObjectPainter using Timer = depth_clustering::time_utils::Timer; public: - void OnNewObjectReceived(const std::unordered_map& clouds, - int client_id) override { - if (!_viewer) { return; } - Timer timer; - for (const auto& kv : clouds) { - const auto& cluster = kv.second; - Eigen::Vector3f center = Eigen::Vector3f::Zero(); - Eigen::Vector3f extent = Eigen::Vector3f::Zero(); - Eigen::Vector3f max_point(std::numeric_limits::lowest(), - std::numeric_limits::lowest(), - std::numeric_limits::lowest()); - Eigen::Vector3f min_point(std::numeric_limits::max(), - std::numeric_limits::max(), - std::numeric_limits::max()); - for (const auto& point : cluster.points()) { - center = center + point.AsEigenVector(); - min_point << std::min(min_point.x(), point.x()), - std::min(min_point.y(), point.y()), - std::min(min_point.z(), point.z()); - max_point << std::max(max_point.x(), point.x()), - std::max(max_point.y(), point.y()), - std::max(max_point.z(), point.z()); - } - center /= cluster.size(); - if (min_point.x() < max_point.x()) { extent = max_point - min_point; } - _viewer->AddDrawable(DrawableCube::Create(center, extent)); - } - fprintf(stderr, "[TIMING]: Adding all boxes took %lu us\n", - timer.measure(Timer::Units::Micro)); - _viewer->update(); - fprintf(stderr, "[TIMING]: Viewer updated in %lu us\n", - timer.measure(Timer::Units::Micro)); - } + enum class OutlineType { kBox, kPolygon3d }; + + explicit ObjectPainter(Viewer* viewer, OutlineType outline_type) + : viewer_{viewer}, outline_type_{outline_type} {} - explicit ObjectPainter(Viewer* viewer) : _viewer(viewer) {} - virtual ~ObjectPainter() {} + void OnNewObjectReceived(const std::unordered_map& clouds, + int id) override; private: - Viewer* _viewer = nullptr; + static Drawable::UniquePtr CreateDrawableCube( + const depth_clustering::Cloud& cloud); + + static Drawable::UniquePtr CreateDrawablePolygon3d( + const depth_clustering::Cloud& cloud); + + Viewer* viewer_{nullptr}; + OutlineType outline_type_{OutlineType::kBox}; }; +} // namespace depth_clustering + #endif // SRC_QT_DRAWABLES_OBJECT_PAINTER_H_ diff --git a/src/qt/utils/utils.cpp b/src/qt/utils/utils.cpp index 778690c..1761de3 100644 --- a/src/qt/utils/utils.cpp +++ b/src/qt/utils/utils.cpp @@ -4,9 +4,9 @@ #include "./utils.h" +#include #include #include -#include #if PCL_FOUND #include @@ -14,10 +14,10 @@ #endif // PCL_FOUND using depth_clustering::Cloud; -using depth_clustering::ProjectionParams; using depth_clustering::MatFromDepthPng; -using depth_clustering::ReadKittiCloudTxt; +using depth_clustering::ProjectionParams; using depth_clustering::ReadKittiCloud; +using depth_clustering::ReadKittiCloudTxt; QString appendPaths(const QString &path1, const QString &path2) { return QDir::cleanPath(path1 + QDir::separator() + path2); @@ -56,12 +56,12 @@ Cloud::Ptr CloudFromFile(const std::string &file_name, QString name = fi.fileName(); Cloud::Ptr cloud = nullptr; if (name.endsWith(".pcd")) { - #if PCL_FOUND +#if PCL_FOUND pcl::PointCloud pcl_cloud; pcl::io::loadPCDFile(file_name, pcl_cloud); cloud = Cloud::FromPcl(pcl_cloud); cloud->InitProjection(proj_params); - #endif // PCL_FOUND +#endif // PCL_FOUND } else if (name.endsWith(".png") || name.endsWith(".exr")) { cloud = Cloud::FromImage(MatFromDepthPng(file_name), proj_params); } else if (name.endsWith(".txt")) { diff --git a/src/qt/utils/utils.h b/src/qt/utils/utils.h index 85a2745..6385427 100644 --- a/src/qt/utils/utils.h +++ b/src/qt/utils/utils.h @@ -11,8 +11,8 @@ #include -#include #include +#include namespace dc = depth_clustering; diff --git a/src/qt/viewer/viewer.cpp b/src/qt/viewer/viewer.cpp index a62122d..8245977 100644 --- a/src/qt/viewer/viewer.cpp +++ b/src/qt/viewer/viewer.cpp @@ -4,8 +4,8 @@ #include "./viewer.h" -using std::mutex; using std::lock_guard; +using std::mutex; void Viewer::AddDrawable(Drawable::Ptr drawable) { lock_guard guard(_cloud_mutex); diff --git a/src/qt/widgets/opengl_folder_player.cpp b/src/qt/widgets/opengl_folder_player.cpp index 35538ba..ceacf0f 100644 --- a/src/qt/widgets/opengl_folder_player.cpp +++ b/src/qt/widgets/opengl_folder_player.cpp @@ -14,7 +14,6 @@ #include #include #include -#include #if PCL_FOUND #include @@ -25,6 +24,7 @@ #include "qt/drawables/drawable_cloud.h" #include "qt/drawables/drawable_cube.h" +#include "qt/drawables/object_painter.h" #include "qt/utils/utils.h" #include "qt/widgets/ui_opengl_folder_player.h" @@ -40,6 +40,7 @@ using depth_clustering::FolderReader; using depth_clustering::ImageBasedClusterer; using depth_clustering::LinearImageLabeler; using depth_clustering::MatFromDepthPng; +using depth_clustering::ObjectPainter; using depth_clustering::ProjectionParams; using depth_clustering::Radians; using depth_clustering::ReadKittiCloud; @@ -97,7 +98,8 @@ OpenGlFolderPlayer::OpenGlFolderPlayer(QWidget *parent) ui->gfx_labels->setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); - _painter.reset(new ObjectPainter(_viewer)); + _painter.reset( + new ObjectPainter{_viewer, ObjectPainter::OutlineType::kPolygon3d}); this->onSegmentationParamUpdate(); } @@ -111,8 +113,7 @@ void OpenGlFolderPlayer::onPlayAllClouds() { qDebug() << "All clouds shown!"; } -void OpenGlFolderPlayer::OnNewObjectReceived(const cv::Mat &image, - int client_id) { +void OpenGlFolderPlayer::OnNewObjectReceived(const cv::Mat &image, int) { QImage qimage; fprintf(stderr, "[INFO] Received Mat with type: %d\n", image.type()); switch (image.type()) { diff --git a/src/qt/widgets/opengl_folder_player.h b/src/qt/widgets/opengl_folder_player.h index 0f6d7d2..736335e 100644 --- a/src/qt/widgets/opengl_folder_player.h +++ b/src/qt/widgets/opengl_folder_player.h @@ -60,7 +60,7 @@ class OpenGlFolderPlayer : public BaseViewerWidget, _clusterer = nullptr; std::unique_ptr _ground_rem = nullptr; - std::unique_ptr _painter = nullptr; + std::unique_ptr _painter = nullptr; cv::Mat _current_full_depth_image; depth_clustering::Cloud::Ptr _cloud; diff --git a/src/visualization/visualizer.cpp b/src/visualization/visualizer.cpp index 9a428bf..fa215c3 100644 --- a/src/visualization/visualizer.cpp +++ b/src/visualization/visualizer.cpp @@ -24,18 +24,18 @@ namespace depth_clustering { -using std::string; -using std::vector; using std::array; +using std::string; using std::to_string; +using std::vector; +using std::lock_guard; using std::map; using std::mutex; using std::string; -using std::vector; using std::thread; -using std::lock_guard; using std::unordered_map; +using std::vector; static vector> COLORS;