Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add LOGOS features matching strategy #2383

Merged
merged 1 commit into from
Dec 17, 2019

Conversation

catree
Copy link
Contributor

@catree catree commented Dec 11, 2019

Merge with extra: opencv/opencv_extra#690

This pullrequest changes

Original code: LOGOS

Regression tests consist in comparing the output of the current implementation w.r.t. the original Matlab code, see opencv/opencv_extra#690

Note:

  • pointers are used as in the original code. I did not manage to use cv::Ptr successfully (got some memory leak issues)
  • returned distance for the matches will be zero
  • LOGOS parameters cannot be set
  • parallelization could be used
  • main changes should be code convention and float type instead of double

This method requires to build a BoW for a considered image dataset. Something like:

        std::string pattern = "Oxford City Centre/Images/*.jpg";
        vector<String> results;
        glob(pattern, results);

        Ptr<Feature2D> surf = SURF::create();
        vector<KeyPoint> bowKeypoints;
        Mat bowDescriptors;
        for (size_t i = 0; i < results.size(); i++)
        {
            Mat img = imread(results[i]);

            std::vector<KeyPoint> keypoints;
            Mat descriptors;
            surf->detectAndCompute(img, noArray(), keypoints, descriptors);

            bowKeypoints.insert(bowKeypoints.end(), keypoints.begin(), keypoints.end());
            bowDescriptors.push_back(descriptors);
        }

        int clusterCount = 512;
        BOWKMeansTrainer bowTrainer(clusterCount);
        Mat bowCenters = bowTrainer.cluster(bowDescriptors);

        FileStorage file("Oxford_BOW_512.yml", FileStorage::WRITE);
        file << "matName" << bowCenters;
    }

Cosine distance can be used to get the nearest BoW cluster for each descriptor.

Copy link
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for contribution!


void CV_LogosMatcherTest::run( int )
{
const std::string vP1_path = ts->get_data_path() + "detectors_descriptors_evaluation/matching/LOGOS/vP1.txt";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid using of legacy "cvtest::BaseTest". It is not needed after migration on GoogleTest. Just write:

TEST(XFeatures2d_LogosMatcher, logos_matcher_regression)
{
    const std::string vP1_path ...
    ...
}

ts->get_data_path() + "..."

Please use cvtest::findDataFile(...) instead.


std::cout << "groundTruth: " << groundTruth.size() << " ; matchesLogos: " << matchesLogos.size()
<< " ; correctMatches: " << correctMatches << std::endl;
ASSERT_TRUE(correctMatches == static_cast<int>(groundTruth.size()));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ASSERT_EQ(static_cast<int>(groundTruth.size()), correctMatches)
    << "groundTruth: " << groundTruth.size()
    << " ; matchesLogos: " << matchesLogos.size()
    << " ; correctMatches: " << correctMatches
;

@@ -1,89 +1,119 @@
@incollection{Agrawal08,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you please backport sorting onto 3.4 branch too?
With some note which order should be preserved (like "cite id" string)

/*
* MIT License
*
* Copyright (c) 2018 Stephanie Lowry
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this file code covered by 3rdparty license too? Is where some adopted code or it has been written from scratch ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have removed the license.

@catree catree force-pushed the feat_LOGOS_matching branch 3 times, most recently from f5973b7 to d54b041 Compare December 16, 2019 01:09
Copy link
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done! Thank you 👍

@opencv-pushbot opencv-pushbot merged commit a9c1cfc into opencv:master Dec 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants