Commit e39e7e603b540e02a53daa2b746833f1d681fa16

Authored by Josh Klontz
1 parent ac67461f

removed keypoint matcher

openbr/plugins/distance/keypointmatcher.cpp deleted
1   -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2   - * Copyright 2012 The MITRE Corporation *
3   - * *
4   - * Licensed under the Apache License, Version 2.0 (the "License"); *
5   - * you may not use this file except in compliance with the License. *
6   - * You may obtain a copy of the License at *
7   - * *
8   - * http://www.apache.org/licenses/LICENSE-2.0 *
9   - * *
10   - * Unless required by applicable law or agreed to in writing, software *
11   - * distributed under the License is distributed on an "AS IS" BASIS, *
12   - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13   - * See the License for the specific language governing permissions and *
14   - * limitations under the License. *
15   - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
16   -
17   -#include <opencv2/features2d/features2d.hpp>
18   -
19   -#include <openbr/plugins/openbr_internal.h>
20   -
21   -using namespace cv;
22   -
23   -namespace br
24   -{
25   -
26   -/*!
27   - * \ingroup transforms
28   - * \brief Wraps OpenCV Key Point Matcher
29   - * \br_link http://docs.opencv.org/modules/features2d/doc/common_interfaces_of_feature_detectors.html
30   - * \author Josh Klontz \cite jklontz
31   - */
32   -class KeyPointMatcherDistance : public UntrainableDistance
33   -{
34   - Q_OBJECT
35   - Q_PROPERTY(QString matcher READ get_matcher WRITE set_matcher RESET reset_matcher STORED false)
36   - Q_PROPERTY(float maxRatio READ get_maxRatio WRITE set_maxRatio RESET reset_maxRatio STORED false)
37   - BR_PROPERTY(QString, matcher, "BruteForce")
38   - BR_PROPERTY(float, maxRatio, 0.8)
39   -
40   - Ptr<DescriptorMatcher> descriptorMatcher;
41   -
42   - void init()
43   - {
44   - descriptorMatcher = DescriptorMatcher::create(matcher.toStdString());
45   - if (descriptorMatcher.empty())
46   - qFatal("Failed to create DescriptorMatcher: %s", qPrintable(matcher));
47   - }
48   -
49   - float compare(const Mat &a, const Mat &b) const
50   - {
51   - if ((a.rows < 2) || (b.rows < 2)) return 0;
52   -
53   - std::vector< std::vector<DMatch> > matches;
54   - if (a.rows < b.rows) descriptorMatcher->knnMatch(a, b, matches, 2);
55   - else descriptorMatcher->knnMatch(b, a, matches, 2);
56   -
57   - QList<float> distances;
58   - foreach (const std::vector<DMatch> &match, matches) {
59   - if (match[0].distance / match[1].distance > maxRatio) continue;
60   - distances.append(match[0].distance);
61   - }
62   - qSort(distances);
63   -
64   - float similarity = 0;
65   - for (int i=0; i<distances.size(); i++)
66   - similarity += 1.f/(1+distances[i])/(i+1);
67   - return similarity;
68   - }
69   -};
70   -
71   -BR_REGISTER(Distance, KeyPointMatcherDistance)
72   -
73   -} // namespace br
74   -
75   -#include "distance/keypointmatcher.moc"