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 <VisionX/gui-plugins/UserAssistedSegmenterGui/ui_UserAssistedSegmenterGuiWidget.h>
27 
28 #include <Eigen/Dense>
29 
30 #include <pcl/point_cloud.h>
31 #include <pcl/point_types.h>
32 #include <pcl/PointIndices.h>
33 
35 
38 
40 
41 #include <VisionX/interface/components/UserAssistedSegmenter.h>
42 
44 
45 
46 namespace visionx
47 {
48  class UserAssistedSegmenterConfigDialog;
49 
76  public armarx::ArmarXComponentWidgetControllerTemplate<UserAssistedSegmenterGuiWidgetController>,
77  public visionx::UserAssistedSegmenterListener
78  {
79  Q_OBJECT
80 
81  using PointT = pcl::PointXYZRGBL;
82  using PointCloudT = pcl::PointCloud<PointT>;
83 
84 
85  public:
86 
89 
91  virtual ~UserAssistedSegmenterGuiWidgetController() override;
92 
93 
95  virtual void loadSettings(QSettings* settings) override;
96 
98  virtual void saveSettings(QSettings* settings) override;
99 
100 
101  virtual QPointer<QDialog> getConfigDialog(QWidget* parent) override;
102 
103  virtual void configured() override;
104 
105 
107  static QString GetWidgetName();
108 
109 
111  virtual void onInitComponent() override;
112 
114  virtual void onConnectComponent() override;
115 
116 
117  // UserAssistedSegmenterListener interface
118  virtual void reportSegmentation(const visionx::ColoredLabeledPointCloud& pointCloud, const Ice::Current&) override;
119 
120 
121  public slots:
122  /* QT slot declarations */
123 
125  void onNewSourcePointCloud();
126 
127  // Filters
128  void onFilterSmallSegmentsNumEdited();
129  void updateFilters();
130 
131  // Visualization
132  void onRadioButtonShowInputToggled(bool checked);
133  void onRadioButtonShowResultToggle(bool checked);
134 
135  // IDs
136  void onShowIDsToggled(bool checked);
137  void updateSegmentIDs();
138 
139  void clearVisualization();
140 
141  // Grouping
142  void updateUserGroupingRows(int numRows);
143  void onUserGroupingChanged(uint32_t groupID, std::vector<uint32_t> segmentIDs);
144  void onTableGroupingCellChanged(int row, int col);
145 
146  void publishSegmentation();
147 
148 
149  signals:
150  /* QT signal declarations */
151  void newSourcePointCloud();
152 
153 
154  private:
155 
156  static std::vector<armarx::DrawColor> makeColorList();
157 
158 
159  private:
160 
161  void applyFilters(PointCloudT& pointCloud,
162  std::map<uint32_t, pcl::PointIndices>& segmentIndex);
163 
165  void updatePointCloud(const PointCloudT& pointCloud,
166  const std::map<uint32_t, pcl::PointIndices>& segmentIndex);
167 
168  void computeSegmentIndex(const PointCloudT& pointCloud);
169  void computeCenters(const PointCloudT& pointCloud,
170  const std::map<uint32_t, pcl::PointIndices>& segmentIndex);
171 
172  void updateTableOverview();
173  void drawSegmentIDs(bool onlyIfChecked = false);
174  void drawInputPointCloud(bool onlyIfChecked = false);
175  void drawResultPointCloud(bool onlyIfChecked = false);
176 
177  armarx::DrawColor dcolor(std::size_t id) const;
178  QColor qcolor(std::size_t id) const;
179 
180 
181  private:
182 
184  Ui::UserAssistedSegmenterGuiWidget widget;
185  QPointer<UserAssistedSegmenterConfigDialog> configDialog;
186 
187  PointCloudSegmentsTable* segmentsOverviewTable;
188 
189 
190  std::string userAssistedSegmenterProxyName = "UserAssistedSegmenter";
191  std::string userAssistedSegmenterTopicName = "UserAssistedSegmenterUpdates";
192 
193 
195  visionx::UserAssistedSegmenterInterfacePrx segmenterProxy;
196 
197 
198  PointCloudT sourcePointCloud;
199  PointCloudT pointCloud;
200 
201  std::map<uint32_t, pcl::PointIndices> segmentIndex;
202  std::map<uint32_t, Eigen::Vector3f> centers;
203 
204 
205  std::vector<std::vector<std::uint32_t>> userGrouping;
206 
207  std::string layerPointCloud = "UserAssistedSegmenter_PointCloud";
208  std::string layerSegmentIDs = "UserAssistedSegmenter_SegmentIDs";
209 
210  };
211 }
212 
armarx::DebugDrawerTopic
The DebugDrawerTopic wraps a DebugDrawerInterfacePrx and provides a more useful interface than the Ic...
Definition: DebugDrawerTopic.h:152
visionx
ArmarX headers.
Definition: OpenPoseStressTest.h:38
PointCloudSegmentsTable.h
armarx::ArmarXComponentWidgetControllerTemplate
Definition: ArmarXComponentWidgetController.h:69
ArmarXGuiPlugin.h
DebugDrawerTopic.h
ArmarXComponentWidgetController.h
ARMARXCOMPONENT_IMPORT_EXPORT
#define ARMARXCOMPONENT_IMPORT_EXPORT
Definition: ImportExportComponent.h:38
visionx::PointCloudSegmentsTable
Definition: PointCloudSegmentsTable.h:23
visionx::UserAssistedSegmenterGuiWidgetController
UserAssistedSegmenterGuiWidgetController brief one line description.
Definition: UserAssistedSegmenterGuiWidgetController.h:74
UserAssistedSegmenterConfigDialog.h
ImportExportComponent.h