From 22d2839fd3c59d18e19cb58761bf29fcf1a72585 Mon Sep 17 00:00:00 2001 From: Paul Leroy Date: Thu, 26 Jan 2023 07:56:39 +0100 Subject: [PATCH] save / looad TrainParameters, OpenCV parameters tooltips --- CMakeLists.txt | 2 +- Train3DMASCDialog.ui | 15 +++++++++++++++ q3DMASC.cpp | 21 +++++++++++++++++++++ q3DMASC.h | 4 ++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f5eb49..7549021 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 ) diff --git a/Train3DMASCDialog.ui b/Train3DMASCDialog.ui index d32d265..c79d19b 100644 --- a/Train3DMASCDialog.ui +++ b/Train3DMASCDialog.ui @@ -22,6 +22,9 @@ + + <html><head/><body><p>OpenCV parameter</p><p>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.</p><p>[default 25]</p></body></html> + max depth @@ -42,6 +45,9 @@ + + <html><head/><body><p>OpenCV parameter</p><p>The number of trees in the forest!</p><p>[default 100]</p></body></html> + max tree count @@ -68,6 +74,9 @@ + + <html><head/><body><p>OpenCV parameter</p><p>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.</p><p>[default 0]</p></body></html> + active var count @@ -82,6 +91,9 @@ + + <html><head/><body><p>OpenCV parameter</p><p>If the number of samples in a node is less than this parameter then the node will not be split.</p><p>[default 10]</p></body></html> + min sample count @@ -95,6 +107,9 @@ 1 + + 10 + diff --git a/q3DMASC.cpp b/q3DMASC.cpp index a877ecb..851c795 100644 --- a/q3DMASC.cpp +++ b/q3DMASC.cpp @@ -35,6 +35,7 @@ #include #include #include +#include q3DMASCPlugin::q3DMASCPlugin(QObject* parent/*=0*/) : QObject(parent) @@ -219,6 +220,24 @@ struct FeatureSelection float importance = std::numeric_limits::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 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); diff --git a/q3DMASC.h b/q3DMASC.h index 1bdb518..e7bd377 100644 --- a/q3DMASC.h +++ b/q3DMASC.h @@ -20,6 +20,8 @@ //qCC #include +#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: