Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

[e976b6]: src / hugin_base / algorithms / control_points / FeatureMatchingSingleKdTree.cpp Maximize Restore History

Download this file

FeatureMatchingSingleKdTree.cpp    54 lines (42 with data), 1.5 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* FeatureMatchingSingleKdTree.cpp
* gsoc2008_feature_matching
*
* @author Onur Kucuktunc <onurcc@gmail.com>
*/
#include "FeatureMatchingSingleKdTree.h"
namespace HuginBase {
using namespace std;
using namespace hugin_utils;
// matching function
static HuginBase::FPMVector& FeatureMatchingSingleKdTree::match(const PanoramaData& pano) {
FPMVector allMatches;
// prepare kd tree
KDTreeKeypointMatcher matcher;
matcher.create(pano);
// keep track of matched points, to avoid re-matching them.
UIntSet matchedPoints;
// for each image in panorama
for (int im=0; im < pano.getNrOfImages(); im++)
{
// for each keypoint in this image
const std::vector<Keypoint> & keypoints = pano.getImage(*it).getKeypoints();
for (vector<Keypoint>::const_iterator itkey=keypoints.begin();
itkey != keypoints.end(); ++itkey)
{
// do not try to match this point, if it has already been matched.
if (set_contains(matchedPoints, pnr)) continue;
// find the nearest matching point
ImageKeypoint onematch = matcher.match(*itkey, *it);
if (onematch != NULL)
allMatches.push_back(FeaturePointMatch(im, onematch.imageNr, itkey, onematch.keypoint));
// mark matched points and remove them from further matching.
for (unsigned j=0; j < matches.size(); j++) {
// mark controlpoint as matched.
matchedPoints.insert(matcher.getKeypointIdxOfMatch(j));
}
}
}
return allMatches;
}
}