I am trying to give a function pointer as parameter to a clustering operation.
pcl::ConditionalEuclideanClustering<pcl::PointXYZINormal> cec;
cec.setInputCloud(ss_cloud);
//Conditions
if (m_config.condition == EuclideanCondition::pass) {
//Next line gives an error
cec.setConditionFunction(std::bind(&Rules::passThrough, this, _1, _2, _3));
}
else if (m_config.condition == EuclideanCondition::curvature) {
//cec.setConditionFunction(&passThrough);
}
else if (m_config.condition == EuclideanCondition::normals) {
//cec.setConditionFunction(&normalRule);
}
cec.setClusterTolerance(m_config.tolerance);
cec.setMinClusterSize(m_config.minSize);
cec.setMaxClusterSize(m_config.maxSize);
Than I have a member function of class Rules defined here
bool Rules::passThrough(
const pcl::PointXYZINormal& p1,
const pcl::PointXYZINormal& p2,
float squared_distance) {
return true;
}
The function (passThrough()) used to be a friend function to the class containing the pcl::ConditionalEuclideanClustering code and everything worked just fine. But now I need to access a few class variables in it without passing the class as parameter to passThrough() (standard for friend functions).
In other words the pcl::ConditionalEuclideanClustering expects
const pcl::PointXYZINormal& p1,
const pcl::PointXYZINormal& p2,
float squared_distance
format that I need to respect.
I decided to make a class Rules and put all my condition functions in there. If you think there is a better idea please let me know.
The error message I get is the following:
Error C2440 '
return': cannot convert from 'std::_Unforced' to 'bool'
inline void
setConditionFunction (bool (*condition_function) (const PointT&, const PointT&, float))
{
condition_function_ = condition_function;
}
/** \brief Set the condition that needs to hold for neighboring points to be considered part of the same cluster.
* This is an overloaded function provided for convenience. See the documentation for setConditionFunction(). */
inline void
setConditionFunction (boost::function<bool (const PointT&, const PointT&, float)> condition_function)
{
condition_function_ = condition_function;
}
Aucun commentaire:
Enregistrer un commentaire