I'm now dealing with template in c++ with PCL (Point Cloud Library) and I encountered something that I'm not able to solve (I searched before on the internet and on Stack)
I have a template class called Features
.
my hpp file:
#ifndef KeyFeatures_hpp
#define KeyFeatures_hpp
// Declarations and includes
typedef pcl::PointXYZRGB PointTypeRGB;
template<typename FeatureType>
class Features {
public:
Features(const int typeDescriptor);
void setDescriptorExtractor(typename pcl::Feature<PointTypeRGB, FeatureType>::Ptr extractor);
private:
typename pcl::Feature<PointTypeRGB, FeatureType>::Ptr m_descriptor_extractor;
};
#endif /* Features_hpp */
In the cpp file I have a constructor which will checks what kind of type is it and then perform some action.
template <typename FeatureType>
Features<FeatureType>::Features(const int type){
//Some code
if (type == DESCRIPTOR_SHOT){
pcl::SHOTEstimationOMP<PointTypeRGB, pcl::Normal, pcl::SHOT352>* shot = new pcl::SHOTEstimationOMP<PointTypeRGB, pcl::Normal, pcl::SHOT352>;
shot->setRadiusSearch (0.02f);
pcl::Feature<PointTypeRGB, pcl::SHOT352>::Ptr descriptor_extractor (shot);
descriptor_extractor->setSearchMethod (pcl::search::Search<PointTypeRGB>::Ptr (new pcl::search::KdTree<PointTypeRGB>));
this->m_descriptor_extractor = descriptor_extractor;//ERROR
setDescriptorExtractor(descriptor_extractor);//ERROR
// Some code
}
The error appeared in the last two lines when I try without success to fill in my variable member. Each time I have the following error x 10 (corresponding to my 10 kind of type)
error: no matching conversion for functional-style cast from 'const shared_ptr<pcl::Feature<pcl::PointXYZRGB, pcl::SHOT352> >'
to 'this_type' (aka 'shared_ptr<pcl::Feature<pcl::PointXYZRGB, pcl::ShapeContext1980> >')
However at the end of my cpp file I put all my template class. For example:
template class Features<pcl::SHOT352>;
In my main function I called this class by using:
Features<pcl::SHOT352> feature_SHOT(type);
It seems that it's not able to perform the conversion..
Can someone might be able to help me ?
Thank