Quantcast

Get Normals while using SIFT keypoints

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Get Normals while using SIFT keypoints

saranshvora
I am using the following code snippet to get pointnormals from SIFT keypoint detector. I want to know how do I give point normals to it and again get pointnormals when I compute it. I tried using
pcl::SIFTKeypoint<pcl::PointNormal, pcl::PointNormals> sift;
                pcl::PointCloud<pcl::PointNormals> result;

but it gave me garbage value for the normals

<code>
void KeypointsType::SiftKeypoint(const pcl::PointCloud<pcl::PointNormal>::Ptr &cluster, pcl::PointCloud<pcl::PointNormal>::Ptr &keypts)
{

   
    const float min_scale =2.0f;//0.001f 0.0001 for tomato perfect
        const int n_octaves = 3;// 3
        const int n_scales_per_octave = 4; // 4
        const float min_contrast = 0.0001f; //0.001f


    double resolution;
   ComputeResolution(cluster,resolution);

                 pcl::SIFTKeypoint<pcl::PointNormal, pcl::PointWithScale> sift;
                pcl::PointCloud<pcl::PointWithScale> result;
                pcl::search::KdTree<pcl::PointNormal>::Ptr tree(new pcl::search::KdTree<pcl::PointNormal> ());
                sift.setSearchMethod(tree);
                sift.setRadiusSearch(10.0f);

                sift.setScales(min_scale, n_octaves, n_scales_per_octave);
                sift.setMinimumContrast(min_contrast);
                sift.setInputCloud(cluster);
                sift.compute(result);
                std::cout << result.size() << std::endl;
               pcl::copyPointCloud(result, *keypts);
               std::vector<int> indices;
        pcl::removeNaNFromPointCloud(*keypts, *keypts, indices);
        std::cout<<"[SIFT]:Size is: "<<keypts->size()<<std::endl;

        for (int i = 0; i <keypts->size(); i++) {
        if(DEBUG)
                                {
                                        std::cout<<"[DEBUG]:"<<"[GetColorPointCloud]:normal_cloud.X(): "<<keypts->points[i].normal_x<<std::endl;
                                        std::cout<<"[DEBUG]:"<<"[GetColorPointCloud]:normal_cloud.Y(): "<<keypts->points[i].normal_y<<std::endl;
                                        std::cout<<"[DEBUG]:"<<"[GetColorPointCloud]:normal_cloud.Z(): "<<keypts->points[i].normal_z<<std::endl;
                                }
        }
}
</code>
Loading...