Berkeley SfM
keypoint_detector.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015, The Regents of the University of California (Regents).
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above
13  * copyright notice, this list of conditions and the following
14  * disclaimer in the documentation and/or other materials provided
15  * with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived
19  * from this software without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS AS IS
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
25  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31  * POSSIBILITY OF SUCH DAMAGE.
32  *
33  * Please contact the author(s) of this library if you have any questions.
34  * Authors: Erik Nelson ( eanelson@eecs.berkeley.edu )
35  * David Fridovich-Keil ( dfk@eecs.berkeley.edu )
36  */
37 
38 #ifndef BSFM_IMAGE_KEYPOINT_DETECTOR_H
39 #define BSFM_IMAGE_KEYPOINT_DETECTOR_H
40 
41 #include <opencv2/features2d/features2d.hpp>
42 #include <opencv2/nonfree/nonfree.hpp>
43 #include <string>
44 
45 #include "../image/image.h"
46 #include "../util/disallow_copy_and_assign.h"
47 #include "../util/types.h"
48 
49 namespace bsfm {
50 
52  public:
55 
56  // The detector must be set prior to calling DetectKeypoints().
57  bool SetDetector(const std::string& detector_type);
58 
59  // Detects keypoints in the input image, returning them in the output list.
60  bool DetectKeypoints(const Image& image, KeypointList& keypoints_out);
61 
62  // Turn on adaptive feature counts. Only works if the detector type is FAST,
63  // SURF, or STAR.
64  // - min: minimum desired number of features.
65  // - max: maximum desired number of features.
66  // - iters: number of iterations spend adjusting the feature detector
67  // parameters. High numbers are fine for FAST, but time consuming
68  // for SURF and STAR.
69  void SetAdaptiveOn(unsigned int min, unsigned int max, unsigned int iters);
70  void SetAdaptiveOff();
71 
72  // Return whether or not the detector_type supports adaptive feature count
73  // adjustment.
74  bool SupportsAdaptiveAdjustment() const;
75 
76  private:
78 
80  cv::Ptr<cv::FeatureDetector> detector_;
81  bool adaptive_;
82 
83  // Adaptive feature count parameters. See 'SetAdaptiveOn()' for descriptions.
84  unsigned int adaptive_min_;
85  unsigned int adaptive_max_;
86  unsigned int adaptive_iters_;
87 
88 }; //\class KeypointDetector
89 
90 } //\namespace bsfm
91 #endif
bool DetectKeypoints(const Image &image, KeypointList &keypoints_out)
STL namespace.
cv::Ptr< cv::FeatureDetector > detector_
bool SupportsAdaptiveAdjustment() const
::std::vector< Keypoint > KeypointList
Definition: types.h:80
bool SetDetector(const std::string &detector_type)
Definition: camera.cpp:50
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
void SetAdaptiveOn(unsigned int min, unsigned int max, unsigned int iters)