├── .idea
├── ForestMetrics.iml
├── dictionaries
│ └── she397.xml
├── misc.xml
├── modules.xml
├── vcs.xml
└── workspace.xml
├── CMakeLists.txt
├── Doxyfile.in
├── LICENSE
├── README.md
├── Step_1.PNG
├── Step_2.PNG
├── Step_3.PNG
├── Step_4.PNG
├── cmake
└── Modules
│ └── UseDoxygen.cmake
├── data
├── subset1.pcd
├── subset2.pcd
├── subset3.pcd
├── subset4.pcd
├── subset5.pcd
├── subset6.pcd
├── subset7.pcd
└── subset8.pcd
├── gui
├── CMakeLists.txt
├── delineation
│ ├── CMakeLists.txt
│ ├── cluster_list_model.cpp
│ ├── cluster_list_model.h
│ ├── config.cpp
│ ├── config.h
│ ├── delineation.pro
│ ├── graph_building_form.cpp
│ ├── graph_building_form.h
│ ├── graph_building_form.ui
│ ├── main.cpp
│ ├── main_window.cpp
│ ├── main_window.h
│ ├── main_window.ui
│ ├── min_max_widget.cpp
│ ├── min_max_widget.h
│ ├── min_max_widget.ui
│ ├── pipeline.h
│ ├── preprocessing_form.cpp
│ ├── preprocessing_form.h
│ ├── preprocessing_form.ui
│ ├── seed_selection.cpp
│ ├── seed_selection.h
│ ├── seed_selection_form.cpp
│ ├── seed_selection_form.h
│ ├── seed_selection_form.ui
│ ├── segmentation_form.cpp
│ ├── segmentation_form.h
│ ├── segmentation_form.ui
│ ├── status_bar.h
│ ├── trunk_detection_form.cpp
│ ├── trunk_detection_form.h
│ ├── trunk_detection_form.ui
│ └── types.h
└── rws
│ ├── CMakeLists.txt
│ ├── main.cpp
│ ├── main_window.cpp
│ ├── main_window.h
│ ├── main_window.ui
│ ├── rws.pro
│ ├── rws.pro.user
│ ├── seed_selection.cpp
│ └── seed_selection.h
├── include
├── as_range.h
├── conversions.h
├── factory
│ ├── edge_weight_computer_factory.h
│ ├── factory.h
│ ├── graph_builder_factory.h
│ └── graph_factory.h
├── graph
│ ├── common.h
│ ├── edge_weight_computer.h
│ ├── edge_weight_computer_terms.h
│ ├── graph_builder.h
│ ├── impl
│ │ ├── common.hpp
│ │ ├── edge_weight_computer.hpp
│ │ ├── nearest_neighbors_graph_builder.hpp
│ │ └── voxel_grid_graph_builder.hpp
│ ├── nearest_neighbors_graph_builder.h
│ ├── point_cloud_graph.h
│ ├── point_cloud_graph_concept.h
│ ├── utils.h
│ └── voxel_grid_graph_builder.h
├── graph_visualizer.h
├── hungarian
│ └── hungarian.h
├── impl
│ ├── io.hpp
│ ├── octree_pointcloud_adjacency3.hpp
│ ├── octree_pointcloud_adjacency_container2.hpp
│ ├── random_walker.hpp
│ └── random_walker_segmentation.hpp
├── io.h
├── kde.h
├── label_utils.h
├── measure_runtime.h
├── mesh_grid.h
├── random_walker.h
├── random_walker_segmentation.h
├── scaler.h
├── seed_utils.h
├── tree_top_detector.h
└── typedefs.h
├── src
├── create_seeds.cpp
├── hungarian
│ ├── CMakeLists.txt
│ └── hungarian.cpp
├── io.cpp
├── kde.cpp
├── mesh_grid.cpp
├── random_walker_segmentation.cpp
├── random_walker_segmentation_app.cpp
├── segmentation_evaluation.cpp
├── slice.cpp
├── tree_top_detector.cpp
└── view_point_cloud_graph.cpp
└── third-party
├── hungarian-v2.0
├── Assignment.cpp
├── Assignment.h
├── BipartiteGraph.cpp
├── BipartiteGraph.h
├── CmdParser.h
├── Hungarian.cpp
├── Hungarian.h
├── Log
├── Makefile
├── Matrix.h
├── PlotGraph.cpp
├── PlotGraph.h
├── README
├── example.demo
├── main.cpp
└── plot
│ ├── Cgnuplot.cpp
│ ├── Cgnuplot.h
│ ├── Makefile
│ ├── README
│ ├── graph_hungarian.cpp
│ └── graph_hungarian.h
└── tviewer
└── CMakeLists.txt
/.idea/ForestMetrics.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/dictionaries/she397.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | passthrough
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
2 | project(delineation)
3 | find_package(PCL 1.7.2 REQUIRED)
4 | set(CMAKE_BUILD_TYPE "Release")
5 |
6 | option(WITH_QT_GUI "Build Qt GUI application." ON)
7 |
8 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/Modules/" ${CMAKE_MODULE_PATH})
9 |
10 | # set the default path for built executables to the "bin" directory
11 | set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
12 | # set the default path for built libraries to the "lib" directory
13 | set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
14 | # add include folder to the list include directories
15 | include_directories(${PROJECT_SOURCE_DIR}/include)
16 |
17 | add_definitions(-std=c++11)
18 |
19 | if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
20 | add_definitions(-fcolor-diagnostics)
21 | endif ()
22 |
23 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
24 |
25 | #...: enable all but certain warnings
26 | add_definitions(-Wall)
27 | add_definitions(-Wno-unknown-pragmas)
28 | add_definitions(-Wno-deprecated)
29 | add_definitions(-fpermissive)
30 |
31 | # PCL
32 | include_directories(${PCL_INCLUDE_DIRS})
33 | link_directories(${PCL_LIBRARY_DIRS})
34 | add_definitions(${PCL_DEFINITIONS})
35 |
36 | # TViewer
37 | add_subdirectory(third-party/tviewer)
38 | include_directories(${TVIEWER_INCLUDE_DIR})
39 | add_definitions(${TVIEWER_DEFINITIONS})
40 |
41 | # Hungarian
42 | add_subdirectory(src/hungarian)
43 |
44 | add_library(random_walker_segmentation
45 | src/random_walker_segmentation.cpp
46 | )
47 | target_link_libraries(random_walker_segmentation
48 | ${PCL_LIBRARIES}
49 | )
50 | set_target_properties(random_walker_segmentation
51 | PROPERTIES COMPILE_DEFINITIONS "PCL_ONLY_CORE_POINT_TYPES"
52 | )
53 |
54 | add_library(io
55 | src/io.cpp
56 | )
57 | target_link_libraries(io
58 | ${PCL_LIBRARIES}
59 | )
60 |
61 | add_library(kde
62 | src/kde.cpp
63 | )
64 |
65 | add_executable(app_random_walker_segmentation
66 | src/random_walker_segmentation_app.cpp
67 | )
68 | target_link_libraries(app_random_walker_segmentation
69 | ${PCL_LIBRARIES}
70 | ${TVIEWER_LIBRARIES}
71 | random_walker_segmentation
72 | io
73 | )
74 | add_dependencies(app_random_walker_segmentation
75 | tviewer
76 | )
77 |
78 | add_executable(view_point_cloud_graph
79 | src/view_point_cloud_graph.cpp
80 | )
81 | target_link_libraries(view_point_cloud_graph
82 | ${PCL_LIBRARIES}
83 | ${TVIEWER_LIBRARIES}
84 | io
85 | )
86 | add_dependencies(view_point_cloud_graph
87 | tviewer
88 | )
89 |
90 | add_executable(segmentation_evaluation
91 | src/segmentation_evaluation.cpp
92 | )
93 | target_link_libraries(segmentation_evaluation
94 | ${PCL_LIBRARIES}
95 | ${TVIEWER_LIBRARIES}
96 | hungarian
97 | )
98 | add_dependencies(segmentation_evaluation
99 | tviewer
100 | )
101 |
102 | add_executable(create_seeds
103 | src/create_seeds.cpp
104 | )
105 | target_link_libraries(create_seeds
106 | ${PCL_LIBRARIES}
107 | )
108 |
109 | add_executable(slice
110 | src/slice.cpp
111 | )
112 | target_link_libraries(slice
113 | ${PCL_LIBRARIES}
114 | ${TVIEWER_LIBRARIES}
115 | )
116 | add_dependencies(slice
117 | tviewer
118 | )
119 |
120 | if(WITH_QT_GUI)
121 | add_subdirectory(gui)
122 | endif()
123 |
--------------------------------------------------------------------------------
/Step_1.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yurithefury/ForestMetrics/0e5caf54fc02b3264dc46e493a21c9fa45d45f53/Step_1.PNG
--------------------------------------------------------------------------------
/Step_2.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yurithefury/ForestMetrics/0e5caf54fc02b3264dc46e493a21c9fa45d45f53/Step_2.PNG
--------------------------------------------------------------------------------
/Step_3.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yurithefury/ForestMetrics/0e5caf54fc02b3264dc46e493a21c9fa45d45f53/Step_3.PNG
--------------------------------------------------------------------------------
/Step_4.PNG:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/yurithefury/ForestMetrics/0e5caf54fc02b3264dc46e493a21c9fa45d45f53/Step_4.PNG
--------------------------------------------------------------------------------
/cmake/Modules/UseDoxygen.cmake:
--------------------------------------------------------------------------------
1 | # - Run Doxygen
2 | #
3 | # Adds a doxygen target that runs doxygen to generate the html
4 | # and optionally the LaTeX API documentation.
5 | # The doxygen target is added to the doc target as a dependency.
6 | # i.e.: the API documentation is built with:
7 | # make doc
8 | #
9 | # USAGE: GLOBAL INSTALL
10 | #
11 | # Install it with:
12 | # cmake ./ && sudo make install
13 | # Add the following to the CMakeLists.txt of your project:
14 | # include(UseDoxygen OPTIONAL)
15 | # Optionally copy Doxyfile.in in the directory of CMakeLists.txt and edit it.
16 | #
17 | # USAGE: INCLUDE IN PROJECT
18 | #
19 | # set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
20 | # include(UseDoxygen)
21 | # Add the Doxyfile.in and UseDoxygen.cmake files to the projects source directory.
22 | #
23 | #
24 | # Variables you may define are:
25 | # DOXYFILE_SOURCE_DIR - Path where the Doxygen input files are.
26 | # Defaults to the current source and binary directory.
27 | # DOXYFILE_OUTPUT_DIR - Path where the Doxygen output is stored. Defaults to "doc".
28 | #
29 | # DOXYFILE_LATEX - Set to "NO" if you do not want the LaTeX documentation
30 | # to be built.
31 | # DOXYFILE_LATEX_DIR - Directory relative to DOXYFILE_OUTPUT_DIR where
32 | # the Doxygen LaTeX output is stored. Defaults to "latex".
33 | #
34 | # DOXYFILE_HTML_DIR - Directory relative to DOXYFILE_OUTPUT_DIR where
35 | # the Doxygen html output is stored. Defaults to "html".
36 | #
37 |
38 | #
39 | # Copyright (c) 2009, 2010 Tobias Rautenkranz
40 | #
41 | # Redistribution and use is allowed according to the terms of the New
42 | # BSD license.
43 | # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
44 | #
45 |
46 | macro(usedoxygen_set_default name value)
47 | if(NOT DEFINED "${name}")
48 | set("${name}" "${value}")
49 | endif()
50 | endmacro()
51 |
52 | find_package(Doxygen)
53 |
54 | if(DOXYGEN_FOUND)
55 | find_file(DOXYFILE_IN "Doxyfile.in"
56 | PATHS "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_ROOT}/Modules/"
57 | NO_DEFAULT_PATH)
58 | set(DOXYFILE "${CMAKE_CURRENT_BINARY_DIR}/Doxyfile")
59 | include(FindPackageHandleStandardArgs)
60 | find_package_handle_standard_args(DOXYFILE_IN DEFAULT_MSG "DOXYFILE_IN")
61 | endif()
62 |
63 | if(DOXYGEN_FOUND AND DOXYFILE_IN_FOUND)
64 | usedoxygen_set_default(DOXYFILE_OUTPUT_DIR "${CMAKE_CURRENT_BINARY_DIR}/doc")
65 | usedoxygen_set_default(DOXYFILE_HTML_DIR "html")
66 | usedoxygen_set_default(DOXYFILE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
67 |
68 | set_property(DIRECTORY APPEND PROPERTY
69 | ADDITIONAL_MAKE_CLEAN_FILES
70 | "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_HTML_DIR}")
71 |
72 | add_custom_target(tocsdoxygen
73 | COMMAND ${DOXYGEN_EXECUTABLE}
74 | ${DOXYFILE}
75 | COMMENT "Writing documentation to ${DOXYFILE_OUTPUT_DIR}..."
76 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR})
77 |
78 | ## LaTeX
79 | set(DOXYFILE_PDFLATEX "NO")
80 | set(DOXYFILE_DOT "NO")
81 |
82 | find_package(LATEX)
83 | find_program(MAKE_PROGRAM make)
84 | if(LATEX_COMPILER AND MAKEINDEX_COMPILER AND MAKE_PROGRAM AND
85 | (NOT DEFINED DOXYFILE_LATEX OR DOXYFILE_LATEX STREQUAL "YES"))
86 | set(DOXYFILE_LATEX "YES")
87 | usedoxygen_set_default(DOXYFILE_LATEX_DIR "latex")
88 |
89 | set_property(DIRECTORY APPEND PROPERTY
90 | ADDITIONAL_MAKE_CLEAN_FILES
91 | "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_LATEX_DIR}")
92 |
93 | if(PDFLATEX_COMPILER)
94 | set(DOXYFILE_PDFLATEX "YES")
95 | endif()
96 | if(DOXYGEN_DOT_EXECUTABLE)
97 | set(DOXYFILE_DOT "YES")
98 | endif()
99 |
100 | add_custom_command(TARGET tocsdoxygen
101 | POST_BUILD
102 | COMMAND ${MAKE_PROGRAM}
103 | COMMENT "Running LaTeX for Doxygen documentation in ${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_LATEX_DIR}..."
104 | WORKING_DIRECTORY "${DOXYFILE_OUTPUT_DIR}/${DOXYFILE_LATEX_DIR}")
105 | else()
106 | set(DOXYGEN_LATEX "NO")
107 | endif()
108 |
109 |
110 | configure_file(${DOXYFILE_IN} Doxyfile IMMEDIATE @ONLY)
111 |
112 | get_target_property(DOC_TARGET doc TYPE)
113 | if(NOT DOC_TARGET)
114 | add_custom_target(doc)
115 | endif()
116 |
117 | add_dependencies(doc tocsdoxygen)
118 | endif()
119 |
--------------------------------------------------------------------------------
/gui/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | if(VTK_VERSION VERSION_LESS "6.0")
2 | message(STATUS "VTK version is 5 or below, therefore using Qt4")
3 | find_package(Qt4 REQUIRED)
4 | include(${QT_USE_FILE})
5 | include(${VTK_USE_FILE})
6 | macro(qt_wrap_ui)
7 | qt4_wrap_ui(${ARGN})
8 | endmacro()
9 | list(APPEND VTK_LIBRARIES QVTK)
10 | else()
11 | message(STATUS "VTK version is 6 or above, therefore using Qt5")
12 | find_package(Qt5Widgets REQUIRED)
13 | macro(qt_wrap_ui)
14 | qt5_wrap_ui(${ARGN})
15 | endmacro()
16 | set(QT_LIBRARIES ${Qt5Widgets_LIBRARIES})
17 | endif()
18 |
19 | # Find includes in corresponding build directories
20 | set(CMAKE_INCLUDE_CURRENT_DIR ON)
21 | # Instruct CMake to run moc automatically when needed.
22 | set(CMAKE_AUTOMOC ON)
23 | add_definitions(${QT_DEFINITIONS} "-DQT_NO_KEYWORDS")
24 |
25 | macro(ADD_QT_FORM _prefix _name)
26 | list(APPEND ${_prefix}_SOURCES ${_name}.cpp)
27 | list(APPEND ${_prefix}_HEADERS ${_name}.h)
28 | list(APPEND ${_prefix}_FORMS ${_name}.ui)
29 | endmacro(ADD_QT_FORM)
30 |
31 | add_subdirectory(rws)
32 | add_subdirectory(delineation)
33 |
--------------------------------------------------------------------------------
/gui/delineation/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | ADD_QT_FORM(GUI_DELINEATION main_window)
2 | ADD_QT_FORM(GUI_DELINEATION preprocessing_form)
3 | ADD_QT_FORM(GUI_DELINEATION trunk_detection_form)
4 | ADD_QT_FORM(GUI_DELINEATION graph_building_form)
5 | ADD_QT_FORM(GUI_DELINEATION seed_selection_form)
6 | ADD_QT_FORM(GUI_DELINEATION segmentation_form)
7 | ADD_QT_FORM(GUI_DELINEATION min_max_widget)
8 |
9 | list(APPEND GUI_DELINEATION_SOURCES main.cpp
10 | seed_selection.cpp
11 | cluster_list_model.cpp)
12 | list(APPEND GUI_DELINEATION_HEADERS seed_selection.h
13 | cluster_list_model.h)
14 |
15 | qt_wrap_ui(GUI_DELINEATION_FORMS_HEADERS ${GUI_DELINEATION_FORMS})
16 |
17 | add_executable(gui_delineation
18 | config.cpp
19 | ${PROJECT_SOURCE_DIR}/src/mesh_grid.cpp
20 | ${PROJECT_SOURCE_DIR}/src/tree_top_detector.cpp
21 | ${GUI_DELINEATION_SOURCES}
22 | ${GUI_DELINEATION_FORMS_HEADERS}
23 | )
24 | target_link_libraries(gui_delineation
25 | io
26 | kde
27 | random_walker_segmentation
28 | ${QT_LIBRARIES}
29 | ${PCL_LIBRARIES}
30 | ${VTK_LIBRARIES}
31 | ${TVIEWER_LIBRARIES}
32 | )
33 | add_dependencies(gui_delineation
34 | tviewer
35 | )
36 |
--------------------------------------------------------------------------------
/gui/delineation/cluster_list_model.cpp:
--------------------------------------------------------------------------------
1 | #include
2 | #include
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #include "cluster_list_model.h"
10 |
11 | ClusterListModel::ClusterListModel (QObject* parent)
12 | : QAbstractListModel (parent)
13 | , cloud_ (new PointCloud)
14 | {
15 | }
16 |
17 | ClusterListModel::~ClusterListModel ()
18 | {
19 | }
20 |
21 | int
22 | ClusterListModel::rowCount (const QModelIndex&) const
23 | {
24 | return cluster_indices_.size ();
25 | }
26 |
27 | QVariant
28 | ClusterListModel::data (const QModelIndex& index, int role) const
29 | {
30 | if (role == Qt::DisplayRole)
31 | {
32 | return QString ("%1").arg (cluster_indices_[index.row ()].indices.size ());
33 | }
34 | if (role == Qt::BackgroundRole)
35 | {
36 | auto c = pcl::GlasbeyLUT::at (index.row () % pcl::GlasbeyLUT::size ());
37 | return QBrush (QColor (c.r, c.g, c.b));
38 | }
39 | return QVariant ();
40 | }
41 |
42 | QModelIndex
43 | ClusterListModel::getIndexFromPointIndex (int index)
44 | {
45 | for (size_t i = 0; i < cluster_indices_.size (); ++i)
46 | {
47 | index -= static_cast (cluster_indices_[i].indices.size ());
48 | if (index < 0)
49 | return createIndex (i, 0);
50 | }
51 | return QModelIndex ();
52 | }
53 |
54 | void
55 | ClusterListModel::setClusterList (const PointCloud::ConstPtr& cloud,
56 | const std::vector& cluster_indices)
57 | {
58 | auto old_size = cluster_indices_.size ();
59 | auto new_size = cluster_indices.size ();
60 | if (new_size > old_size)
61 | {
62 | beginInsertRows (QModelIndex (), old_size, new_size - 1);
63 | endInsertRows ();
64 | }
65 | else if (new_size < old_size)
66 | {
67 | beginRemoveRows (QModelIndex (), new_size, old_size - 1);
68 | endRemoveRows ();
69 | }
70 | cloud_ = cloud;
71 | cluster_indices_ = cluster_indices;
72 | }
73 |
74 | pcl::PointCloud::Ptr
75 | ClusterListModel::getPointCloudForVisualization ()
76 | {
77 | pcl::PointCloud::Ptr cloud (new pcl::PointCloud);
78 | for (size_t i = 0; i < cluster_indices_.size (); ++i)
79 | {
80 | uint8_t alpha = 0xFF;
81 | if (current_selection_.size () != 0 && current_selection_.count (i + 1) == 0)
82 | alpha = 0x3F;
83 | for (const auto& index : cluster_indices_[i].indices)
84 | {
85 | pcl::PointXYZRGBA p;
86 | pcl::copyPoint (cloud_->at (index), p);
87 | p.rgba = pcl::GlasbeyLUT::at (i % pcl::GlasbeyLUT::size ()).rgba;
88 | p.a = alpha;
89 | cloud->push_back (p);
90 | }
91 | }
92 | return cloud;
93 | }
94 |
95 | void
96 | ClusterListModel::currentChanged (const QItemSelection& current, const QItemSelection& previous)
97 | {
98 | for (size_t i = 0; i < current.indexes ().size (); ++i)
99 | current_selection_.insert (current.indexes ().at (i).row () + 1);
100 | for (size_t i = 0; i < previous.indexes ().size (); ++i)
101 | current_selection_.erase (previous.indexes ().at (i).row () + 1);
102 | selectionChanged ();
103 | }
104 |
105 |
--------------------------------------------------------------------------------
/gui/delineation/cluster_list_model.h:
--------------------------------------------------------------------------------
1 | #ifndef CLUSTER_LIST_MODEL_H
2 | #define CLUSTER_LIST_MODEL_H
3 |
4 | #include
5 |
6 | #include
7 | #include
8 |
9 | #include
10 | #include
11 |
12 | #ifndef Q_MOC_RUN
13 | #include "types.h"
14 | #endif
15 |
16 | class ClusterListModel : public QAbstractListModel
17 | {
18 |
19 | Q_OBJECT
20 |
21 | public:
22 |
23 | typedef boost::shared_ptr Ptr;
24 |
25 | ClusterListModel (QObject* parent = 0);
26 |
27 | ~ClusterListModel ();
28 |
29 | virtual int
30 | rowCount (const QModelIndex&) const override;
31 |
32 | virtual QVariant
33 | data (const QModelIndex& index, int role) const override;
34 |
35 | QModelIndex
36 | getIndexFromPointIndex (int index);
37 |
38 | void
39 | setClusterList (const PointCloud::ConstPtr& cloud,
40 | const std::vector& cluster_indices);
41 |
42 | pcl::PointCloud::Ptr
43 | getPointCloudForVisualization ();
44 |
45 | public Q_SLOTS:
46 |
47 | void
48 | currentChanged (const QItemSelection& current, const QItemSelection& previous);
49 |
50 | Q_SIGNALS:
51 |
52 | //void
53 | //pointPicked ();
54 |
55 | void
56 | selectionChanged ();
57 |
58 | private:
59 |
60 | PointCloud::ConstPtr cloud_;
61 |
62 | std::vector cluster_indices_;
63 |
64 | std::set current_selection_;
65 |
66 | };
67 |
68 | #endif /* CLUSTER_LIST_MODEL_H */
69 |
70 |
--------------------------------------------------------------------------------
/gui/delineation/config.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #include "config.h"
10 | #include "pipeline.h"
11 | #include "min_max_widget.h"
12 |
13 | Config::Config ()
14 | {
15 | }
16 |
17 | Config::Config (const std::string& filename)
18 | {
19 | boost::property_tree::read_json (filename, pt_);
20 | }
21 |
22 | void
23 | Config::save (const std::string& filename)
24 | {
25 | boost::property_tree::write_json (filename, pt_);
26 | }
27 |
28 | void
29 | Config::put (const std::string& name, pipeline::Stage* stage)
30 | {
31 | section_ = name + ".";
32 | stage->saveConfig (*this);
33 | section_ = "";
34 | }
35 |
36 | void
37 | Config::get (const std::string& name, pipeline::Stage* stage)
38 | {
39 | section_ = name + ".";
40 | stage->loadConfig (*this);
41 | section_ = "";
42 | }
43 |
44 | template <> void
45 | Config::put (const std::string& name, QTabWidget* obj)
46 | {
47 | pt_.put (section_ + name, obj->currentIndex ());
48 | }
49 |
50 | template <> void
51 | Config::get (const std::string& name, QTabWidget* obj, int dflt)
52 | {
53 | obj->setCurrentIndex (pt_.get (section_ + name, dflt));
54 | }
55 |
56 | template <> void
57 | Config::put (const std::string& name, QComboBox* obj)
58 | {
59 | pt_.put (section_ + name, obj->currentIndex ());
60 | }
61 |
62 | template <> void
63 | Config::get (const std::string& name, QComboBox* obj, int dflt)
64 | {
65 | obj->setCurrentIndex (pt_.get (section_ + name, dflt));
66 | }
67 |
68 | template <> void
69 | Config::put (const std::string& name, QDoubleSpinBox* obj)
70 | {
71 | pt_.put (section_ + name, obj->value ());
72 | }
73 |
74 | template <> void
75 | Config::get (const std::string& name, QDoubleSpinBox* obj, double dflt)
76 | {
77 | obj->setValue (pt_.get (section_ + name, dflt));
78 | }
79 |
80 | template <> void
81 | Config::put (const std::string& name, QSpinBox* obj)
82 | {
83 | pt_.put (section_ + name, obj->value ());
84 | }
85 |
86 | template <> void
87 | Config::get (const std::string& name, QSpinBox* obj, int dflt)
88 | {
89 | obj->setValue (pt_.get (section_ + name, dflt));
90 | }
91 |
92 | template <> void
93 | Config::put (const std::string& name, QCheckBox* obj)
94 | {
95 | pt_.put (section_ + name, obj->checkState ());
96 | }
97 |
98 | template <> void
99 | Config::get (const std::string& name, QCheckBox* obj, int dflt)
100 | {
101 | obj->setCheckState (Qt::CheckState (pt_.get (section_ + name, dflt)));
102 | }
103 |
104 | template <> void
105 | Config::put (const std::string& name, MinMaxWidget* obj)
106 | {
107 | pt_.put (section_ + name + ".Min", obj->value ().first);
108 | pt_.put (section_ + name + ".Max", obj->value ().second);
109 | pt_.put (section_ + name + ".RangeMin", obj->range ().first);
110 | pt_.put (section_ + name + ".RangeMax", obj->range ().second);
111 | }
112 |
113 | template <> void
114 | Config::get (const std::string& name, MinMaxWidget* obj)
115 | {
116 | obj->setRange (pt_.get (section_ + name + ".Min", 0.000),
117 | pt_.get (section_ + name + ".Max", 0.000));
118 | obj->setValue (pt_.get (section_ + name + ".RangeMin", 0.000),
119 | pt_.get (section_ + name + ".RangeMax", 0.000));
120 | }
121 |
122 |
--------------------------------------------------------------------------------
/gui/delineation/config.h:
--------------------------------------------------------------------------------
1 | #ifndef GUI_DELINEATION_CONFIG_H
2 | #define GUI_DELINEATION_CONFIG_H
3 |
4 | #include
5 |
6 | #include
7 |
8 | namespace pipeline
9 | {
10 | class Stage;
11 | }
12 |
13 | class Config
14 | {
15 |
16 | public:
17 |
18 | /// Constructor that creates an empty config.
19 | Config ();
20 |
21 | /// Constructor that loads existing config.
22 | Config (const std::string& filename);
23 |
24 | void
25 | save (const std::string& filename);
26 |
27 | void
28 | put (const std::string& name, pipeline::Stage* obj);
29 |
30 | void
31 | get (const std::string& name, pipeline::Stage* obj);
32 |
33 | template void
34 | put (const std::string& name, T* obj);
35 |
36 | template void
37 | get (const std::string& name, T* obj);
38 |
39 | template void
40 | get (const std::string& name, T* obj, M dflt);
41 |
42 | private:
43 |
44 | boost::property_tree::ptree pt_;
45 | std::string section_;
46 |
47 | };
48 |
49 | #endif /* GUI_DELINEATION_CONFIG_H */
50 |
51 |
--------------------------------------------------------------------------------
/gui/delineation/delineation.pro:
--------------------------------------------------------------------------------
1 | #-------------------------------------------------
2 | #
3 | # Project created by QtCreator 2014-08-21T10:59:23
4 | #
5 | #-------------------------------------------------
6 |
7 | QT += core gui
8 |
9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
10 |
11 | TARGET = gui
12 | TEMPLATE = app
13 |
14 | SOURCES += main.cpp\
15 | mainwindow.cpp \
16 | seed_selection.cpp \
17 | main_window.cpp \
18 | preprocessing_form.cpp \
19 | trunk_detection_form.cpp \
20 | graph_building_form.cpp \
21 | seed_selection_form.cpp \
22 | segmentation_form.cpp \
23 | min_max_widget.cpp
24 |
25 | HEADERS += mainwindow.h \
26 | seed_selection.h \
27 | main_window.h \
28 | preprocessing_form.h \
29 | trunk_detection_form.h \
30 | graph_building_form.h \
31 | seed_selection_form.h \
32 | segmentation_form.h \
33 | min_max_widget.h
34 |
35 | FORMS += main_window.ui \
36 | preprocessing_form.ui \
37 | trunk_detection_form.ui \
38 | graph_building_form.ui \
39 | seed_selection_form.ui \
40 | segmentation_form.ui \
41 | min_max_widget.ui
42 |
--------------------------------------------------------------------------------
/gui/delineation/graph_building_form.h:
--------------------------------------------------------------------------------
1 | #ifndef GUI_DELINEATION_GRAPH_BUILDING_FORM_H
2 | #define GUI_DELINEATION_GRAPH_BUILDING_FORM_H
3 |
4 | #include
5 |
6 | #include
7 | #include
8 |
9 | #ifndef Q_MOC_RUN
10 | #include "types.h"
11 | #include "pipeline.h"
12 | #endif
13 |
14 | namespace Ui
15 | {
16 | class GraphBuildingForm;
17 | }
18 |
19 | class GraphBuildingForm : public QWidget, public pipeline::Stage
20 | {
21 |
22 | Q_OBJECT
23 |
24 | public:
25 |
26 | explicit GraphBuildingForm (QWidget* parent = 0);
27 |
28 | ~GraphBuildingForm ();
29 |
30 | virtual void
31 | loadConfig (Config& config) override;
32 |
33 | virtual void
34 | saveConfig (Config& config) const override;
35 |
36 | virtual void
37 | enter () override;
38 |
39 | virtual void
40 | leave () override;
41 |
42 | void
43 | execute ();
44 |
45 | public Q_SLOTS:
46 |
47 | void
48 | onGraphBuilderEditingFinished ();
49 |
50 | void
51 | onEdgeWeightsEditingFinished ();
52 |
53 | void
54 | onUpdateButtonClicked ();
55 |
56 | private:
57 |
58 | void
59 | buildGraph ();
60 |
61 | void
62 | computeEdgeWeights ();
63 |
64 | pipeline::Input input_cloud_ = "LoadedCloud";
65 | pipeline::Input> input_indices_ = "FilteredIndices";
66 | pipeline::Output output_graph_ = "Graph";
67 |
68 | Ui::GraphBuildingForm* ui_;
69 |
70 | GraphPtr graph_;
71 |
72 | PointCloud::Ptr vertices_;
73 |
74 | vtkSmartPointer edges_;
75 |
76 | };
77 |
78 | #endif // GUI_DELINEATION_GRAPH_BUILDING_FORM_H
79 |
--------------------------------------------------------------------------------
/gui/delineation/main.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | #include "main_window.h"
8 |
9 | int
10 | main (int argc, char** argv)
11 | {
12 | if (argc < 2 || pcl::console::find_switch (argc, argv, "--help"))
13 | {
14 | pcl::console::print_error ("Usage: %s [seeds.pcd]"
15 | , argv[0]);
16 | return (1);
17 | }
18 |
19 | QApplication app (argc, argv);
20 | MainWindow w (argv[1]);
21 |
22 | if (argc > 2)
23 | w.loadSeeds (argv[2]);
24 |
25 | w.show ();
26 | return app.exec ();
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/gui/delineation/main_window.h:
--------------------------------------------------------------------------------
1 | #ifndef MAIN_WINDOW_H
2 | #define MAIN_WINDOW_H
3 |
4 | #include