36 #include <QApplication>
37 #include <QMessageBox>
38 #include <QStringList>
42 qCanupoPlugin::qCanupoPlugin(QObject* parent )
53 selectedEntities.size() == 1 &&
67 QList<QAction*> qCanupoPlugin::getActions() {
68 QList<QAction*> group;
74 ":/CC/plugin/qCanupoPlugin/images/iconCreate.png")));
84 ":/CC/plugin/qCanupoPlugin/images/iconClassify.png")));
126 params.generateAdditionalSF =
127 cDlg.generateAdditionalSFsCheckBox->isChecked();
128 params.generateRoughnessSF =
129 cDlg.generateRoughnessSFsCheckBox->isChecked();
134 QString classifierFilename = cDlg.classifFileLineEdit->text();
140 cDlg.cpSubsamplingDoubleSpinBox->value());
148 switch (coreSource) {
152 if (!realCorePoints) {
155 tr(
"Internal error: failed to access core pointss?!"),
166 assert(samplingDist > 0);
171 cloud, samplingDist, modParams, 0, &pDlg);
174 tr(
"Failed to compute sub-sampled core points!"),
179 params.samplingDist = samplingDist;
184 if (realCorePoints) {
187 tr(
".core points (subsampled @ %1)").arg(samplingDist));
193 tr(
"Can't save subsampled cloud (not enough memory)!"));
201 realCorePoints =
new ccPointCloud(tr(
"MSC core points"));
207 if (realCorePoints) {
208 delete realCorePoints;
214 }
else if (!
error.isNull()) {
220 assert(realCorePoints);
229 tr(
"Internal error: no core point source specified?!"),
238 corePointsDescriptors, realCorePoints,
m_app,
271 if (!ctDlg.exec())
return;
275 std::vector<float> scales;
283 std::sort(scales.begin(), scales.end(), std::greater<float>());
289 if (!cloud1 || !cloud2) {
292 tr(
"At least one cloud (class #1 or #2) was not defined!"),
297 assert(cloud1 != cloud2);
304 assert(descriptorID != 0);
310 tr(
"Internal error: unhandled descriptor ID (%1)!")
322 tr(
"To compute this type of descriptor, all clouds "
323 "must have an active scalar field!"),
340 assert(ctDlg.maxPointsSpinBox->value() > 0);
341 unsigned maxCorePoints =
342 static_cast<unsigned>(ctDlg.maxPointsSpinBox->value());
346 if (evaluationCloud) {
347 if (evaluationCloud->
size() > maxCorePoints)
349 subsampleCloudRandomly(evaluationCloud,
350 maxCorePoints, &pDlg);
352 evaluationPoints = evaluationCloud;
354 if (!evaluationPoints) {
356 tr(
"Failed to compute sub-sampled version of "
357 "evaluation points!"),
365 if (maxCorePoints > cloud1->
size()) maxCorePoints = cloud1->
size();
366 if (maxCorePoints > cloud2->
size()) maxCorePoints = cloud2->
size();
368 if (cloud1->
size() > maxCorePoints)
371 cloud1, maxCorePoints, &pDlg);
373 corePoints1 = cloud1;
382 if (cloud2->
size() > maxCorePoints)
385 cloud2, maxCorePoints, &pDlg);
387 corePoints2 = cloud2;
405 originCloud ? originCloud : cloud1,
415 tr(
"Failed to compute core points descriptors: %1")
421 tr(
"[qCanupo] Some descriptors couldn't be computed on "
422 "cloud#1 (min scale may be too small)!"),
435 originCloud ? originCloud : cloud2,
445 tr(
"Failed to compute core points descriptors: %1")
451 tr(
"[qCanupo] Some descriptors couldn't be computed on "
452 "cloud#2 (min scale may be too small)!"),
460 if (evaluationPoints) {
465 evaluationPoints, evaluationDescriptors,
469 tr(
"Failed to compute core points descriptors: %1")
477 tr(
"[qCanupo] Some descriptors couldn't be computed on "
478 "evaluation cloud (min scale may be too small)!"),
486 &descriptors1, &descriptors2, cloud1->
getName(),
487 cloud2->
getName(), ctDlg.cloud1ClassSpinBox->value(),
488 ctDlg.cloud2ClassSpinBox->value(),
489 evaluationPoints ? &evaluationDescriptors : 0,
m_app);
493 c2DDlg.setWindowModality(Qt::ApplicationModal);
494 QApplication::processEvents();
499 tr(
"[qCanupo] Classifier training failed..."),
511 if (corePoints1 != cloud1)
delete corePoints1;
512 if (corePoints2 != cloud2)
delete corePoints2;
513 if (evaluationPoints != evaluationCloud)
delete evaluationPoints;
float PointCoordinateType
Type of the coordinates of a (N-D) point.
cmdLineReadable * params[]
Set of (core) point descriptors.
bool loadFromMSC(QString filename, QString &error, ccPointCloud *corePoints=0)
Loads structure of descriptors from an ".msc" file (see Brodu's version)
Generic parameters 'computer' class (at a given scale)
static ScaleParamsComputer * GetByID(unsigned descID)
Vault: returns the computer corresponding to the given ID.
virtual bool needSF() const
Returns whether the computer requires a scalar field or not.
virtual bool registerCommand(Command::Shared command)=0
Registers a new command.
virtual void setRedraw(bool state)
Sets entity redraw mode.
unsigned getChildrenNumber() const
Returns the number of children.
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
std::vector< ccHObject * > Container
Standard instances container (for children, etc.)
virtual QString getName() const
Returns object name.
virtual void setName(const QString &name)
Sets object name.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
ccScalarField * getCurrentDisplayedScalarField() const
Returns the currently displayed scalar (or 0 if none)
ccPointCloud * partialClone(const cloudViewer::ReferenceCloud *selection, int *warnings=nullptr, bool withChildEntities=true) const
Creates a new point cloud object from a ReferenceCloud (selection)
Standard ECV plugin interface.
virtual void onNewSelection(const ccHObject::Container &selectedEntities)
ecvMainAppInterface * m_app
Main application interface.
A generic 3D point cloud with index-based and presistent access to points.
unsigned size() const override
A very simple point cloud (no point duplication)
virtual void updateUI()=0
virtual ccHObject * dbRootObject()=0
Returns DB root (as a ccHObject)
virtual QWidget * getActiveWindow()=0
virtual void refreshAll(bool only2D=false, bool forceRedraw=true)=0
Redraws all GL windows that have the 'refresh' flag on.
virtual void addToDB(ccHObject *obj, bool updateZoom=false, bool autoExpandDBTree=true, bool checkDimensions=false, bool autoRedraw=true)=0
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
Graphical progress indicator (thread-safe)
CANUPO plugin's 2D view dialog.
bool trainClassifier()
Trains the classifier (with the current number of scales!)
CANUPO plugin's classification dialog.
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.
CORE_CLOUD_SOURCES getCorePointsCloudSource() const
Returns the selected source for core points.
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
ccHObject::Container m_selectedEntities
Currently selected entities.
QAction * m_classifyAction
Calssift action.
QAction * m_trainAction
Train action.
static bool Classify(QString classifierFilename, const ClassifyParams ¶ms, ccPointCloud *cloud, cloudViewer::GenericIndexedCloudPersist *corePoints, CorePointDescSet &corePointsDescriptors, ccPointCloud *realCorePoints=nullptr, ecvMainAppInterface *app=nullptr, QWidget *parentWidget=nullptr, bool silent=false)
Classify a point cloud.
CANUPO plugin's training dialog.
ccPointCloud * getEvaluationCloud()
Get evaluation point cloud.
bool getScales(std::vector< float > &scales) const
Returns input scales.
ccPointCloud * getClass1Cloud()
Get class #1 point cloud.
void saveParamsToPersistentSettings()
Saves parameters to persistent settings.
unsigned getDescriptorID() const
Returns the selected descriptor ID.
ccPointCloud * getOriginPointCloud()
Get origin point cloud.
int getMaxThreadCount() const
Returns the max number of threads to use.
ccPointCloud * getClass2Cloud()
Get class #2 point cloud.
static void error(char *msg)
static bool ShowClassifyDisclaimer(ecvMainAppInterface *app)
static bool ShowTrainDisclaimer(ecvMainAppInterface *app)
QSharedPointer< Command > Shared
Shared type.