24 #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, SIGNAL(currentIndexChanged(
const QString&)),
this, SLOT(
recognitionMethodChanged(
const QString&)));
49 texturedFeatureFileDialog =
new QFileDialog(parent);
50 texturedFeatureFileDialog->setModal(
true);
51 texturedFeatureFileDialog->setFileMode(QFileDialog::ExistingFiles);
52 texturedFeatureFileDialog->setNameFilter(tr(
"IVT data files (*.dat)"));
53 connect(ui->btnSelectTexturedFeatureFile, SIGNAL(clicked()), texturedFeatureFileDialog, SLOT(show()));
56 segmentableFeatureFileDialog =
new QFileDialog(parent);
57 segmentableFeatureFileDialog->setModal(
true);
58 segmentableFeatureFileDialog->setFileMode(QFileDialog::ExistingFiles);
59 segmentableFeatureFileDialog->setNameFilter(tr(
"IVT config files (config.txt)"));
60 connect(ui->btnSelectSegmentableFeatureFile, SIGNAL(clicked()), segmentableFeatureFileDialog, SLOT(show()));
82 std::string recognitionMethod = objectRecognitionWrapper->getRecognitionMethod();
83 int index = ui->comboBoxRecognitionMethod->findText(QString(recognitionMethod.c_str()));
87 ui->comboBoxRecognitionMethod->setCurrentIndex(
index);
89 else if (recognitionMethod !=
"")
91 index = ui->comboBoxRecognitionMethod->findText(QString(otherRecognitionMethod.c_str()));
95 ui->comboBoxRecognitionMethod->setCurrentIndex(
index);
96 recognitionMethod = otherRecognitionMethod;
100 ARMARX_WARNING_S <<
"Something is wrong with the ComboBox for the recognition methods";
104 if (recognitionMethod == texturedRecognition)
106 ui->editTexturedFeatureFile->setText(QString(texturedRecognitionWrapper->getFeatureFile().c_str()));
108 else if (recognitionMethod == segmentableRecognition)
110 std::string configName = segmentableRecognitionWrapper->getDataFiles() +
"/config.txt";
111 ui->editSegmentableFeatureFile->setText(QString(configName.c_str()));
112 ui->comboBoxObjectColor->setCurrentIndex(
int(segmentableRecognitionWrapper->getObjectColor()));
114 else if (recognitionMethod == handMarkerRecognition)
116 ui->comboBoxMarkerColor->setCurrentIndex(
int(handMarkerBallWrapper->getObjectColor()));
118 else if (recognitionMethod == arMarkerRecognition)
120 std::vector<int> ids = arMarkerWrapper->getArMarkerIDs();
121 std::vector<float> sizes = arMarkerWrapper->getArMarkerSizes();
122 std::vector<Eigen::Vector3f> translations = arMarkerWrapper->getTransformationToCenterTranslations();
123 std::vector<Eigen::Vector3f> rotations = arMarkerWrapper->getTransformationToCenterRotationsRPY();
125 if (ids.size() != 2 || sizes.size() != 2 || translations.size() != 2 || rotations.size() != 2)
131 ui->editArMarkerID->setText(QString(
std::to_string(ids.at(0)).c_str()));
132 ui->editArMarkerID_2->setText(QString(
std::to_string(ids.at(1)).c_str()));
134 ui->editArMarkerSize->setText(QString(
std::to_string(sizes.at(0)).c_str()));
135 ui->editArMarkerSize_2->setText(QString(
std::to_string(sizes.at(1)).c_str()));
137 ui->editArMarkerTrafoX->setText(QString(
std::to_string(translations.at(0)(0)).c_str()));
138 ui->editArMarkerTrafoY->setText(QString(
std::to_string(translations.at(0)(1)).c_str()));
139 ui->editArMarkerTrafoZ->setText(QString(
std::to_string(translations.at(0)(2)).c_str()));
140 ui->editArMarkerTrafoX_2->setText(QString(
std::to_string(translations.at(1)(0)).c_str()));
141 ui->editArMarkerTrafoY_2->setText(QString(
std::to_string(translations.at(1)(1)).c_str()));
142 ui->editArMarkerTrafoZ_2->setText(QString(
std::to_string(translations.at(1)(2)).c_str()));
144 ui->editArMarkerTrafoR->setText(QString(
std::to_string(rotations.at(0)(0)).c_str()));
145 ui->editArMarkerTrafoP->setText(QString(
std::to_string(rotations.at(0)(1)).c_str()));
146 ui->editArMarkerTrafoYaw->setText(QString(
std::to_string(rotations.at(0)(2)).c_str()));
147 ui->editArMarkerTrafoR_2->setText(QString(
std::to_string(rotations.at(1)(0)).c_str()));
148 ui->editArMarkerTrafoP_2->setText(QString(
std::to_string(rotations.at(1)(1)).c_str()));
149 ui->editArMarkerTrafoYaw_2->setText(QString(
std::to_string(rotations.at(1)(2)).c_str()));
152 else if (recognitionMethod == otherRecognitionMethod)
154 ui->editOtherRecogMethodName->setText(QString(objectRecognitionWrapper->getRecognitionMethod().c_str()));
156 else if (recognitionMethod !=
"")
158 ARMARX_WARNING_S <<
"Recognition method " << recognitionMethod <<
" not handled here";
174 std::string recognitionMethod = ui->comboBoxRecognitionMethod->currentText().toStdString();
176 if (recognitionMethod == otherRecognitionMethod)
178 recognitionMethod = ui->editOtherRecogMethodName->text().toStdString();
180 else if (recognitionMethod == texturedRecognition)
182 texturedRecognitionWrapper->setFeatureFile(ui->editTexturedFeatureFile->text().toStdString(), filesDBName);
184 else if (recognitionMethod == segmentableRecognition)
186 std::string dataPath = ui->editSegmentableFeatureFile->text().toStdString();
187 dataPath = dataPath.substr(0, dataPath.length() - 11);
188 segmentableRecognitionWrapper->setDataFiles(dataPath, filesDBName);
189 segmentableRecognitionWrapper->setObjectColor((ObjectColor) ui->comboBoxObjectColor->currentIndex());
191 else if (recognitionMethod == handMarkerRecognition)
193 handMarkerBallWrapper->setObjectColor((ObjectColor) ui->comboBoxMarkerColor->currentIndex());
195 else if (recognitionMethod == arMarkerRecognition)
197 std::vector<int> ids;
198 ids.push_back(std::stoi(ui->editArMarkerID->text().toStdString()));
199 ids.push_back(std::stoi(ui->editArMarkerID_2->text().toStdString()));
200 arMarkerWrapper->setArMarkerIDs(ids);
202 std::vector<float> sizes;
203 sizes.push_back(std::stof(ui->editArMarkerSize->text().toStdString()));
204 sizes.push_back(std::stof(ui->editArMarkerSize_2->text().toStdString()));
205 arMarkerWrapper->setArMarkerSizes(sizes);
207 Eigen::Vector3f tempVec;
208 std::vector<Eigen::Vector3f> translations;
209 tempVec(0) = std::stof(ui->editArMarkerTrafoX->text().toStdString());
210 tempVec(1) = std::stof(ui->editArMarkerTrafoY->text().toStdString());
211 tempVec(2) = std::stof(ui->editArMarkerTrafoZ->text().toStdString());
212 translations.push_back(tempVec);
213 tempVec(0) = std::stof(ui->editArMarkerTrafoX_2->text().toStdString());
214 tempVec(1) = std::stof(ui->editArMarkerTrafoY_2->text().toStdString());
215 tempVec(2) = std::stof(ui->editArMarkerTrafoZ_2->text().toStdString());
216 translations.push_back(tempVec);
217 arMarkerWrapper->setTransformationToCenterTranslations(translations);
219 std::vector<Eigen::Vector3f> rotations;
220 tempVec(0) = std::stof(ui->editArMarkerTrafoR->text().toStdString());
221 tempVec(1) = std::stof(ui->editArMarkerTrafoP->text().toStdString());
222 tempVec(2) = std::stof(ui->editArMarkerTrafoYaw->text().toStdString());
223 rotations.push_back(tempVec);
224 tempVec(0) = std::stof(ui->editArMarkerTrafoR_2->text().toStdString());
225 tempVec(1) = std::stof(ui->editArMarkerTrafoP_2->text().toStdString());
226 tempVec(2) = std::stof(ui->editArMarkerTrafoYaw_2->text().toStdString());
227 rotations.push_back(tempVec);
228 arMarkerWrapper->setTransformationToCenterRotationsRPY(rotations);
232 ARMARX_WARNING_S <<
"Recognition method " << recognitionMethod <<
" not handled here";
235 objectRecognitionWrapper->setRecognitionMethod(recognitionMethod);
240 ui->editTexturedFeatureFile->setText(texturedFeatureFileDialog->selectedFiles()[0]);
245 ui->editSegmentableFeatureFile->setText(segmentableFeatureFileDialog->selectedFiles()[0]);
251 bool enableTextured = (method.toStdString() == texturedRecognition);
252 bool enableSegmentable = (method.toStdString() == segmentableRecognition);
253 bool enableHandMarker = (method.toStdString() == handMarkerRecognition);
254 bool enableArMarker = (method.toStdString() == arMarkerRecognition);
255 bool enableOtherRecogMethod = (method.toStdString() == otherRecognitionMethod);
257 ui->btnSelectTexturedFeatureFile->setEnabled(enableTextured);
258 ui->editTexturedFeatureFile->setEnabled(enableTextured);
260 ui->btnSelectSegmentableFeatureFile->setEnabled(enableSegmentable);
261 ui->editSegmentableFeatureFile->setEnabled(enableSegmentable);
262 ui->comboBoxObjectColor->setEnabled(enableSegmentable);
264 ui->comboBoxMarkerColor->setEnabled(enableHandMarker);
266 ui->editArMarkerID->setEnabled(enableArMarker);
267 ui->editArMarkerSize->setEnabled(enableArMarker);
268 ui->editArMarkerTrafoX->setEnabled(enableArMarker);
269 ui->editArMarkerTrafoY->setEnabled(enableArMarker);
270 ui->editArMarkerTrafoZ->setEnabled(enableArMarker);
271 ui->editArMarkerTrafoR->setEnabled(enableArMarker);
272 ui->editArMarkerTrafoP->setEnabled(enableArMarker);
273 ui->editArMarkerTrafoYaw->setEnabled(enableArMarker);
274 ui->editArMarkerID_2->setEnabled(enableArMarker);
275 ui->editArMarkerSize_2->setEnabled(enableArMarker);
276 ui->editArMarkerTrafoX_2->setEnabled(enableArMarker);
277 ui->editArMarkerTrafoY_2->setEnabled(enableArMarker);
278 ui->editArMarkerTrafoZ_2->setEnabled(enableArMarker);
279 ui->editArMarkerTrafoR_2->setEnabled(enableArMarker);
280 ui->editArMarkerTrafoP_2->setEnabled(enableArMarker);
281 ui->editArMarkerTrafoYaw_2->setEnabled(enableArMarker);
283 ui->editOtherRecogMethodName->setEnabled(enableOtherRecogMethod);