OSVR-Core
SBDBlobExtractor.h
Go to the documentation of this file.
1 
11 // Copyright 2015 Sensics, Inc.
12 //
13 // Licensed under the Apache License, Version 2.0 (the "License");
14 // you may not use this file except in compliance with the License.
15 // You may obtain a copy of the License at
16 //
17 // http://www.apache.org/licenses/LICENSE-2.0
18 //
19 // Unless required by applicable law or agreed to in writing, software
20 // distributed under the License is distributed on an "AS IS" BASIS,
21 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22 // See the License for the specific language governing permissions and
23 // limitations under the License.
24 
25 #ifndef INCLUDED_SBDBlobExtractor_h_GUID_E67E1F86_F827_48A3_5FA2_F9F241BA79AF
26 #define INCLUDED_SBDBlobExtractor_h_GUID_E67E1F86_F827_48A3_5FA2_F9F241BA79AF
27 
28 // Internal Includes
29 #include "BlobParams.h"
31 #include "GenericBlobExtractor.h"
32 #include "LedMeasurement.h"
33 
34 // Library/third-party includes
35 #include <opencv2/features2d/features2d.hpp>
36 
37 // Standard includes
38 #include <vector>
39 
40 namespace osvr {
41 namespace vbtracker {
42  class KeypointDetailer;
43 
46  public:
48  explicit SBDBlobExtractor(BlobParams const &blobParams);
51  SBDBlobExtractor(BlobParams const &blobParams,
52  EdgeHoleParams const &extParams);
54  LedMeasurementVec const &extractBlobs(cv::Mat const &grayImage);
55 
56  enum class Algo { SimpleBlobDetector, EdgeHoleExtractor };
57 
58  Algo getAlgo() const { return m_algo; }
59 
62  cv::Mat const &getDebugThresholdImage();
63 
64  cv::Mat const &getDebugBlobImage();
65 #if 0
66  cv::Mat const &getDebugExtraImage();
67 #endif
68  private:
69  void getKeypoints(cv::Mat const &grayImage);
70  cv::Mat generateDebugThresholdImage() const;
71  cv::Mat generateDebugBlobImage() const;
72 
73  Algo m_algo;
74  BlobParams m_params;
75  EdgeHoleBasedLedExtractor m_extractor;
76  cv::SimpleBlobDetector::Params m_sbdParams;
77  LedMeasurementVec m_latestMeasurements;
78 
79  std::vector<cv::KeyPoint> m_keyPoints;
80 
81 #if 0
82  std::unique_ptr<KeypointDetailer> m_keypointDetailer;
83 #endif
84  cv::Mat m_lastGrayImage;
85 
86  bool m_debugThresholdImageDirty = true;
87  cv::Mat m_debugThresholdImage;
88 
89  bool m_debugBlobImageDirty = true;
90  cv::Mat m_debugBlobImage;
91 #if 0
92  cv::Mat m_extraImage;
93 #endif
94  };
95 
97  public:
98  SBDGenericBlobExtractor(BlobParams const &blobParams);
99  ~SBDGenericBlobExtractor() override = default;
100 
101  protected:
102  cv::Mat generateDebugThresholdImage_() const override;
103  cv::Mat generateDebugBlobImage_() const override;
104  LedMeasurementVec extractBlobs_() override;
105 
106  private:
107  void getKeypoints(cv::Mat const &grayImage);
108  BlobParams m_params;
109  std::vector<cv::KeyPoint> m_keyPoints;
110  cv::SimpleBlobDetector::Params m_sbdParams;
111  };
112 
113  BlobExtractorPtr makeBlobExtractor(BlobParams const &blobParams);
114 } // namespace vbtracker
115 } // namespace osvr
116 
117 #endif // INCLUDED_SBDBlobExtractor_h_GUID_E67E1F86_F827_48A3_5FA2_F9F241BA79AF
SBDBlobExtractor(BlobParams const &blobParams)
Construct with just BlobParams: uses simple blob detector.
Definition: SBDBlobExtractor.cpp:197
Definition: EdgeHoleBasedLedExtractor.h:70
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
LedMeasurementVec const & extractBlobs(cv::Mat const &grayImage)
Definition: SBDBlobExtractor.cpp:236
Definition: BlobParams.h:93
~SBDBlobExtractor()
Definition: SBDBlobExtractor.cpp:231
BlobExtractorPtr makeBlobExtractor(BlobParams const &blobParams, EdgeHoleParams const &extParams)
If passing an EdgeHoleParams object, then call the EdgeHoldBlobExtractor factory. ...
Definition: EdgeHoleBlobExtractor.h:64
cv::Mat const & getDebugThresholdImage()
In the case of the EdgeHoleExtractor, this is actually the edge detection image.
Definition: SBDBlobExtractor.cpp:349
A class performing blob-extraction duties on incoming frames.
Definition: SBDBlobExtractor.h:45
Blob detection configuration parameters.
Definition: BlobParams.h:40
Definition: SBDBlobExtractor.h:96
This is an interface/base class for blob extractors that have the ability to provide graphical debug ...
Definition: GenericBlobExtractor.h:43
Header.