19 #include <QApplication>
21 #include <QFileDialog>
23 #include <QMainWindow>
24 #include <QPushButton>
30 : QDialog(app ? app->getMainWindow() : 0),
31 Ui::CanupoClassifDialog(),
36 #ifndef COMPILE_PRIVATE_CANUPO
37 generateRoughnessSFsCheckBox->setVisible(
false);
40 int maxThreadCount = QThread::idealThreadCount();
41 maxThreadCountSpinBox->setRange(1, maxThreadCount);
42 maxThreadCountSpinBox->setSuffix(QString(
" / %1").arg(maxThreadCount));
58 for (
size_t i = 0; i < clouds.size(); ++i) {
61 cpOtherCloudComboBox->addItem(
63 QVariant(clouds[i]->getUniqueID()));
67 connect(browseToolButton, SIGNAL(clicked()),
this,
69 connect(mscBrowseToolButton, SIGNAL(clicked()),
this,
72 buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
false);
76 if (!useConfThresholdGroupBox->isChecked())
return 0.0;
79 assert(pokDoubleSpinBox->value() >= 0 && pokDoubleSpinBox->value() <= 1.0);
80 return pokDoubleSpinBox->value();
84 return useConfThresholdGroupBox->isChecked() && useSFCheckBox->isChecked();
88 return maxThreadCountSpinBox->value();
93 if (cpUseCloudRadioButton->isChecked()) {
95 }
else if (cpSubsampleRadioButton->isChecked()) {
97 }
else if (cpUseOtherCloudRadioButton->isChecked()) {
99 }
else if (cpMscFileRadioButton->isChecked()) {
108 return mscFileLineEdit->text();
112 if (cpUseCloudRadioButton->isChecked()) {
114 }
else if (cpUseOtherCloudRadioButton->isChecked()) {
124 QSettings settings(
"qCanupo");
125 settings.beginGroup(
"Classif");
135 double subsampleRadius = settings.value(
"SubsampleRadius",
136 cpSubsamplingDoubleSpinBox->value())
138 bool subsampleEnabled = settings.value(
"SubsampleEnabled",
139 cpSubsampleRadioButton->isChecked())
142 QString currentPath =
143 settings.value(
"CurrentPath", QApplication::applicationDirPath())
145 QString mscCurrentPath =
146 settings.value(
"MscCurrentPath", QApplication::applicationDirPath())
149 bool useConfThreshold =
150 settings.value(
"UseConfThreshold",
151 useConfThresholdGroupBox->isChecked())
153 double pok = settings.value(
"Pok", pokDoubleSpinBox->value()).toDouble();
154 bool useSF = settings.value(
"UseSF", useSFCheckBox->isChecked()).toBool();
156 settings.value(
"AdditionalSF",
157 generateAdditionalSFsCheckBox->isChecked())
159 bool roughnessSF = settings.value(
"RoughnessSF",
160 generateRoughnessSFsCheckBox->isChecked())
163 settings.value(
"MaxThreadCount", maxThreadCountSpinBox->maximum())
172 cpSubsamplingDoubleSpinBox->setValue(subsampleRadius);
173 if (subsampleEnabled) cpSubsampleRadioButton->setChecked(
true);
175 classifFileLineEdit->setText(currentPath);
176 mscFileLineEdit->setText(mscCurrentPath);
178 useConfThresholdGroupBox->setChecked(useConfThreshold);
179 pokDoubleSpinBox->setValue(pok);
180 useSFCheckBox->setChecked(
useSF);
181 generateAdditionalSFsCheckBox->setChecked(additionalSF);
182 generateRoughnessSFsCheckBox->setChecked(roughnessSF);
183 maxThreadCountSpinBox->setValue(maxThreadCount);
187 QSettings settings(
"qCanupo");
188 settings.beginGroup(
"Classif");
195 settings.setValue(
"SubsampleRadius", cpSubsamplingDoubleSpinBox->value());
196 settings.setValue(
"SubsampleEnabled", cpSubsampleRadioButton->isChecked());
198 QString currentPath = QFileInfo(classifFileLineEdit->text()).absolutePath();
199 settings.setValue(
"CurrentPath", currentPath);
201 settings.setValue(
"UseConfThreshold",
202 useConfThresholdGroupBox->isChecked());
203 settings.setValue(
"Pok", pokDoubleSpinBox->value());
204 settings.setValue(
"UseSF", useSFCheckBox->isChecked());
205 settings.setValue(
"AdditionalSF",
206 generateAdditionalSFsCheckBox->isChecked());
207 settings.setValue(
"RoughnessSF", generateRoughnessSFsCheckBox->isChecked());
209 settings.setValue(
"MaxThreadCount", maxThreadCountSpinBox->value());
214 QSettings settings(
"qCanupo");
215 settings.beginGroup(
"Classif");
216 QString currentPath =
217 settings.value(
"MscCurrentPath", mscFileLineEdit->text())
220 QString
filename = QFileDialog::getOpenFileName(
this,
"Load MSC file",
221 currentPath,
"*.msc");
226 currentPath = QFileInfo(
filename).absolutePath();
227 settings.setValue(
"MscCurrentPath", currentPath);
233 QSettings settings(
"qCanupo");
234 settings.beginGroup(
"Classif");
235 QString currentPath =
236 settings.value(
"CurrentPath", classifFileLineEdit->text())
239 filename = QFileDialog::getOpenFileName(
this,
"Load classifier file",
240 currentPath,
"*.prm");
244 classifFileLineEdit->setText(
filename);
245 currentPath = QFileInfo(
filename).absolutePath();
246 settings.setValue(
"CurrentPath", currentPath);
249 std::vector<Classifier> classifiers;
250 std::vector<PointCoordinateType> scales;
255 QStringList fileDesc;
256 fileDesc << QString(
"File: %1").arg(QFileInfo(
filename).fileName());
257 fileDesc << QString(
"Classifier(s) in file: %1")
260 assert(header.
descID != 0);
263 QString descriptorName =
265 fileDesc << QString(
"Descriptor ID: %1 (%2)")
267 .arg(descriptorName);
269 fileDesc << QString(
"Dimensions per scale: %1").arg(header.
dimPerScale);
270 fileDesc << QString(
"Scales: %1").arg(scales.size());
271 QString scalesStr(
" [ ");
272 for (
size_t i = 0; i < scales.size(); ++i)
273 scalesStr.append(QString(
"%1 ").arg(
274 scales[scales.size() - 1 -
277 scalesStr.append(
"]");
278 fileDesc << scalesStr;
280 classifInfoTextEdit->setText(fileDesc.join(
"\n"));
282 buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
true);
284 classifInfoTextEdit->setText(
285 "Error: failed to open/read the input file");
286 buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
false);
static bool Load(QString filename, std::vector< Classifier > &classifiers, std::vector< float > &scales, QString &error, FileHeader *header=0, bool headerOnly=false)
Loads a CANUPO's classifier file (.prm)
Generic parameters 'computer' class (at a given scale)
static ScaleParamsComputer * GetByID(unsigned descID)
Vault: returns the computer corresponding to the given ID.
virtual QString getName() const =0
Returns the associated descriptor name.
unsigned filterChildren(Container &filteredChildren, bool recursive=false, CV_CLASS_ENUM filter=CV_TYPES::OBJECT, bool strict=false) const
Collects the children corresponding to a certain pattern.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
ccScalarField * getCurrentDisplayedScalarField() const
Returns the currently displayed scalar (or 0 if none)
Main application interface (for plugins)
virtual ccHObject * dbRootObject()=0
Returns DB root (as a ccHObject)
ccPointCloud * m_cloud
Associated cloud.
void loadParamsFromPersistentSettings()
Loads parameters from persistent settings.
ccPointCloud * getCorePointsCloud()
Get core points cloud (if any)
QString getMscFilename() const
Returns MSC file name (if source == MSC_FILE)
void saveParamsToPersistentSettings()
Saves parameters to persistent settings.
ecvMainAppInterface * m_app
Gives access to the application (data-base, UI, etc.)
qCanupoClassifDialog(ccPointCloud *cloud, ecvMainAppInterface *app)
Default constructor.
CORE_CLOUD_SOURCES getCorePointsCloudSource() const
Returns the selected source for core points.
void browseClassifierFile()
double getConfidenceTrehshold() const
Returns the confidence threshold.
int getMaxThreadCount() const
Returns the max number of threads to use.
CORE_CLOUD_SOURCES
"Sources" of core points
static void error(char *msg)