Ask Your Question
1

(3.1.0) Detected FAST keypoints offset from image

asked 2016-03-20 02:07:10 -0500

csp256 gravatar image

I just compiled OpenCV 3.1.0 from source on Ubuntu 15.10. I disabled CUDA but kept everything else default.

Detected FAST features do not align with my image. Tellingly, when I rotate my camera, the keypoints move at a speed greater than the camera's rotation.

Here is a video.

    vector<KeyPoint> keypoints_1, keypoints_2;
    FAST(img_1, keypoints_1, 28);
    FAST(img_2, keypoints_2, 28);

    Mat descriptors_1, descriptors_2;
    Ptr<ORB> orb = ORB::create();
    orb->compute( img_1, keypoints_1, descriptors_1 );
    orb->compute( img_2, keypoints_2, descriptors_2 );

    BFMatcher matcher;
    vector<vector<DMatch> > knnMatches;
    matcher.knnMatch(descriptors_1, descriptors_2, knnMatches, 2 );

    vector< DMatch > good_matches;
    for( int i = 0; i < descriptors_1.rows; i++ ) {
      if( knnMatches[i][0].distance / knnMatches[i][1].distance <= 0.9 ) {
          good_matches.push_back( knnMatches[i][0]);
      }
    }

    Mat img_matches;
    drawMatches( img_1, keypoints_1, img_2, keypoints_2,
               good_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
               vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
    imshow( "Matches", img_matches );

Really looking forward to figuring out how I managed to mess this up... thanks everyone.

edit retag flag offensive close merge delete

Comments

FAST uses a grayscale image. Are you passing in the color image? Could it be re-interpreting it as a single channel and tripling or quadrupling the width?

That's my first thought. Check that by converting to gray before passing it to FAST and ORB, and see if that helps. If not, I should be able to take a closer look later today.

Tetragramm gravatar imageTetragramm ( 2016-03-20 08:06:03 -0500 )edit

It was really that simple. Please resubmit as answer.

csp256 gravatar imagecsp256 ( 2016-03-20 10:50:27 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2016-03-20 12:33:44 -0500

Tetragramm gravatar image

FAST uses a grayscale image. Are you passing in the color image? Could it be re-interpreting it as a single channel and tripling or quadrupling the width?

That's my first thought. Check that by converting to gray before passing it to FAST and ORB, and see if that helps. If not, I should be able to take a closer look later today.

edit flag offensive delete link more
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-03-20 02:07:10 -0500

Seen: 122 times

Last updated: Mar 20 '16