Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7588969
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T20:03:30+00:00 2026-05-30T20:03:30+00:00

Does anyone happen to know why the OpenCV 2 DescriptorMatcher::radiusMatch() and knnMatch() take a

  • 0

Does anyone happen to know why the OpenCV 2 DescriptorMatcher::radiusMatch() and knnMatch() take a vector<vector<DMatch>>& matches? I’m a bit confused about why it wouldn’t just a vector, since it’s just a single array of points in the scene that correspond to the training image, right?

I’ve got something like this:

void getMatchingPoints(
    const vector<vector<cv::DMatch> >& matches,
    const vector<cv::KeyPoint>& keyPtsTemplates,
    const vector<cv::KeyPoint>& keyPtsScene,
    vector<Vec2f>& ptsTemplate,
    vector<Vec2f>& ptsScene
    )
{
    ptsTemplate.clear();
    ptsScene.clear();

    for (size_t k = 0; k < matches.size(); k++)
    {
        for (size_t i = 0; i < matches[k].size(); i++)
        {
            const cv::DMatch& match = matches[k][i];
            ptsScene.push_back(fromOcv(keyPtsScene[match.queryIdx].pt));
            ptsTemplate.push_back(fromOcv(keyPtsTemplates[match.trainIdx].pt));
        }
    }
}

but I’m a bit confused about how to actually map the approx. location of the object once I have them all in ptsScene. The points seem scattered to me when I just draw them, so I think I’m missing what the nested vectors represent.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T20:03:31+00:00Added an answer on May 30, 2026 at 8:03 pm

    The knnMatch function will return the k nearest-neighbour matches, i.e. if you call knnMatch(queryDescriptors, trainDescriptors, matchesQueryToTrain, 3) where in this case k=3, then for each training point, it will find the 3 best matches from the query set.

    In terms of your vector<vector<DMatch>>, this means that the outer vector is a vector of each query->train match, and the inner vector is a vector of your k nearest matches.

    There is quite a good example of how to use these k matches along with a cross-checking method in this other question.

    If you want a simple 1-1 matching, then you can call knnMatch with k=1 which will return an inner vector of size 1, or just call match which outputs matches in the form vector<DMatch> with no second vector.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone happen to know if there is a token I can add to
Does anyone happen to know what the maximum length of a method name is
Does anyone happen to know if Google's MapActivity will eat up extra resources if
Does anyone happen to know why this query when executed in phpMyAdmin gives me
Does anyone happen to know what the name is used for the sign up
I suppose I could easily test this, but does anyone happen to know whether
Does anyone happen to know of an article that explains what each ref in
Does anyone here happen to know how to accomplish this effect from Espresso.app? http://f.cl.ly/items/1j1V1q322f2K202v2T2s/ScreenFlow.mov
Does anyone happen to know what the convention for Windows service key names is,
Does anyone know what is the worst possible asymptotic slowdown that can happen when

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.