Correspondences Estimation with BRISK Signature

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

Correspondences Estimation with BRISK Signature

Silvio
Hi everyone,

I have a problem in finding correspondences between BRISK keypoints. Basically I am extending the BRISK example found here with a CorrespondencesEstimation in order to find similar points in 2 frames before aligning them.

Here is my code:



// Detection
pcl::BriskKeypoint2D<PointT> brisk_keypoint_estimation;
brisk_keypoint_estimation.setThreshold (60);
brisk_keypoint_estimation.setOctaves (4);

// Input Cloud
pcl::PointCloud<pcl::PointWithScale>::Ptr Input_keypoints (new pcl::PointCloud<pcl::PointWithScale>);
brisk_keypoint_estimation.setInputCloud (Input);
brisk_keypoint_estimation.compute(*Input_keypoints);

// Target Cloud
pcl::PointCloud<pcl::PointWithScale>::Ptr Target_keypoints (new pcl::PointCloud<pcl::PointWithScale>);
brisk_keypoint_estimation.setInputCloud (Target);
brisk_keypoint_estimation.compute (*Target_keypoints);




// Description
pcl::BRISK2DEstimation<PointT> brisk_descriptor_estimation;

// Input Cloud
pcl::PointCloud<pcl::BRISKSignature512>::Ptr Input_descriptors (new pcl::PointCloud<pcl::BRISKSignature512>);
brisk_descriptor_estimation.setInputCloud (Input);
brisk_descriptor_estimation.setKeypoints (Input_keypoints);
brisk_descriptor_estimation.compute (*Input_descriptors);

// Target Cloud
pcl::PointCloud<pcl::BRISKSignature512>::Ptr Target_descriptors (new pcl::PointCloud<pcl::BRISKSignature512>);
brisk_descriptor_estimation.setInputCloud (Target);
brisk_descriptor_estimation.setKeypoints (Target_keypoints);
brisk_descriptor_estimation.compute (*Target_descriptors);




// Correspondences
pcl::registration::CorrespondenceEstimation<pcl::BRISKSignature512, pcl::BRISKSignature512> myCorrespondenceEstimation;

pcl::CorrespondencesPtr correspondences(new pcl::Correspondences);
myCorrespondenceEstimation.setInputSource (Input_descriptors);
myCorrespondenceEstimation.setInputTarget (Target_descriptors);
myCorrespondenceEstimation.determineCorrespondences (*correspondences);


Detection and description go well, but the "determineCorrespondences" function get stuck in the kd-tree (seen in debug) and return this error:

/usr/include/flann/algorithms/kdtree_single_index.h:492: void flann::KDTreeSingleIndex<Distance>::middleSplit(int*, int, int&, int&, flann::KDTreeSingleIndex<Distance>::DistanceType&, const BoundingBox&) [with Distance = flann::L2_Simple<float>; flann::KDTreeSingleIndex<Distance>::DistanceType = float; flann::KDTreeSingleIndex<Distance>::BoundingBox = std::vector<flann::KDTreeSingleIndex<flann::L2_Simple<float> >::Interval, std::allocator<flann::KDTreeSingleIndex<flann::L2_Simple<float> >::Interval> >]: Assertion `index > 0 && index < count' failed.
The program has unexpectedly finished.

Have you ever encounter something similar? I don't think I am the only one to use the BRISK keypoints to register point clouds.

PS: I am using QtCreator in Ubuntu 14.04 LTS with PCL trunk.


Thank you!

Reply | Threaded
Open this post in threaded view
|

Re: Correspondences Estimation with BRISK Signature

Silvio
Up!

Anyone can help me with this problem?

Thank you ! :)
Reply | Threaded
Open this post in threaded view
|

Re: Correspondences Estimation with BRISK Signature

VictorLamoine
Administrator
Hello,

Please provide a minimal compilable code example + input point cloud to reproduce the issue.
It will be easier for readers to reproduce your problem / help you.

Bye
Reply | Threaded
Open this post in threaded view
|

Re: Correspondences Estimation with BRISK Signature

Silvio
Hi Victor,

Here is a minimal compilable code example :

testBRISK.cpp

#include <iostream>

#include <pcl/console/parse.h>
#include <pcl/io/pcd_io.h>
#include <pcl/keypoints/brisk_2d.h>
#include <pcl/features/brisk_2d.h>
#include <pcl/registration/correspondence_estimation.h>

typedef pcl::PointXYZRGBNormal PointT;
typedef pcl::PointCloud<PointT> PointCloudT;

typedef pcl::PointWithScale KeyPointT;
typedef pcl::PointCloud<KeyPointT> KeyPointCloudT;

typedef pcl::BRISKSignature512 DescriptorT;
typedef pcl::PointCloud<DescriptorT> DescriptorCloudT;

int main(int argc, char *argv[])
{    
    // Open point clouds
    std::string Source_path, Target_path;
    pcl::console::parse(argc, argv, "-source", Source_path);
    pcl::console::parse(argc, argv, "-target", Target_path);

    PointCloudT::Ptr Source(new PointCloudT);
    PointCloudT::Ptr Target(new PointCloudT);

    pcl::io::loadPCDFile(Source_path, *Source);
    pcl::io::loadPCDFile(Target_path, *Target);

    std::cout << "Target points number : " << Target->size() << std::endl;
    std::cout << "Source points number : " << Source->size() << std::endl;



    // Keypoint Detection
    pcl::BriskKeypoint2D<PointT> brisk_keypoint_estimation;
    brisk_keypoint_estimation.setThreshold (60);
    brisk_keypoint_estimation.setOctaves (4);

    // Source Cloud
    KeyPointCloudT::Ptr Source_keypoints (new KeyPointCloudT);
    brisk_keypoint_estimation.setInputCloud (Source);
    brisk_keypoint_estimation.compute(*Source_keypoints);

    // Target Cloud
    KeyPointCloudT::Ptr Target_keypoints (new KeyPointCloudT);
    brisk_keypoint_estimation.setInputCloud (Target);
    brisk_keypoint_estimation.compute (*Target_keypoints);

    std::cout << "Target keypoints number : " << Target_keypoints->size() << std::endl;
    std::cout << "Source keypoints number : " << Source_keypoints->size() << std::endl;



    // Keypoint Description
    pcl::BRISK2DEstimation<PointT> brisk_descriptor_estimation;

    // Source Cloud
    DescriptorCloudT::Ptr Source_descriptors (new DescriptorCloudT);
    brisk_descriptor_estimation.setInputCloud (Source);
    brisk_descriptor_estimation.setKeypoints (Source_keypoints);
    brisk_descriptor_estimation.compute (*Source_descriptors);

    // Target Cloud
    DescriptorCloudT::Ptr Target_descriptors (new DescriptorCloudT);
    brisk_descriptor_estimation.setInputCloud (Target);
    brisk_descriptor_estimation.setKeypoints (Target_keypoints);
    brisk_descriptor_estimation.compute (*Target_descriptors);

    std::cout << "Target descriptor number : " << Target_descriptors->size() << std::endl;
    std::cout << "Source descriptor number : " << Source_descriptors->size() << std::endl;



    // Correspondences matching
    pcl::registration::CorrespondenceEstimation<DescriptorT, DescriptorT> correspondence_estimation;

    pcl::CorrespondencesPtr correspondences(new pcl::Correspondences);
    correspondence_estimation.setInputSource (Source_descriptors);
    correspondence_estimation.setInputTarget (Target_descriptors);
    correspondence_estimation.determineCorrespondences (*correspondences);

    std::cout << "Correspondences found : " << correspondences->size() << std::endl;



    return 0;
}


CMakeLists.txt


find_package(PCL 1.8 REQUIRED)
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

ADD_EXECUTABLE(testBRISK testBRISK.cpp)
TARGET_LINK_LIBRARIES(testBRISK ${PCL_LIBRARIES})



I am using 2 point clouds from the kinect 2 (cloud1, cloud2). The example can be tested with the followinf command line :

testBRISK -target cloud1.pcd -source cloud2.pcd



My output is the following :


Target points number : 217088
Source points number : 217088
Target keypoints number : 985
Source keypoints number : 980
Target descriptor number : 855
Source descriptor number : 863
The program has unexpectedly finished.


It crashes at "correspondence_estimation.determineCorrespondences (*correspondences);", it get stuck in the KdTreeFLANN class (line 160 kdtree_flann.hpp).

Let me know If I am doing something wrong.

Thank you for your support.

Reply | Threaded
Open this post in threaded view
|

Re: Correspondences Estimation with BRISK Signature

VictorLamoine
Administrator
Thanks for this example.

There is indeed something wrong, I reported my/your issues on the issue tracker:
https://github.com/PointCloudLibrary/pcl/issues/1517

I can reproduce your problem; did you get the SSE errors too?

Bye
Reply | Threaded
Open this post in threaded view
|

RE: Correspondences Estimation with BRISK Signature

Silvio
This post was updated on .
Hi Victor,


I didn't get the SSE error, I have tried on a Intel Core i7-4510U and an Intel Xeon E5-2697 v3 CPU but I never get your SSE error.


The only error I get is the segmentation fault for the correspondences.


Let me know if you found a solution, I'll track the issue.


Bye
Reply | Threaded
Open this post in threaded view
|

RE: Correspondences Estimation with BRISK Signature

Silvio
Hi Victor,

Except the SSE error, do you have an idea why it is not working? I don't have any SSE error that pop up, do I need to compile the PCL in debug mode to see it? Do you have any clue on how can I temporary solve this issue?

Thank you,
Reply | Threaded
Open this post in threaded view
|

RE: Correspondences Estimation with BRISK Signature

Sergey
Administrator
Hi,

We've just merged a couple of pull requests that fix some issues with SSE detection on Clang and MSVC
compilers. If you are using one of these, please give it a try, it may solve your problem.

Cheers,
Sergey
Reply | Threaded
Open this post in threaded view
|

RE: Correspondences Estimation with BRISK Signature

Silvio
Hi Sergey,

Thank you for the pull you provide.
Unfortunately it didn't solve my problem, I still have a segmentation fault with this code. I am not using clang nor MSVC, I am under ubuntu 14.04, I am using QtCreator with a CMake project. I use the default compiler (which should be gcc/g++)

Basically it get stuck on the nearestKSearch function inside the KdTree, exactly here:

  // Do mapping to original point cloud
  if (!identity_mapping_)
  {
    for (size_t i = 0; i < static_cast<size_t> (k); ++i)
    {
      int& neighbor_index = k_indices[i];
      neighbor_index = index_mapping_[neighbor_index]; <--- HERE
    }
  }

It looks like for i = 0, k_indices[i] returns 9423200, which doesn't have any sense to me. Thus, index_mapping_[9423200] does not exist, and return a segmentation fault.
Again I don't know why this occurs, you try by yourself with the code I provided, I may do something wrong. I basically want to find correspondences between brisk descriptors.

Let me know if you have any suggestion.

Thank you,

Silvio
Reply | Threaded
Open this post in threaded view
|

RE: Correspondences Estimation with BRISK Signature

Napole0n
This post has NOT been accepted by the mailing list yet.
In reply to this post by Silvio
hello,when I use visual stdio 2013 to the exe which i build from the source file in the directory of PCL1.8/pcl-master/gpu/examples/segmentation,I also encountered such a error.
I doubts about whether the pcd file should be the culprit.so then I copy the front 12 line of pcd to replace the original file,then the exe run well.

bu what error in the original pcd file causing the  "kdtree_single_index.h line 492 index>0 && index<count" i do not know? I do hope to have my form friend  give me an explanation,thanks!!!