25 #include <MemoryX/gui-plugins/PriorMemoryEditor/ui_RecognitionAttributesEditTab.h>
38 texturedRecognition(
"TexturedObjectRecognition"),
39 segmentableRecognition(
"SegmentableObjectRecognition"),
40 handMarkerRecognition(
"HandMarkerLocalization"),
41 arMarkerRecognition(
"ArMarkerLocalization"),
42 otherRecognitionMethod(
"Other")
47 connect(ui->comboBoxRecognitionMethod,
48 SIGNAL(currentIndexChanged(
const QString&)),
52 texturedFeatureFileDialog =
new QFileDialog(parent);
53 texturedFeatureFileDialog->setModal(
true);
54 texturedFeatureFileDialog->setFileMode(QFileDialog::ExistingFiles);
55 texturedFeatureFileDialog->setNameFilter(tr(
"IVT data files (*.dat)"));
56 connect(ui->btnSelectTexturedFeatureFile,
58 texturedFeatureFileDialog,
63 segmentableFeatureFileDialog =
new QFileDialog(parent);
64 segmentableFeatureFileDialog->setModal(
true);
65 segmentableFeatureFileDialog->setFileMode(QFileDialog::ExistingFiles);
66 segmentableFeatureFileDialog->setNameFilter(tr(
"IVT config files (config.txt)"));
67 connect(ui->btnSelectSegmentableFeatureFile,
69 segmentableFeatureFileDialog,
71 connect(segmentableFeatureFileDialog,
100 std::string recognitionMethod = objectRecognitionWrapper->getRecognitionMethod();
101 int index = ui->comboBoxRecognitionMethod->findText(QString(recognitionMethod.c_str()));
105 ui->comboBoxRecognitionMethod->setCurrentIndex(
index);
107 else if (recognitionMethod !=
"")
109 index = ui->comboBoxRecognitionMethod->findText(QString(otherRecognitionMethod.c_str()));
113 ui->comboBoxRecognitionMethod->setCurrentIndex(
index);
114 recognitionMethod = otherRecognitionMethod;
118 ARMARX_WARNING_S <<
"Something is wrong with the ComboBox for the recognition methods";
122 if (recognitionMethod == texturedRecognition)
124 ui->editTexturedFeatureFile->setText(
125 QString(texturedRecognitionWrapper->getFeatureFile().c_str()));
127 else if (recognitionMethod == segmentableRecognition)
129 std::string configName = segmentableRecognitionWrapper->getDataFiles() +
"/config.txt";
130 ui->editSegmentableFeatureFile->setText(QString(configName.c_str()));
131 ui->comboBoxObjectColor->setCurrentIndex(
132 int(segmentableRecognitionWrapper->getObjectColor()));
134 else if (recognitionMethod == handMarkerRecognition)
136 ui->comboBoxMarkerColor->setCurrentIndex(
int(handMarkerBallWrapper->getObjectColor()));
138 else if (recognitionMethod == arMarkerRecognition)
140 std::vector<int> ids = arMarkerWrapper->getArMarkerIDs();
141 std::vector<float> sizes = arMarkerWrapper->getArMarkerSizes();
142 std::vector<Eigen::Vector3f> translations =
143 arMarkerWrapper->getTransformationToCenterTranslations();
144 std::vector<Eigen::Vector3f> rotations =
145 arMarkerWrapper->getTransformationToCenterRotationsRPY();
147 if (ids.size() != 2 || sizes.size() != 2 || translations.size() != 2 ||
148 rotations.size() != 2)
154 ui->editArMarkerID->setText(QString(
std::to_string(ids.at(0)).c_str()));
155 ui->editArMarkerID_2->setText(QString(
std::to_string(ids.at(1)).c_str()));
157 ui->editArMarkerSize->setText(QString(
std::to_string(sizes.at(0)).c_str()));
158 ui->editArMarkerSize_2->setText(QString(
std::to_string(sizes.at(1)).c_str()));
160 ui->editArMarkerTrafoX->setText(QString(
std::to_string(translations.at(0)(0)).c_str()));
161 ui->editArMarkerTrafoY->setText(QString(
std::to_string(translations.at(0)(1)).c_str()));
162 ui->editArMarkerTrafoZ->setText(QString(
std::to_string(translations.at(0)(2)).c_str()));
163 ui->editArMarkerTrafoX_2->setText(
165 ui->editArMarkerTrafoY_2->setText(
167 ui->editArMarkerTrafoZ_2->setText(
170 ui->editArMarkerTrafoR->setText(QString(
std::to_string(rotations.at(0)(0)).c_str()));
171 ui->editArMarkerTrafoP->setText(QString(
std::to_string(rotations.at(0)(1)).c_str()));
172 ui->editArMarkerTrafoYaw->setText(QString(
std::to_string(rotations.at(0)(2)).c_str()));
173 ui->editArMarkerTrafoR_2->setText(QString(
std::to_string(rotations.at(1)(0)).c_str()));
174 ui->editArMarkerTrafoP_2->setText(QString(
std::to_string(rotations.at(1)(1)).c_str()));
175 ui->editArMarkerTrafoYaw_2->setText(
179 else if (recognitionMethod == otherRecognitionMethod)
181 ui->editOtherRecogMethodName->setText(
182 QString(objectRecognitionWrapper->getRecognitionMethod().c_str()));
184 else if (recognitionMethod !=
"")
186 ARMARX_WARNING_S <<
"Recognition method " << recognitionMethod <<
" not handled here";
206 std::string recognitionMethod = ui->comboBoxRecognitionMethod->currentText().toStdString();
208 if (recognitionMethod == otherRecognitionMethod)
210 recognitionMethod = ui->editOtherRecogMethodName->text().toStdString();
212 else if (recognitionMethod == texturedRecognition)
214 texturedRecognitionWrapper->setFeatureFile(
215 ui->editTexturedFeatureFile->text().toStdString(), filesDBName);
217 else if (recognitionMethod == segmentableRecognition)
219 std::string dataPath = ui->editSegmentableFeatureFile->text().toStdString();
220 dataPath = dataPath.substr(0, dataPath.length() - 11);
221 segmentableRecognitionWrapper->setDataFiles(dataPath, filesDBName);
222 segmentableRecognitionWrapper->setObjectColor(
223 (ObjectColor)ui->comboBoxObjectColor->currentIndex());
225 else if (recognitionMethod == handMarkerRecognition)
227 handMarkerBallWrapper->setObjectColor((ObjectColor)ui->comboBoxMarkerColor->currentIndex());
229 else if (recognitionMethod == arMarkerRecognition)
231 std::vector<int> ids;
232 ids.push_back(std::stoi(ui->editArMarkerID->text().toStdString()));
233 ids.push_back(std::stoi(ui->editArMarkerID_2->text().toStdString()));
234 arMarkerWrapper->setArMarkerIDs(ids);
236 std::vector<float> sizes;
237 sizes.push_back(std::stof(ui->editArMarkerSize->text().toStdString()));
238 sizes.push_back(std::stof(ui->editArMarkerSize_2->text().toStdString()));
239 arMarkerWrapper->setArMarkerSizes(sizes);
241 Eigen::Vector3f tempVec;
242 std::vector<Eigen::Vector3f> translations;
243 tempVec(0) = std::stof(ui->editArMarkerTrafoX->text().toStdString());
244 tempVec(1) = std::stof(ui->editArMarkerTrafoY->text().toStdString());
245 tempVec(2) = std::stof(ui->editArMarkerTrafoZ->text().toStdString());
246 translations.push_back(tempVec);
247 tempVec(0) = std::stof(ui->editArMarkerTrafoX_2->text().toStdString());
248 tempVec(1) = std::stof(ui->editArMarkerTrafoY_2->text().toStdString());
249 tempVec(2) = std::stof(ui->editArMarkerTrafoZ_2->text().toStdString());
250 translations.push_back(tempVec);
251 arMarkerWrapper->setTransformationToCenterTranslations(translations);
253 std::vector<Eigen::Vector3f> rotations;
254 tempVec(0) = std::stof(ui->editArMarkerTrafoR->text().toStdString());
255 tempVec(1) = std::stof(ui->editArMarkerTrafoP->text().toStdString());
256 tempVec(2) = std::stof(ui->editArMarkerTrafoYaw->text().toStdString());
257 rotations.push_back(tempVec);
258 tempVec(0) = std::stof(ui->editArMarkerTrafoR_2->text().toStdString());
259 tempVec(1) = std::stof(ui->editArMarkerTrafoP_2->text().toStdString());
260 tempVec(2) = std::stof(ui->editArMarkerTrafoYaw_2->text().toStdString());
261 rotations.push_back(tempVec);
262 arMarkerWrapper->setTransformationToCenterRotationsRPY(rotations);
266 ARMARX_WARNING_S <<
"Recognition method " << recognitionMethod <<
" not handled here";
269 objectRecognitionWrapper->setRecognitionMethod(recognitionMethod);
275 ui->editTexturedFeatureFile->setText(texturedFeatureFileDialog->selectedFiles()[0]);
281 ui->editSegmentableFeatureFile->setText(segmentableFeatureFileDialog->selectedFiles()[0]);
287 bool enableTextured = (method.toStdString() == texturedRecognition);
288 bool enableSegmentable = (method.toStdString() == segmentableRecognition);
289 bool enableHandMarker = (method.toStdString() == handMarkerRecognition);
290 bool enableArMarker = (method.toStdString() == arMarkerRecognition);
291 bool enableOtherRecogMethod = (method.toStdString() == otherRecognitionMethod);
293 ui->btnSelectTexturedFeatureFile->setEnabled(enableTextured);
294 ui->editTexturedFeatureFile->setEnabled(enableTextured);
296 ui->btnSelectSegmentableFeatureFile->setEnabled(enableSegmentable);
297 ui->editSegmentableFeatureFile->setEnabled(enableSegmentable);
298 ui->comboBoxObjectColor->setEnabled(enableSegmentable);
300 ui->comboBoxMarkerColor->setEnabled(enableHandMarker);
302 ui->editArMarkerID->setEnabled(enableArMarker);
303 ui->editArMarkerSize->setEnabled(enableArMarker);
304 ui->editArMarkerTrafoX->setEnabled(enableArMarker);
305 ui->editArMarkerTrafoY->setEnabled(enableArMarker);
306 ui->editArMarkerTrafoZ->setEnabled(enableArMarker);
307 ui->editArMarkerTrafoR->setEnabled(enableArMarker);
308 ui->editArMarkerTrafoP->setEnabled(enableArMarker);
309 ui->editArMarkerTrafoYaw->setEnabled(enableArMarker);
310 ui->editArMarkerID_2->setEnabled(enableArMarker);
311 ui->editArMarkerSize_2->setEnabled(enableArMarker);
312 ui->editArMarkerTrafoX_2->setEnabled(enableArMarker);
313 ui->editArMarkerTrafoY_2->setEnabled(enableArMarker);
314 ui->editArMarkerTrafoZ_2->setEnabled(enableArMarker);
315 ui->editArMarkerTrafoR_2->setEnabled(enableArMarker);
316 ui->editArMarkerTrafoP_2->setEnabled(enableArMarker);
317 ui->editArMarkerTrafoYaw_2->setEnabled(enableArMarker);
319 ui->editOtherRecogMethodName->setEnabled(enableOtherRecogMethod);