19 #include <QApplication>
21 #include <QMainWindow>
22 #include <QPushButton>
33 : QDialog(app ? app->getActiveWindow() : 0),
34 Ui::CanupoTrainingDialog(),
38 int maxThreadCount = QThread::idealThreadCount();
39 maxThreadCountSpinBox->setRange(1, maxThreadCount);
40 maxThreadCountSpinBox->setSuffix(QString(
" / %1").arg(maxThreadCount));
49 unsigned cloudCount = 0;
50 for (
size_t i = 0; i < clouds.size(); ++i) {
55 QVariant uniqueID(clouds[i]->getUniqueID());
56 originCloudComboBox->addItem(
name, uniqueID);
57 class1CloudComboBox->addItem(
name, uniqueID);
58 class2CloudComboBox->addItem(
name, uniqueID);
59 evaluationCloudComboBox->addItem(
name, uniqueID);
66 class1CloudComboBox->setCurrentIndex(
67 cloudCount > 0 ? (cloudCount > 2 ? 1 : 0) : -1);
68 class2CloudComboBox->setCurrentIndex(
69 cloudCount > 1 ? (cloudCount > 2 ? 2 : 1) : -1);
70 originCloudComboBox->setCurrentIndex(cloudCount > 2 ? 0 : -1);
72 if (cloudCount < 2 && app)
74 "You need at least 2 loaded clouds to train a classifier "
81 paramComboBox->clear();
83 for (
unsigned i = 0; i <
count; ++i) {
91 connect(cloud1ClassSpinBox, SIGNAL(valueChanged(
int)),
this,
93 connect(cloud2ClassSpinBox, SIGNAL(valueChanged(
int)),
this,
95 connect(class1CloudComboBox, SIGNAL(currentIndexChanged(
int)),
this,
97 connect(class2CloudComboBox, SIGNAL(currentIndexChanged(
int)),
this,
105 if (cloud1ClassSpinBox->value() == cloud2ClassSpinBox->value())
108 int c1 = class1CloudComboBox->currentIndex();
109 int c2 = class2CloudComboBox->currentIndex();
110 if (c1 < 0 || c2 < 0)
return false;
111 if (c1 == c2)
return false;
117 return maxThreadCountSpinBox->value();
124 if (scalesRampRadioButton->isChecked()) {
125 double maxScale = maxScaleDoubleSpinBox->value();
126 double step = stepScaleDoubleSpinBox->value();
127 double minScale = minScaleDoubleSpinBox->value();
128 if (maxScale < minScale || maxScale < 0 || step < 1.0e-6)
131 static_cast<unsigned>(
132 floor((maxScale - minScale) / step + 1.0e-6)) +
134 scales.resize(stepCount);
135 for (
unsigned i = 0; i < stepCount; ++i)
136 scales[i] =
static_cast<float>(maxScale - i * step);
137 }
else if (scalesListRadioButton->isChecked()) {
138 QStringList scaleList = scalesListLineEdit->text().split(
141 int listSize = scaleList.size();
142 scales.resize(listSize);
143 for (
int i = 0; i < listSize; ++i) {
146 f = scaleList[i].toFloat(&ok);
147 if (!ok)
return false;
153 }
catch (
const std::bad_alloc&) {
162 int currentIndex = paramComboBox->currentIndex();
163 if (currentIndex < 0) {
168 return paramComboBox->itemData(currentIndex).toUInt();
172 buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
validParameters());
176 buttonBox->button(QDialogButtonBox::Ok)->setEnabled(
validParameters());
193 return useOriginalCloudCheckBox->isChecked()
201 return evaluateParamsCheckBox->isChecked()
208 QSettings settings(
"qCanupo");
209 settings.beginGroup(
"Training");
212 double minScale = settings.value(
"MinScale", minScaleDoubleSpinBox->value())
215 settings.value(
"Step", stepScaleDoubleSpinBox->value()).toDouble();
216 double maxScale = settings.value(
"MaxScale", maxScaleDoubleSpinBox->value())
219 settings.value(
"ScalesList", scalesListLineEdit->text()).toString();
220 bool scalesRampEnabled = settings.value(
"ScalesRampEnabled",
221 scalesRampRadioButton->isChecked())
225 settings.value(
"MaxPoints", maxPointsSpinBox->value()).toUInt();
227 settings.value(
"ClassifParam", paramComboBox->currentIndex())
230 settings.value(
"MaxThreadCount", maxThreadCountSpinBox->maximum())
235 minScaleDoubleSpinBox->setValue(minScale);
236 stepScaleDoubleSpinBox->setValue(step);
237 maxScaleDoubleSpinBox->setValue(maxScale);
238 scalesListLineEdit->setText(scalesList);
239 if (scalesRampEnabled)
240 scalesRampRadioButton->setChecked(
true);
242 scalesListRadioButton->setChecked(
true);
244 maxPointsSpinBox->setValue(maxPoints);
245 paramComboBox->setCurrentIndex(classifParam);
246 maxThreadCountSpinBox->setValue(maxThreadCount);
250 QSettings settings(
"qCanupo");
251 settings.beginGroup(
"Training");
254 settings.setValue(
"MinScale", minScaleDoubleSpinBox->value());
255 settings.setValue(
"Step", stepScaleDoubleSpinBox->value());
256 settings.setValue(
"MaxScale", maxScaleDoubleSpinBox->value());
257 settings.setValue(
"ScalesList", scalesListLineEdit->text());
258 settings.setValue(
"ScalesRampEnabled", scalesRampRadioButton->isChecked());
260 settings.setValue(
"MaxPoints", maxPointsSpinBox->value());
261 settings.setValue(
"ClassifParam", paramComboBox->currentIndex());
262 settings.setValue(
"MaxThreadCount", maxThreadCountSpinBox->value());
Generic parameters 'computer' class (at a given scale)
static unsigned AvailableCount()
Returns the number of available 'descriptors'.
static ScaleParamsComputer * GetByIndex(unsigned index)
Vault: returns the ith computer.
virtual unsigned getID() const =0
Returns the associated descriptor 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.)
Main application interface (for plugins)
virtual ccHObject * dbRootObject()=0
Returns DB root (as a ccHObject)
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
ccPointCloud * getEvaluationCloud()
Get evaluation point cloud.
bool getScales(std::vector< float > &scales) const
Returns input scales.
bool validParameters() const
ccPointCloud * getClass1Cloud()
Get class #1 point cloud.
void saveParamsToPersistentSettings()
Saves parameters to persistent settings.
qCanupoTrainingDialog(ecvMainAppInterface *app)
Default constructor.
unsigned getDescriptorID() const
Returns the selected descriptor ID.
ecvMainAppInterface * m_app
Gives access to the application (data-base, UI, etc.)
void loadParamsFromPersistentSettings()
Loads parameters from persistent settings.
ccPointCloud * getOriginPointCloud()
Get origin point cloud.
int getMaxThreadCount() const
Returns the max number of threads to use.
ccPointCloud * getClass2Cloud()
Get class #2 point cloud.
constexpr Qt::SplitBehavior SkipEmptyParts
MiniVec< float, N > floor(const MiniVec< float, N > &a)