Problem with keypoint estimation

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with keypoint estimation

akselsv
Hello,
I have a problem when I use the SIFT algorithm to calculate keypoints for my cloud. It looks like it returns the keypoints translated away from the original cloud(as you can see from the image where the white points is the original cloud and the red points are the keypoints).


This is my code:

#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/visualization/cloud_viewer.h>
#include <pcl/keypoints/sift_keypoint.h>

//Set the sift parameters for the keypoint detection
float min_scale = 0.01f, min_contrast = 0.001f;
int nr_octaves = 3, nr_scales_per_octave = 4;

int main()
{
        //Load cloud
        pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud_target(new pcl::PointCloud<pcl::PointXYZRGB>);

        if (pcl::io::loadPCDFile<pcl::PointXYZRGB>("heicloud4target.pcd", *cloud_target) == -1) //* load the file
        {
                PCL_ERROR("Couldn't read file  \n");
                return (-1);
        }
        std::cout << "Loaded cloud1 \n";

        //Sift keypoint calculation
        pcl::SIFTKeypoint<pcl::PointXYZRGB, pcl::PointWithScale> sift_detect;
        //Use a FLANN-based KdTree to perform neighborhood searches
        sift_detect.setSearchMethod(pcl::search::KdTree<pcl::PointXYZRGB>::Ptr(new pcl::search::KdTree<pcl::PointXYZRGB>));

        //Set detection parameters
        sift_detect.setScales(min_scale, nr_octaves, nr_scales_per_octave);
        sift_detect.setMinimumContrast(min_contrast);

        //Set the Input
        sift_detect.setInputCloud(cloud_target);

        //Detect the keypoints and store them in "keypoints_out_target"
        pcl::PointCloud<pcl::PointWithScale>::Ptr keypoints_out_target(new pcl::PointCloud<pcl::PointWithScale>);
        sift_detect.compute(*keypoints_out_target);
       
        //Copy the XYZ data for visualization
        pcl::PointCloud<pcl::PointXYZ>::Ptr keypoints_target(new pcl::PointCloud<pcl::PointXYZ>);
        pcl::copyPointCloud(*keypoints_out_target, *keypoints_target);

        //Visualize point cloud and keypoints
        pcl::visualization::PCLVisualizer viz;
        viz.addPointCloud(cloud_target, "target");
        viz.addPointCloud(keypoints_target, "keypoint");
        viz.setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_COLOR, 255, 0, 0, "keypoint");
        viz.spin();

        return 0;
}


Thanks,
Reply | Threaded
Open this post in threaded view
|

Re: Problem with keypoint estimation

mdelmar
I am encountering the same problem.

Opened https://github.com/PointCloudLibrary/pcl/issues/1498
Reply | Threaded
Open this post in threaded view
|

Re: Problem with keypoint estimation

VictorLamoine
Administrator
The bugfix is here, please test it and tell us if it works now:
https://github.com/PointCloudLibrary/pcl/pull/1508