One to Many Images by ID

asked 2016-10-04 23:43:57 -0500

Hello,

I am seeking to use 2D features to match a large amount of images.

The opencv example of one to many images

https://github.com/opencv/opencv/blob...

So all this does is find that all query features were matched to the training set. How to get the id? DMatch does not contain information about the particular image it is from.

    descriptorMatcher->match( queryDescriptors, matches );
    tm.stop();
    double matchTime = tm.getTimeMilli();

    CV_Assert( queryDescriptors.rows == (int)matches.size() || matches.empty() );

I have also looked at FLANN index, but i do not understand it well enough. First create a BOW vocabulary from the features in all training images.

While looping
    Mat bowFeature = getBow2(inImg, detector, bow, featureMask2);
    trainData.push_back(bowFeature.reshape(1,1));


Ptr<cv::flann::Index> index = train_index(trainData);

int K = 2;
cv::Mat dists, indices;
index->knnSearch(bowTest, indices, dists, K);
float response = indices.at<int>(0, 0)

This should give me the image id right?

I am unsure about how the index is generated.

Are there any samples of one to many image matching by id?

edit retag flag offensive close merge delete

Comments

1

what are you trying to achieve ?

if you have "ids", it sounds more than classification(which? use flann::Index) than matching(where? use Matcher)

(the matching_to_many example assumes, all train images show the same thing, just from a different pose)

berak gravatar imageberak ( 2016-10-05 00:30:28 -0500 )edit

@berak - Given a list of images. I wish to identify the name of a new sample image which matches only one from the list of images.

MrDaniel1234 gravatar imageMrDaniel1234 ( 2016-10-05 08:30:10 -0500 )edit

go for the bow / flann::Index idea, then.

berak gravatar imageberak ( 2016-10-05 08:38:31 -0500 )edit