1 /*
2 * Copyright (C) 2007-2008 Anael Orlinski
3 *
4 * This file is part of Panomatic.
5 *
6 * Panomatic is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * Panomatic is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with Panomatic; if not, write to the Free Software
18 * <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef __lfeat_keypointdetector_h
22 #define __lfeat_keypointdetector_h
23 
24 #include "Image.h"
25 #include "KeyPoint.h"
26 
27 namespace lfeat
28 {
29 
30 class KeyPointInsertor
31 {
32 public:
33     virtual void operator()(const KeyPoint& k) = 0;
34 };
35 
36 class LFIMPEX KeyPointDetector
37 {
38 public:
39     // default constructor
40     KeyPointDetector();
41 
42     // setters for various parameters
setMaxScales(unsigned int iMaxScales)43     inline void setMaxScales(unsigned int iMaxScales)
44     {
45         _maxScales = iMaxScales;
46     }
setMaxOctaves(unsigned int iMaxOctaves)47     inline void setMaxOctaves(unsigned int iMaxOctaves)
48     {
49         _maxOctaves = iMaxOctaves;
50     }
setScoreThreshold(double iThreshold)51     inline void setScoreThreshold(double iThreshold)
52     {
53         _scoreThreshold = iThreshold;
54     }
55 
56     // detect keypoints and put them in the insertor
57     void detectKeypoints(Image& iImage, KeyPointInsertor& iInsertor);
58 
59 private:
60 
61     // internal values of the keypoint detector
62 
63     // number of scales
64     unsigned int					_maxScales;
65 
66     // number of octaves
67     unsigned int					_maxOctaves;
68 
69     // detection score threshold
70     double							_scoreThreshold;
71 
72     // initial box filter size
73     unsigned int					_initialBoxFilterSize;
74 
75     // scale overlapping : how many filter sizes to overlap
76     // with default value 3 : [3,5,7,9,11][7,11,15,19,23][...
77     unsigned int					_scaleOverlap;
78 
79     // some default values.
80     const static double kBaseSigma;
81 
82     bool fineTuneExtrema(double** * iSH, unsigned int iX, unsigned int iY, unsigned int iS,
83                          double& oX, double& oY, double& oS, double& oScore,
84                          unsigned int iOctaveWidth, unsigned int iOctaveHeight, unsigned int iBorder);
85 
86     bool calcTrace(Image& iImage, double iX, double iY, double iScale, int& oTrace);
87 
88     unsigned int		getFilterSize(unsigned int iOctave, unsigned int iScale);
89     unsigned int		getBorderSize(unsigned int iOctave, unsigned int iScale);
90 
91 };
92 
93 }
94 
95 #endif //__lfeat_keypointdetector_h
96