24 #include <QMainWindow>
31 tr(
"Template Alignment"),
32 tr(
"Template Alignment"),
33 tr(
"Template Alignment from clouds"),
34 ":/toolbar/PclAlgorithms/icons/templateAlignment.png")),
36 m_templateMatch(nullptr),
37 m_targetCloud(nullptr),
38 m_useVoxelGrid(false),
40 m_normalRadius(0.02f),
41 m_featureRadius(0.02f),
42 m_minSampleDistance(0.05f),
43 m_maxCorrespondenceDistance(0.01f * 0.01f),
45 m_maxThreadCount(1) {}
58 if (have_cloud != 1)
return -11;
117 if (!cloud1 && !cloud2) {
124 assert(cloud1 != cloud2);
146 PointCloudT::Ptr cloudFiltered =
148 if (cloudFiltered->width * cloudFiltered->height != 0) {
171 cloudFiltered = tempCloud;
174 if (!cloudFiltered) {
193 if (!best_template) {
199 tr(
"(values less than 0.00002 are good) Best fitness score: %1")
207 if (out_cloud_sm.height * out_cloud_sm.width == 0) {
223 out_cloud_cc->
showSF(
false);
229 if (best_index == 0) {
231 }
else if (best_index == 1) {
236 QString outName = cloud->
getName() +
"-alignment";
237 out_cloud_cc->
setName(outName);
257 CVLog::Print(tr(
"[ApplyTransformation] Applied transformation matrix:"));
260 tr(
"Hint: copy it (CTRL+C) and apply it - or its inverse - on any "
261 "entity with the 'Edit > Apply transformation' tool"));
271 "Selected entity does not have any suitable scalar field "
275 "Wrong Parameters. One or more parameters cannot be "
279 "Template Alignment does not returned any point. Try "
280 "relaxing your parameters");
pcl::PointCloud< PointT > PointCloudT
pcl::PCLPointCloud2 PCLCloud
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.
static bool Print(const char *format,...)
Prints out a formatted message in console.
void setmaxThreadCount(int maxThreadCount)
void setNormalRadius(float normalRadius)
void setInputCloud(PointCloudT::Ptr xyz)
void setFeatureRadius(float featureRadius)
PointCloudT::Ptr getPointCloud() const
void setTargetCloud(FeatureCloud &target_cloud)
void addTemplateCloud(FeatureCloud &template_cloud)
void setminSampleDis(float minSampleDistance)
void setmaxCorrespondenceDis(float maxCorrespondenceDistance)
int findBestAlignment(TemplateMatching::Result &result)
void setmaxIterations(int maxIterations)
FeatureCloud * getTemplateCloud(int index)
CANUPO plugin's training dialog.
float getMaxCorrespondenceDistance() const
Returns the Maximum Correspondence Distance.
float getFeatureRadius() const
Returns the Feature Radius.
float getVoxelGridLeafSize() const
float getMinSampleDistance() const
Returns the Minimum Sample Distance.
bool getScales(std::vector< float > &scales) const
Returns input scales.
int getMaxIterations() const
Returns the Maximum Iterations.
void saveParamsToPersistentSettings()
Saves parameters to persistent settings.
ccPointCloud * getTemplate1Cloud()
Get template #1 point cloud.
float getNormalRadius() const
Returns the Normal Radius.
void refreshCloudComboBox()
ccPointCloud * getTemplate2Cloud()
Get template #2 point cloud.
ccPointCloud * getEvaluationCloud()
Get evaluation point cloud.
void applyTransformation(ccHObject *entity, const ccGLMatrixd &mat)
virtual int checkSelected()
Checks if current selection is compliant with the filter.
virtual int openInputDialog()
float m_minSampleDistance
virtual void getParametersFromDialog()
Collects parameters from the filter dialog (if openDialog is successful)
virtual ~TemplateAlignment()
std::vector< float > m_scales
virtual int checkParameters()
virtual QString getErrorMessage(int errorCode)
Returns the error message corresponding to a given error code.
virtual int compute()
Performs the actual filter job.
TemplateAlignmentDialog * m_dialog
std::vector< ccPointCloud * > m_templateClouds
ccPointCloud * m_targetCloud
float m_maxCorrespondenceDistance
PCLModules::TemplateMatching * m_templateMatch
CC to PCL cloud converter.
pcl::PointCloud< pcl::PointXYZ >::Ptr getXYZ2() const
virtual void setGLTransformation(const ccGLMatrix &trans)
Associates entity with a GL transformation (rotation + translation)
virtual void showColors(bool state)
Sets colors visibility.
virtual void showSF(bool state)
Sets active scalarfield visibility.
QString toString(int precision=12, QChar separator=' ') const
Returns matrix as a string.
T * data()
Returns a pointer to internal data.
Float version of ccGLMatrixTpl.
Double version of ccGLMatrixTpl.
Hierarchical CLOUDVIEWER Object.
void applyGLTransformation_recursive(const ccGLMatrix *trans=nullptr)
Applies the active OpenGL transformation to the entity (recursive)
ccHObject * getParent() const
Returns parent object.
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
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.)
bool setRGBColor(ColorCompType r, ColorCompType g, ColorCompType b)
Set a unique color for the whole cloud (shortcut)
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 void setGlobalScale(double scale)
virtual double getGlobalScale() const
Returns the scale applied to original coordinates.
virtual void dispToConsole(QString message, ConsoleMessageLevel level=STD_CONSOLE_MESSAGE)=0
static ccMesh * Convert(PCLTextureMesh::ConstPtr textureMesh)
Converts a PCL point cloud to a ccPointCloud.
template int VoxelGridFilter< PointT >(const PointCloudT::ConstPtr inCloud, PointCloudT::Ptr outcloud, const float &leafSizeX, const float &leafSizeY, const float &leafSizeZ)
constexpr Rgb darkBlue(0, 0, MAX/2)
Eigen::Matrix4f final_transformation