UserAssistedSegmenterGuiWidgetController.h
Go to the documentation of this file.
1/*
2 * This file is part of ArmarX.
3 *
4 * ArmarX is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
7 *
8 * ArmarX is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *
16 * @package SceneUnderstanding::gui-plugins::UserAssistedSegmenterGuiWidgetController
17 * @author Rainer Kartmann ( rainer dot kartmann at student dot kit dot edu )
18 * @date 2018
19 * @copyright http://www.gnu.org/licenses/gpl-2.0.txt
20 * GNU General Public License
21 */
22
23#pragma once
24
25#include <Eigen/Dense>
26
27#include <pcl/PointIndices.h>
28#include <pcl/point_cloud.h>
29#include <pcl/point_types.h>
30
32
35
37
38#include <VisionX/gui-plugins/UserAssistedSegmenterGui/ui_UserAssistedSegmenterGuiWidget.h>
39#include <VisionX/interface/components/UserAssistedSegmenter.h>
40
43
44namespace visionx
45{
47
48 /**
49 \page VisionX-GuiPlugins-UserAssistedSegmenterGui UserAssistedSegmenterGui
50 \brief The UserAssistedSegmenterGui allows manually grouping segments of
51 an input oversegmentation to objects.
52
53 \image html UserAssistedSegmenterGui.png
54 The user can see the segment IDs of the input oversegmentation and
55 visualize the segments in the Debug Drawer View.
56 The user can then choose the target number of objects and assign each
57 object the segment IDs of segments which are part of this object.
58 Once all objects have been assigned segments, the point cloud can be
59 published. Once publushed, it will be provided at constant frequency.
60
61 API Documentation \ref UserAssistedSegmenterGuiWidgetController
62
63 \see UserAssistedSegmenterGuiGuiPlugin
64 */
65
66 /**
67 * \class UserAssistedSegmenterGuiWidgetController
68 * \brief UserAssistedSegmenterGuiWidgetController brief one line description
69 *
70 * Detailed description
71 */
74 UserAssistedSegmenterGuiWidgetController>,
75 public visionx::UserAssistedSegmenterListener
76 {
77 Q_OBJECT
78
79 using PointT = pcl::PointXYZRGBL;
80 using PointCloudT = pcl::PointCloud<PointT>;
81
82
83 public:
84 /// Controller Constructor
86
87 /// Controller destructor
89
90
91 /// @see ArmarXWidgetController::loadSettings()
92 virtual void loadSettings(QSettings* settings) override;
93
94 /// @see ArmarXWidgetController::saveSettings()
95 virtual void saveSettings(QSettings* settings) override;
96
97
98 virtual QPointer<QDialog> getConfigDialog(QWidget* parent) override;
99
100 virtual void configured() override;
101
102
103 /// Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
104 static QString GetWidgetName();
105
106
107 /// @see armarx::Component::onInitComponent()
108 virtual void onInitComponent() override;
109
110 /// @see armarx::Component::onConnectComponent()
111 virtual void onConnectComponent() override;
112
113
114 // UserAssistedSegmenterListener interface
115 virtual void reportSegmentation(const visionx::ColoredLabeledPointCloud& pointCloud,
116 const Ice::Current&) override;
117
118
119 public slots:
120 /* QT slot declarations */
121
122 /// @brief Handles an incoming segmented point cloud by reportReceivedSegmentation().
124
125 // Filters
127 void updateFilters();
128
129 // Visualization
130 void onRadioButtonShowInputToggled(bool checked);
131 void onRadioButtonShowResultToggle(bool checked);
132
133 // IDs
134 void onShowIDsToggled(bool checked);
135 void updateSegmentIDs();
136
137 void clearVisualization();
138
139 // Grouping
140 void updateUserGroupingRows(int numRows);
141 void onUserGroupingChanged(uint32_t groupID, std::vector<uint32_t> segmentIDs);
142 void onTableGroupingCellChanged(int row, int col);
143
144 void publishSegmentation();
145
146
147 signals:
148 /* QT signal declarations */
150
151
152 private:
153 static std::vector<armarx::DrawColor> makeColorList();
154
155
156 private:
157 void applyFilters(PointCloudT& pointCloud,
158 std::map<uint32_t, pcl::PointIndices>& segmentIndex);
159
160 /// To be called when pointCloud has been modified.
161 void updatePointCloud(const PointCloudT& pointCloud,
162 const std::map<uint32_t, pcl::PointIndices>& segmentIndex);
163
164 void computeSegmentIndex(const PointCloudT& pointCloud);
165 void computeCenters(const PointCloudT& pointCloud,
166 const std::map<uint32_t, pcl::PointIndices>& segmentIndex);
167
168 void updateTableOverview();
169 void drawSegmentIDs(bool onlyIfChecked = false);
170 void drawInputPointCloud(bool onlyIfChecked = false);
171 void drawResultPointCloud(bool onlyIfChecked = false);
172
173 armarx::DrawColor dcolor(std::size_t id) const;
174 QColor qcolor(std::size_t id) const;
175
176
177 private:
178 /// Widget Form
179 Ui::UserAssistedSegmenterGuiWidget widget;
180 QPointer<UserAssistedSegmenterConfigDialog> configDialog;
181
182 PointCloudSegmentsTable* segmentsOverviewTable;
183
184
185 std::string userAssistedSegmenterProxyName = "UserAssistedSegmenter";
186 std::string userAssistedSegmenterTopicName = "UserAssistedSegmenterUpdates";
187
188
190 visionx::UserAssistedSegmenterInterfacePrx segmenterProxy;
191
192
193 PointCloudT sourcePointCloud;
194 PointCloudT pointCloud;
195
196 std::map<uint32_t, pcl::PointIndices> segmentIndex;
197 std::map<uint32_t, Eigen::Vector3f> centers;
198
199
200 std::vector<std::vector<std::uint32_t>> userGrouping;
201
202 std::string layerPointCloud = "UserAssistedSegmenter_PointCloud";
203 std::string layerSegmentIDs = "UserAssistedSegmenter_SegmentIDs";
204 };
205} // namespace visionx
#define ARMARXCOMPONENT_IMPORT_EXPORT
The DebugDrawerTopic wraps a DebugDrawerInterfacePrx and provides a more useful interface than the Ic...
void onNewSourcePointCloud()
Handles an incoming segmented point cloud by reportReceivedSegmentation().
static QString GetWidgetName()
Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
void onUserGroupingChanged(uint32_t groupID, std::vector< uint32_t > segmentIDs)
virtual void configured() override
This function must be implemented by the user, if he supplies a config dialog.
virtual void reportSegmentation(const visionx::ColoredLabeledPointCloud &pointCloud, const Ice::Current &) override
virtual QPointer< QDialog > getConfigDialog(QWidget *parent) override
getConfigDialog returns a pointer to the a configuration widget of this controller.
ArmarX headers.