blob: d58dec89cc795cd2fee350e34267f40fdd739538 [file] [log] [blame]
Brian Silvermanf1196122020-01-16 00:41:54 -08001#ifndef Y2020_VISION_SIFT_SIFT971_H_
2#define Y2020_VISION_SIFT_SIFT971_H_
3
4#include <vector>
5
6#include <opencv2/core/types.hpp>
7#include <opencv2/features2d.hpp>
8
9namespace frc971 {
10namespace vision {
11
12/*!
13 SIFT implementation.
14
15 The class implements SIFT algorithm by D. Lowe.
16 */
17class SIFT971_Impl : public cv::Feature2D {
18 public:
19 explicit SIFT971_Impl(int nfeatures = 0, int nOctaveLayers = 3,
20 double contrastThreshold = 0.04,
21 double edgeThreshold = 10, double sigma = 1.6);
22
23 //! returns the descriptor size in floats (128)
24 int descriptorSize() const override;
25
26 //! returns the descriptor type
27 int descriptorType() const override;
28
29 //! returns the default norm type
30 int defaultNorm() const override;
31
32 //! finds the keypoints and computes descriptors for them using SIFT
33 //! algorithm. Optionally it can compute descriptors for the user-provided
34 //! keypoints
35 void detectAndCompute(cv::InputArray img, cv::InputArray mask,
36 std::vector<cv::KeyPoint> &keypoints,
37 cv::OutputArray descriptors,
38 bool useProvidedKeypoints = false) override;
39
40 void buildGaussianPyramid(const cv::Mat &base, std::vector<cv::Mat> &pyr,
41 int nOctaves) const;
42 void buildDoGPyramid(const std::vector<cv::Mat> &pyr,
43 std::vector<cv::Mat> &dogpyr) const;
44 void findScaleSpaceExtrema(const std::vector<cv::Mat> &gauss_pyr,
45 const std::vector<cv::Mat> &dog_pyr,
46 std::vector<cv::KeyPoint> &keypoints) const;
47
48 protected:
49 CV_PROP_RW int nfeatures;
50 CV_PROP_RW int nOctaveLayers;
51 CV_PROP_RW double contrastThreshold;
52 CV_PROP_RW double edgeThreshold;
53 CV_PROP_RW double sigma;
54};
55
56} // namespace vision
57} // namespace frc971
58
59#endif // Y2020_VISION_SIFT_SIFT971_H_