11 #include <Utils/cc2sm.h>
12 #include <Utils/sm2cc.h>
14 #include "PclUtils/PCLModules.h"
24 #include <QMainWindow>
32 tr(
"Extract SIFT Keypoints"),
33 tr(
"Extract SIFT keypoints for clouds with "
34 "intensity/RGB or any scalar field"),
35 ":/toolbar/PclAlgorithms/icons/sift.png")),
39 m_nr_scales_per_octave(0),
41 m_use_min_contrast(false),
52 if (have_cloud != 1)
return -11;
56 if (have_sf == 1)
return 1;
100 ?
static_cast<float>(
m_dialog->minContrast->value())
111 fieldname.replace(
' ',
'_');
113 qPrintable(fieldname);
136 if (!cloud)
return -1;
138 std::list<std::string> req_fields;
140 req_fields.push_back(
"xyz");
143 req_fields.push_back(
"rgb");
146 req_fields.push_back(qPrintable(
154 }
catch (
const std::bad_alloc&) {
159 PCLCloud::Ptr sm_cloud = cc2smReader(cloud).getAsSM(req_fields);
160 if (!sm_cloud)
return -1;
167 sm_cloud->fields.at(field_index).name =
173 pcl::PointCloud<pcl::PointXYZ>::Ptr out_cloud(
174 new pcl::PointCloud<pcl::PointXYZ>);
178 pcl::PointCloud<pcl::PointXYZI>::Ptr cloud_i(
179 new pcl::PointCloud<pcl::PointXYZI>);
180 FROM_PCL_CLOUD(*sm_cloud, *cloud_i);
181 PCLModules::EstimateSIFT<pcl::PointXYZI, pcl::PointXYZ>(
185 pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_rgb(
186 new pcl::PointCloud<pcl::PointXYZRGB>);
187 FROM_PCL_CLOUD(*sm_cloud, *cloud_rgb);
188 PCLModules::EstimateSIFT<pcl::PointXYZRGB, pcl::PointXYZ>(
193 PCLCloud out_cloud_sm;
194 TO_PCL_CLOUD(*out_cloud, out_cloud_sm);
196 if (out_cloud_sm.height * out_cloud_sm.width == 0) {
201 ccPointCloud* out_cloud_cc = pcl2cc::Convert(out_cloud_sm);
209 name = tr(
"SIFT Keypoints_%1_rgb_%2_%3_%4")
215 name = tr(
"SIFT Keypoints_%1_%2_%3_%4_%5")
225 out_cloud_cc->
showSF(
false);
245 return "Selected entity does not have any suitable scalar field or "
246 "RGB. Intensity scalar field or RGB are needed for "
249 return "Wrong Parameters. One or more parameters cannot be "
252 return "SIFT keypoint extraction does not returned any point. Try "
253 "relaxing your parameters";
std::vector< PCLPointField > fields
Base abstract class for each implemented PCL filter.
std::vector< std::string > getSelectedAvailableScalarFields()
int hasSelectedRGB()
Returns 1 if the first selected entity has RGB info.
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.
int hasSelectedScalarField()
Returns 1 if the first selected entity has at least one scalar field.
ccPointCloud * getSelectedEntityAsCCPointCloud() const
Returns the first selected entity as a ccPointCloud.
virtual void showColors(bool state)
Sets colors visibility.
virtual void showSF(bool state)
Sets active scalarfield visibility.
void setPointSize(unsigned size=0)
Sets point size.
virtual bool addChild(ccHObject *child, int dependencyFlags=DP_PARENT_OF_OTHER, int insertIndex=-1)
Adds a child.
ccHObject * getParent() const
Returns parent object.
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 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.
virtual QWidget * getActiveWindow()=0
constexpr Rgb red(MAX, 0, 0)