10 #include <Utils/cc2sm.h>
11 #include <Utils/sm2cc.h>
13 #include "PclUtils/PCLModules.h"
23 #include <QMainWindow>
32 tr(
"Min Cut Segmentation"),
33 tr(
"Min Cut Segmentation from clouds"),
34 ":/toolbar/PclAlgorithms/icons/mincut.png")),
37 m_neighboursNumber(14),
39 m_backWeightRadius(3.0f),
40 m_foregroundWeight(0.8f),
53 if (have_cloud != 1)
return -11;
78 m_cx =
static_cast<float>(
m_dialog->cxAxisDoubleSpinBox->value());
79 m_cy =
static_cast<float>(
m_dialog->cyAxisDoubleSpinBox->value());
80 m_cz =
static_cast<float>(
m_dialog->czAxisDoubleSpinBox->value());
85 static_cast<float>(
m_dialog->backWeightRadiusSpinbox->value());
87 static_cast<float>(
m_dialog->foreWeightSpinbox->value());
94 if (!cloud)
return -1;
96 PCLCloud::Ptr sm_cloud = cc2smReader(cloud).getAsSM();
97 if (!sm_cloud)
return -1;
100 std::vector<pcl::PointIndices> clusters;
101 PointCloudT::Ptr xyzCloud(
new PointCloudT);
102 PointCloudRGB::Ptr rgbCloud(
new PointCloudRGB);
103 PointCloudRGB::Ptr cloudSegmented(
new PointCloudRGB);
107 PointRGB foregroundPoint(0.0f, 0.0f, 0.0f, 255, 255, 255);
108 foregroundPoint.x =
m_cx;
109 foregroundPoint.y =
m_cy;
110 foregroundPoint.z =
m_cz;
111 FROM_PCL_CLOUD(*sm_cloud, *rgbCloud);
112 int result = PCLModules::GetMinCutSegmentation<PointRGB>(
113 rgbCloud, clusters, cloudSegmented, foregroundPoint,
116 if (
result < 0)
return -1;
119 FROM_PCL_CLOUD(*sm_cloud, *xyzCloud);
121 int result = PCLModules::GetMinCutSegmentation<PointT>(
122 xyzCloud, clusters, cloudSegmented, foregroundPoint,
125 if (
result < 0)
return -1;
128 PCLCloud out_cloud_sm;
129 TO_PCL_CLOUD(*cloudSegmented, out_cloud_sm);
131 if (out_cloud_sm.height * out_cloud_sm.width == 0) {
136 ccPointCloud* out_cloud_cc = pcl2cc::Convert(out_cloud_sm);
163 "Selected entity does not have any suitable scalar field "
167 "Wrong Parameters. One or more parameters cannot be "
171 "Min Cut Segmentation does not returned any point. Try "
172 "relaxing your parameters");
Base abstract class for each implemented PCL filter.
int isFirstSelectedCcPointCloud()
Returns 1 if the first selected object is a ccPointCloud.
void newEntity(ccHObject *)
Signal emitted when a new entity is created by the filter.
ecvMainAppInterface * m_app
Associated application interface.
virtual QString getErrorMessage(int errorCode)
Returns the error message corresponding to a given error code.
ccPointCloud * getSelectedEntityAsCCPointCloud() const
Returns the first selected entity as a ccPointCloud.
void refreshLabelComboBox()
virtual ~MinimumCutSegmentation()
virtual int checkSelected()
Checks if current selection is compliant with the filter.
virtual QString getErrorMessage(int errorCode)
Returns the error message corresponding to a given error code.
MinimumCutSegmentationDlg * m_dialog
virtual int openInputDialog()
virtual void getParametersFromDialog()
Collects parameters from the filter dialog (if openDialog is successful)
virtual int compute()
Performs the actual filter job.
virtual int checkParameters()
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
ccHObject * getParent() const
Returns parent object.
virtual QString getName() const
Returns object name.
virtual void setName(const QString &name)
Sets object name.
virtual void setEnabled(bool state)
Sets the "enabled" property.
A 3D cloud and its associated features (color, normals, scalar fields, etc.)
bool hasColors() const override
Returns whether colors are enabled or not.
bool hasScalarFields() const override
Returns whether one or more scalar fields are instantiated.
virtual void setGlobalScale(double scale)
virtual void setGlobalShift(double x, double y, double z)
Sets shift applied to original coordinates (information storage only)
virtual const CCVector3d & getGlobalShift() const
Returns the shift applied to original coordinates.
virtual double getGlobalScale() const
Returns the scale applied to original coordinates.