save / looad TrainParameters, OpenCV parameters tooltips

This commit is contained in:
Paul Leroy
2023-01-26 07:56:39 +01:00
parent fc00e28667
commit 22d2839fd3
4 changed files with 41 additions and 1 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ if (INSTALL_Q3DMASC_PLUGIN)
project( Q3DMASC_PLUGIN )
AddPlugin( NAME ${PROJECT_NAME} )
set(Q3DMASC_PLUGIN_VERSION "0.1")
set(Q3DMASC_PLUGIN_VERSION "0.1+")
include( CMakePolicies NO_POLICY_SCOPE )
+15
View File
@@ -22,6 +22,9 @@
<layout class="QFormLayout" name="formLayout">
<item row="0" column="0">
<widget class="QLabel" name="label">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;OpenCV parameter&lt;/p&gt;&lt;p&gt;The maximum possible depth of the tree. That is the training algorithms attempts to split a node while its depth is less than maxDepth. The root node has zero depth. The actual depth may be smaller if the other termination criteria are met, and/or if the tree is pruned.&lt;/p&gt;&lt;p&gt;[default 25]&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>max depth</string>
</property>
@@ -42,6 +45,9 @@
</item>
<item row="1" column="0">
<widget class="QLabel" name="label_5">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;OpenCV parameter&lt;/p&gt;&lt;p&gt;The number of trees in the forest!&lt;/p&gt;&lt;p&gt;[default 100]&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>max tree count</string>
</property>
@@ -68,6 +74,9 @@
</item>
<item row="2" column="0">
<widget class="QLabel" name="label_4">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;OpenCV parameter&lt;/p&gt;&lt;p&gt;The size of the randomly selected subset of features at each tree node and that are used to find the best split(s). If you set it to 0 then the size will be set to the square root of the total number of features.&lt;/p&gt;&lt;p&gt;[default 0]&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>active var count</string>
</property>
@@ -82,6 +91,9 @@
</item>
<item row="3" column="0">
<widget class="QLabel" name="label_2">
<property name="toolTip">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;OpenCV parameter&lt;/p&gt;&lt;p&gt;If the number of samples in a node is less than this parameter then the node will not be split.&lt;/p&gt;&lt;p&gt;[default 10]&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>
</property>
<property name="text">
<string>min sample count</string>
</property>
@@ -95,6 +107,9 @@
<property name="minimum">
<number>1</number>
</property>
<property name="value">
<number>10</number>
</property>
</widget>
</item>
</layout>
+21
View File
@@ -35,6 +35,7 @@
#include <QApplication>
#include <QFileDialog>
#include <QMessageBox>
#include <QSettings>
q3DMASCPlugin::q3DMASCPlugin(QObject* parent/*=0*/)
: QObject(parent)
@@ -219,6 +220,24 @@ struct FeatureSelection
float importance = std::numeric_limits<float>::quiet_NaN();
};
void q3DMASCPlugin::saveTrainParameters(const masc::TrainParameters& params)
{
QSettings settings("OSUR", "q3DMASC");
settings.setValue("TrainParameters/maxDepth", params.rt.maxDepth);
settings.setValue("TrainParameters/minSampleCount", params.rt.minSampleCount);
settings.setValue("TrainParameters/activeVarCount", params.rt.activeVarCount);
settings.setValue("TrainParameters/maxTreeCount", params.rt.maxTreeCount);
}
void q3DMASCPlugin::loadTrainParameters(masc::TrainParameters& params)
{
QSettings settings("OSUR", "q3DMASC");
params.rt.maxDepth = settings.value("TrainParameters/maxDepth", 25).toInt();
params.rt.minSampleCount = settings.value("TrainParameters/minSampleCount", 10).toInt();
params.rt.activeVarCount = settings.value("TrainParameters/activeVarCount", 0).toInt();
params.rt.maxTreeCount = settings.value("TrainParameters/maxTreeCount", 100).toInt();
}
void q3DMASCPlugin::doTrainAction()
{
//disclaimer accepted?
@@ -291,6 +310,7 @@ void q3DMASCPlugin::doTrainAction()
}
static masc::TrainParameters s_params;
loadTrainParameters(s_params); // load the saved parameters or the default values if any
masc::Feature::Set features;
std::vector<double> scales;
if (!masc::Tools:: LoadTrainingFile(inputFilename, features, scales, loadedClouds, s_params, &corePoints, m_app->getMainWindow()))
@@ -676,6 +696,7 @@ void q3DMASCPlugin::doTrainAction()
{
if (!trainDlg.exec())
{
saveTrainParameters(s_params);
//the dialog can be closed
generatedScalarFields.releaseSFs(s_keepAttributes);
generatedScalarFieldsTest.releaseSFs(s_keepAttributes);
+4
View File
@@ -20,6 +20,8 @@
//qCC
#include <ccStdPluginInterface.h>
#include "Parameters.h"
//! 3DMASC plugin
/** 3D Multi-cloud, multi-Attribute, multi-Scale, multi-Class classification
**/
@@ -43,6 +45,8 @@ public:
protected slots:
void doClassifyAction();
void saveTrainParameters(const masc::TrainParameters& params);
void loadTrainParameters(masc::TrainParameters& params);
void doTrainAction();
protected: