Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error matching ORB descriptors with LSH

I try to match orb descriptors with FlannDescriptorMatcher && LSH indexing
The following is my code

  Ptr<ORB> orb =ORB::create();

  //--FEATure extraction & MATCHING

     DescriptorMatcher* m_matcherPtr;

     Ptr<cv::flann::IndexParams> indexParams = new cv::flann::LshIndexParams(8, 30, 2);


    m_matcherPtr =(new FlannBasedMatcher(indexParams));


   for (size_t i = 0; i < queriesnames.size(); i++) {

          image_1 = imread(queriespath[i], CV_LOAD_IMAGE_GRAYSCALE);

          orb->detect(image_1,keypoints_r);

          orb->compute(image_1,keypoints_r,descriptors_r);

          m_matcherPtr->add(descriptors_r);
      }

   m_matcherPtr->train();

   image_1=imread(imgName_1,CV_LOAD_IMAGE_GRAYSCALE);

   orb->detect(image_1,keypoints_1);
   orb->compute(image_1,keypoints_1,descriptors_1);

   image_2=imread(imgName_2,CV_LOAD_IMAGE_GRAYSCALE);

   orb->detect(image_2,keypoints_2);

   orb->compute(image_2,keypoints_2,descriptors_2);


       vector<vector<DMatch> > matches;

   vector< DMatch > good_matches;

   vector<Mat> traindescriptors=m_matcherPtr->getTrainDescriptors();

       m_matcherPtr->knnMatch(descriptors_1,descriptors_2,matches,2);


   size_t num =matches.size();

   for(size_t i = 0; i < num; i++ )

   {

       if(matches[i][0].distance < 0.9*matches[i][1].distance){
              good_matches.push_back(matches[i][0]);
           }

   }


        //-- Draw only "good" matches
           Mat img_matches;
            drawMatches( image_1, keypoints_1, image_2, keypoints_2,
                      good_matches, out_img);

            //-- Show detected matches
            imshow( "Good Matches", out_img );


            waitKey(0);

However, I get the following error message (when debugging)

        Program received signal SIGSEGV, Segmentation fault.
        0x0806604e in main (argc=3, argv=0xbfffeed4) at ../src/main.cpp:314
           if(matches[i][0].distance < 0.9*matches[i][1].distance){

Error matching ORB descriptors with LSH

I try to match orb descriptors with FlannDescriptorMatcher && LSH indexing
The following is my code

  Ptr<ORB> orb =ORB::create();

  //--FEATure extraction & MATCHING

     DescriptorMatcher* m_matcherPtr;

     Ptr<cv::flann::IndexParams> indexParams = new cv::flann::LshIndexParams(8, 30, 2);


    m_matcherPtr =(new FlannBasedMatcher(indexParams));


   for (size_t i = 0; i < queriesnames.size(); i++) {

          image_1 = imread(queriespath[i], CV_LOAD_IMAGE_GRAYSCALE);

          orb->detect(image_1,keypoints_r);

          orb->compute(image_1,keypoints_r,descriptors_r);

          m_matcherPtr->add(descriptors_r);
      }

   m_matcherPtr->train();

   image_1=imread(imgName_1,CV_LOAD_IMAGE_GRAYSCALE);

   orb->detect(image_1,keypoints_1);
   orb->compute(image_1,keypoints_1,descriptors_1);

   image_2=imread(imgName_2,CV_LOAD_IMAGE_GRAYSCALE);

   orb->detect(image_2,keypoints_2);

   orb->compute(image_2,keypoints_2,descriptors_2);


       vector<vector<DMatch> > matches;

   vector< DMatch > good_matches;

   vector<Mat> traindescriptors=m_matcherPtr->getTrainDescriptors();

       m_matcherPtr->knnMatch(descriptors_1,descriptors_2,matches,2);


   size_t num =matches.size();

   for(size_t i = 0; i < num; i++ )

   {

       if(matches[i][0].distance < 0.9*matches[i][1].distance){
              good_matches.push_back(matches[i][0]);
           }

   }


        //-- Draw only "good" matches
           Mat img_matches;
            drawMatches( image_1, keypoints_1, image_2, keypoints_2,
                      good_matches, out_img);

            //-- Show detected matches
            imshow( "Good Matches", out_img );


            waitKey(0);

However, I get the following error message (when debugging)

        Program received signal SIGSEGV, Segmentation fault.
        0x0806604e in main (argc=3, argv=0xbfffeed4) at ../src/main.cpp:314
           if(matches[i][0].distance < 0.9*matches[i][1].distance){