How to do One to many Image matching in opencv?

I am working on a Vein pattern recognition project. I have done one to one matching with the SURF detector and it works fine just by giving the filenames. Now, is there a way, I could do one to many comparison and open the image that maximum matches the image? Like enter one filename and compare with it with images in a directory? Is there some built in function that I can use for traversing the images directory?

I am working the project in C++, Ubuntu 12.04LTS, Opencv.

Any help is deeply appreciated.

Upvotes: 0

Views: 633

Answers (1)

herohuyongtao
herohuyongtao

Reputation: 50717

You can use the following function to get all files within given folder.

int getdir (string dir, vector<string> &files)
{
    DIR *dp;
    struct dirent *dirp;
    if((dp  = opendir(dir.c_str())) == NULL) {
        cout << "Error(" << errno << ") opening " << dir << endl;
        return errno;
    }

    while ((dirp = readdir(dp)) != NULL) {
        files.push_back(string(dirp->d_name));
    }
    closedir(dp);
    return 0;
}

After this, all files will be saved in vector<string> files. You can check out here for more info.

P.S. To achieve one-to-many matches, I think you need to loop these files and compare them based on simple one-to-one match and then select the best match.

Upvotes: 1

Related Questions