2020-01-11 19:28:31 +01:00
|
|
|
#ifndef EXAMPLE_PLUGIN_HEADER
|
|
|
|
|
#define EXAMPLE_PLUGIN_HEADER
|
|
|
|
|
|
|
|
|
|
//##########################################################################
|
|
|
|
|
//# #
|
2020-01-28 21:09:27 +01:00
|
|
|
//# CLOUDCOMPARE PLUGIN: ColorimetricSegmenter #
|
2020-01-11 19:28:31 +01:00
|
|
|
//# #
|
|
|
|
|
//# This program is free software; you can redistribute it and/or modify #
|
|
|
|
|
//# it under the terms of the GNU General Public License as published by #
|
|
|
|
|
//# the Free Software Foundation; version 2 of the License. #
|
|
|
|
|
//# #
|
|
|
|
|
//# This program is distributed in the hope that it will be useful, #
|
|
|
|
|
//# but WITHOUT ANY WARRANTY; without even the implied warranty of #
|
|
|
|
|
//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
|
|
|
|
|
//# GNU General Public License for more details. #
|
|
|
|
|
//# #
|
2020-01-28 21:09:27 +01:00
|
|
|
//# COPYRIGHT: Tri-Thien TRUONG, Ronan COLLIER, Mathieu LETRONE #
|
2020-01-11 19:28:31 +01:00
|
|
|
//# #
|
|
|
|
|
//##########################################################################
|
|
|
|
|
|
|
|
|
|
#include "ccStdPluginInterface.h"
|
2020-03-02 11:10:44 +01:00
|
|
|
#include "ccPointCloud.h"
|
2020-01-28 21:09:27 +01:00
|
|
|
#include <QObject>
|
|
|
|
|
#include <QtGui>
|
|
|
|
|
|
2020-02-01 03:59:24 +01:00
|
|
|
#include <ccPickingListener.h>
|
|
|
|
|
#include <ccPickingHub.h>
|
|
|
|
|
#include <ccGLWindow.h>
|
2020-02-29 18:00:36 +01:00
|
|
|
#include "ccPointCloud.h"
|
|
|
|
|
#include "ccScalarField.h"
|
2020-02-01 03:59:24 +01:00
|
|
|
|
2020-02-06 18:58:02 +01:00
|
|
|
#include "RgbDialog.h"
|
2020-02-29 18:00:36 +01:00
|
|
|
#include "HSVDialog.h"
|
2020-04-29 19:19:46 +02:00
|
|
|
#include "ScalarDialog.h"
|
2020-05-02 10:27:30 +02:00
|
|
|
#include "QuantiDialog.h"
|
|
|
|
|
#include "KmeansDlg.h"
|
2020-01-11 19:28:31 +01:00
|
|
|
|
|
|
|
|
//! Example qCC plugin
|
|
|
|
|
/** Replace 'ExamplePlugin' by your own plugin class name throughout and then
|
|
|
|
|
check 'ExamplePlugin.cpp' for more directions.
|
2020-05-02 10:27:30 +02:00
|
|
|
|
2020-01-11 19:28:31 +01:00
|
|
|
Each plugin requires an info.json file to provide information about itself -
|
|
|
|
|
the name, authors, maintainers, icon, etc..
|
2020-05-02 10:27:30 +02:00
|
|
|
|
2020-01-11 19:28:31 +01:00
|
|
|
The one method you are required to implement is 'getActions'. This should
|
|
|
|
|
return all actions (QAction objects) for the plugin. CloudCompare will
|
|
|
|
|
automatically add these with their icons in the plugin toolbar and to the
|
|
|
|
|
plugin menu. If your plugin returns several actions, CC will create a
|
|
|
|
|
dedicated toolbar and a sub-menu for your plugin. You are responsible for
|
|
|
|
|
connecting these actions to methods in your plugin.
|
2020-05-02 10:27:30 +02:00
|
|
|
|
2020-01-11 19:28:31 +01:00
|
|
|
Use the ccStdPluginInterface::m_app variable for access to most of the CC
|
|
|
|
|
components (database, 3D views, console, etc.) - see the ccMainAppInterface
|
|
|
|
|
class in ccMainAppInterface.h.
|
|
|
|
|
**/
|
2020-04-29 00:18:47 +02:00
|
|
|
const int MIN_VALUE = 0;
|
|
|
|
|
const int MAX_VALUE = 255;
|
|
|
|
|
|
2020-01-28 21:09:27 +01:00
|
|
|
class ColorimetricSegmenter : public QObject, public ccStdPluginInterface
|
2020-01-11 19:28:31 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2020-05-02 11:04:24 +02:00
|
|
|
Q_INTERFACES(ccStdPluginInterface)
|
2020-05-02 10:27:30 +02:00
|
|
|
|
2020-05-02 11:04:24 +02:00
|
|
|
// Replace "Example" by your plugin name (IID should be unique - let's hope your plugin name is unique ;)
|
|
|
|
|
// The info.json file provides information about the plugin to the loading system and
|
|
|
|
|
// it is displayed in the plugin information dialog.
|
|
|
|
|
Q_PLUGIN_METADATA(IID "cccorp.cloudcompare.plugin.ColorimetricSegmenter" FILE "info.json")
|
2020-05-02 10:27:30 +02:00
|
|
|
|
2020-01-11 19:28:31 +01:00
|
|
|
public:
|
2020-05-02 11:04:24 +02:00
|
|
|
explicit ColorimetricSegmenter(QObject* parent = nullptr);
|
2020-01-28 21:09:27 +01:00
|
|
|
~ColorimetricSegmenter() override = default;
|
2020-05-02 10:27:30 +02:00
|
|
|
|
2020-01-11 19:28:31 +01:00
|
|
|
// inherited from ccStdPluginInterface
|
2020-05-02 11:04:24 +02:00
|
|
|
void onNewSelection(const ccHObject::Container& selectedEntities) override;
|
|
|
|
|
QList<QAction*> getActions() override;
|
2020-01-28 21:09:27 +01:00
|
|
|
|
|
|
|
|
public slots:
|
|
|
|
|
//! Handles new entity
|
|
|
|
|
void handleNewEntity(ccHObject*);
|
|
|
|
|
|
|
|
|
|
//! Handles entity (visual) modification
|
|
|
|
|
void handleEntityChange(ccHObject*);
|
|
|
|
|
|
|
|
|
|
//! Handles new error message
|
|
|
|
|
void handleErrorMessage(QString);
|
|
|
|
|
|
|
|
|
|
signals:
|
|
|
|
|
|
|
|
|
|
//! Signal emitted when an entity is (visually) modified
|
|
|
|
|
void entityHasChanged(ccHObject*);
|
|
|
|
|
|
|
|
|
|
//! Signal emitted when a new entity is created by the filter
|
|
|
|
|
void newEntity(ccHObject*);
|
|
|
|
|
|
|
|
|
|
//! Signal emitted when a new error message is produced
|
|
|
|
|
void newErrorMessage(QString);
|
|
|
|
|
|
2020-01-11 19:28:31 +01:00
|
|
|
private:
|
2020-01-28 21:09:27 +01:00
|
|
|
std::vector<ccPointCloud*> getSelectedPointClouds();
|
|
|
|
|
|
|
|
|
|
//! Filter a cloud with RGB color
|
|
|
|
|
void filterRgb();
|
2020-02-01 03:59:24 +01:00
|
|
|
|
2020-05-02 11:04:24 +02:00
|
|
|
void filterHSV();
|
2020-04-29 19:19:46 +02:00
|
|
|
|
2020-05-02 11:04:24 +02:00
|
|
|
void filterScalar();
|
2020-02-29 18:00:36 +01:00
|
|
|
|
2020-05-02 11:04:24 +02:00
|
|
|
void HistogramClustering();
|
2020-05-02 10:27:30 +02:00
|
|
|
|
2020-05-02 11:04:24 +02:00
|
|
|
void KmeansClustering();
|
2020-05-02 10:27:30 +02:00
|
|
|
|
2020-02-29 18:00:36 +01:00
|
|
|
void addPoint(CCLib::ReferenceCloud* filteredCloud, unsigned int j);
|
|
|
|
|
|
2020-04-29 16:11:14 +02:00
|
|
|
template <typename T>
|
|
|
|
|
void createClouds(T& dlg, ccPointCloud* cloud, CCLib::ReferenceCloud* filteredCloudInside, CCLib::ReferenceCloud* filteredCloudOutside, std::string name);
|
2020-04-29 00:18:47 +02:00
|
|
|
|
2020-05-02 11:04:24 +02:00
|
|
|
void createCloud(ccPointCloud* cloud, CCLib::ReferenceCloud* referenceCloud, std::string name, bool inside);
|
2020-04-29 00:18:47 +02:00
|
|
|
|
2020-02-01 03:59:24 +01:00
|
|
|
//picked point callbacks
|
|
|
|
|
//void pointPicked(ccHObject* entity, unsigned itemIdx, int x, int y, const CCVector3& P);
|
|
|
|
|
//virtual void onItemPicked(const ccPickingListener::PickedItem& pi); //inherited from ccPickingListener
|
2020-05-02 10:27:30 +02:00
|
|
|
|
2020-05-02 11:04:24 +02:00
|
|
|
//! Segment a cloud with RGB color
|
|
|
|
|
void filterRgbWithSegmentation();
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief regionGrowing Segmentation method grouping the points into regions of similar colors.
|
|
|
|
|
* Method described in Qingming Zhan, Yubin Liang, Yinghui Xiao, 2009 "Color-based segmentation of point clouds".
|
|
|
|
|
* @param pointCloud The point cloud to segment.
|
|
|
|
|
* @param TNN Point-point colorimetrical similarity threshold.
|
|
|
|
|
* @param TPP Number of neighbours to search using KNN.
|
|
|
|
|
* @param TD Threshold distance between neighbouring points.
|
|
|
|
|
* @return Vector containing the resulting regions.
|
|
|
|
|
*/
|
|
|
|
|
std::vector<CCLib::ReferenceCloud*>* regionGrowing(ccPointCloud* pointCloud, const unsigned TNN, const double TPP, const double TD);
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief regionMergingAndRefinement Merge previously created regions in 'regionGrowing' method.
|
|
|
|
|
* @param basePointCloud The base segmented point cloud used to create the regions.
|
|
|
|
|
* @param regions Vector containing the regions.
|
|
|
|
|
* @param TNN Point-point colorimetrical similarity threshold.
|
|
|
|
|
* @param TRR Region-region colorimetrical similarity threshold.
|
|
|
|
|
* @param TD Threshold distance between neighbouring regions. Used to merge close regions.
|
|
|
|
|
* @param Min Minimal size for a region.
|
|
|
|
|
* @return Vector containing the resulting merged and refined regions.
|
|
|
|
|
*/
|
|
|
|
|
std::vector<CCLib::ReferenceCloud*>* regionMergingAndRefinement(ccPointCloud* basePointCloud, std::vector<CCLib::ReferenceCloud*>* regions, const unsigned TNN, const double TRR, const double TD, const unsigned Min);
|
2020-03-02 11:10:44 +01:00
|
|
|
|
|
|
|
|
|
2020-01-11 19:28:31 +01:00
|
|
|
//! Default action
|
|
|
|
|
/** You can add as many actions as you want in a plugin.
|
|
|
|
|
Each action will correspond to an icon in the dedicated
|
|
|
|
|
toolbar and an entry in the plugin menu.
|
|
|
|
|
**/
|
2020-01-28 21:09:27 +01:00
|
|
|
QAction* m_action_filterRgb;
|
2020-05-12 17:27:32 +02:00
|
|
|
//QAction* m_action_filterRgbWithSegmentation;
|
2020-02-29 18:00:36 +01:00
|
|
|
QAction* m_action_filterHSV;
|
2020-05-02 11:04:24 +02:00
|
|
|
QAction* m_action_filterScalar;
|
|
|
|
|
QAction* m_action_ToonMapping_Hist;
|
2020-05-02 10:27:30 +02:00
|
|
|
QAction* m_action_ToonMapping_KMeans;
|
|
|
|
|
|
2020-01-28 21:09:27 +01:00
|
|
|
|
2020-02-01 03:59:24 +01:00
|
|
|
//! Picking hub
|
|
|
|
|
ccPickingHub* m_pickingHub = nullptr;
|
|
|
|
|
|
2020-02-06 18:58:02 +01:00
|
|
|
RgbDialog* rgbDlg;
|
2020-05-02 11:04:24 +02:00
|
|
|
HSVDialog* hsvDlg;
|
|
|
|
|
ScalarDialog* scalarDlg;
|
|
|
|
|
QuantiDialog* quantiDlg;
|
|
|
|
|
KmeansDlg* kmeansDlg;
|
2020-05-02 10:27:30 +02:00
|
|
|
|
2020-02-06 18:58:02 +01:00
|
|
|
|
2020-02-01 03:59:24 +01:00
|
|
|
//link to application windows
|
|
|
|
|
//ccGLWindow* m_window;
|
|
|
|
|
//QMainWindow* m_main_window;
|
2020-01-28 21:09:27 +01:00
|
|
|
|
2020-05-02 11:04:24 +02:00
|
|
|
const unsigned TNN = 1;
|
|
|
|
|
const double TPP = 2.0;
|
|
|
|
|
const double TD = 2.0;
|
|
|
|
|
const double TRR = 2.0;
|
|
|
|
|
const unsigned Min = 2;
|
2020-01-11 19:28:31 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#endif
|