FeatureLearningWidgetController.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 VisionX::gui-plugins::FeatureLearningWidgetController
17 * @author Markus Grotz ( markus dot grotz at 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#ifndef _ARMARX_VisionX_FeatureLearning_WidgetController_H
24#define _ARMARX_VisionX_FeatureLearning_WidgetController_H
25
26#include <math.h>
27
28#include <QDir>
29#include <QFileDialog>
30#include <QMessageBox>
31#include <QSettings>
32
33#include <Eigen/Core>
34
37
41
43#include <VisionX/gui-plugins/FeatureLearning/ui_FeatureLearningWidget.h>
46
47#include <Features/HarrisSIFTFeatures/HarrisSIFTFeatureCalculator.h>
48#include <Features/SIFTFeatures/SIFTFeatureEntry.h>
49#include <Math/FloatMatrix.h>
50#include <Math/LinearAlgebra.h>
51#include <TexturedRecognition/TexturedFeatureSet.h>
52
53namespace armarx
54{
55
56 //class FeatureLearningObjectChooserWidget;
57
58 /**
59 \page VisionX-GuiPlugins-FeatureLearning FeatureLearning
60 \brief The FeatureLearning allows connecting to ArmarX ImageProviders and extract features from their images.
61
62 \image html FeatureLearning.png
63 The user can connect and disconnect ImageProviders easily. By clicking on the image, a region can be chosen. SIFT features are calculated within the region. After features have been added to the selection, they can be saved to a file. Additionally, the features can be saved to an object in the PriorMemory, if it is available. Loading from the memory or a file is also supported.
64
65 API Documentation \ref FeatureLearningWidgetController
66
67 \see FeatureLearningGuiPlugin
68 */
69
70 /**
71 * \class FeatureLearningWidgetController
72 * \brief FeatureLearningWidgetController brief one line description
73 *
74 * Detailed description
75 */
77 public armarx::ArmarXComponentWidgetControllerTemplate<FeatureLearningWidgetController>,
79 {
80 Q_OBJECT
81
82 public:
83 /**
84 * Controller Constructor
85 */
87
88 /**
89 * Controller destructor
90 */
92
93 /**
94 * @see ArmarXWidgetController::loadSettings()
95 */
96 virtual void loadSettings(QSettings* settings) override;
97
98 /**
99 * @see ArmarXWidgetController::saveSettings()
100 */
101 virtual void saveSettings(QSettings* settings) override;
102
103 /**
104 * Returns the Widget name displayed in the ArmarXGui to create an
105 * instance of this class.
106 */
107 static QString
109 {
110 return "VisionX.FeatureLearning";
111 }
112
113 void reconnect();
114
115 /**
116 * @see visionx::ImageProcessor::onInitImageProcessor()
117 */
118 virtual void onInitImageProcessor() override;
119
120 /**
121 * @see visionx::ImageProcessor::onConnectImageProcessor()
122 */
123 virtual void onConnectImageProcessor() override;
124
125 /**
126 * @see visionx::ImageProcessor::onDisconnectImageProcessor()
127 */
128 virtual void onDisconnectImageProcessor() override;
129
130 /**
131 * @see visionx::ImageProcessor::onExitImageProcessor()
132 */
133 virtual void onExitImageProcessor() override;
134
135 /**
136 * @see visionx::ImageProcessor::process()
137 */
138 virtual void process() override;
139
140 public slots:
141 /* QT slot declarations */
142
143 void addPolygonPoint(int, float x, float y);
144 void connectButtonClicked(bool toggled);
145 void disconnectButtonClicked(bool toggled);
146 void loadFeaturesButtonClicked(bool toggled);
147 void saveFeaturesButtonClicked(bool toggled);
148 void pausePlayButtonClicked(bool toggled);
149 void addFeaturesButtonClicked(bool toggled);
150 void clearFeaturesButtonClicked(bool toggled);
151
152 void thresholdChanged(double threshold);
153 void maxFeaturesChanged(int maxFeatures);
154 void minDistanceChanged(double minDistance);
155 void levelChanged(int level);
156
157 signals:
158 /* QT signal declarations */
159 void imageProviderConnected(bool connected);
160
161 private:
162 /**
163 * Widget Form
164 */
165 Ui::FeatureLearningWidget widget;
166 QWidget* widgetPointer;
167
168 void loadFeatureSet(QString filePath);
169 void saveFeatureSet(QString filePath, float w, float h, float d);
170 void updateFeatures();
171 int addFeatures();
172 void clearFeatures();
173
174 void updateSelection();
175
176 void connectToProvider();
177 void disconnectFromProvider();
178
179 void updatePausePlayButtonText();
180 void updateImageMonitorUI();
181 void updateFeaturesUI();
182
183 static CFloatMatrix* createCuboid(float w, float h, float d);
184 static void addRectangle(CFloatMatrix* object,
185 int& offset,
186 float x1,
187 float y1,
188 float z1,
189 float x2,
190 float y2,
191 float z2,
192 float x3,
193 float y3,
194 float z3,
195 float x4,
196 float y4,
197 float z4,
198 float n1,
199 float n2,
200 float n3);
201 static void addTriangle(CFloatMatrix* object,
202 int& offset,
203 float x1,
204 float y1,
205 float z1,
206 float x2,
207 float y2,
208 float z2,
209 float x3,
210 float y3,
211 float z3,
212 float n1,
213 float n2,
214 float n3);
215
216
217 // provider
218 visionx::ImageProviderInterfacePrx imageProviderPrx;
219 visionx::ImageProviderInfo imageProviderInfo;
220
221
222 SelectableImageViewer* imageViewer;
223
224 int numSelectedPoints;
225
226 CByteImage** cameraImages;
227 CByteImage* visualizationImage;
228 CByteImage* grayImage;
229
230 int numImages;
231
232 bool isPaused;
233
234 std::string imageProviderName;
235
236 CHarrisSIFTFeatureCalculator* featureCalculator;
237 CTexturedFeatureSet* objectFeatureSet;
238 CTexturedFeatureSet* viewFeatureSet;
239
240 bool undistortImages;
241 std::recursive_mutex imageMutex;
242
243 //contains relative position of the mouse clicks on the image
244 Eigen::ArrayX2f points;
245 Mat3d homography;
246
248
249 bool connected;
250 IceUtil::Time timeProvided;
251
252 QSettings mySettings;
253
254 std::mutex featureCalculatorMutex;
255 };
256} // namespace armarx
257
258#endif
#define ARMARXCOMPONENT_IMPORT_EXPORT
void imageProviderConnected(bool connected)
virtual void loadSettings(QSettings *settings) override
virtual void saveSettings(QSettings *settings) override
static QString GetWidgetName()
Returns the Widget name displayed in the ArmarXGui to create an instance of this class.
Widget to conveniently retrieve a proxy instance name of a specific interface type (the template para...
The ImageProcessor class provides an interface for access to ImageProviders via Ice and shared memory...
This file offers overloads of toIce() and fromIce() functions for STL container types.