OSVR-Core
LED.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_LED_h_GUID_C53E1134_AD6B_46B0_4808_19C7EAA7D0EC
26 #define INCLUDED_LED_h_GUID_C53E1134_AD6B_46B0_4808_19C7EAA7D0EC
27 
28 // Internal Includes
29 #include "LedMeasurement.h"
30 #include "LedIdentifier.h"
31 
32 // Library/third-party includes
33 #include <opencv2/core/core.hpp>
34 
35 // Standard includes
36 #include <vector>
37 
38 namespace osvr {
39 namespace vbtracker {
40 
45  class Led {
46  public:
52  Led(LedIdentifier *identifier, LedMeasurement const &meas);
54  typedef int ID;
55 
56  static const ID SENTINEL_NO_IDENTIFIER_OBJECT_OR_INSUFFICIENT_DATA = -1;
57  static const ID SENTINEL_INSUFFICIENT_EXTREMA_DIFFERENCE = -2;
58  static const ID SENTINEL_NO_PATTERN_RECOGNIZED_DESPITE_SUFFICIENT_DATA =
59  -3;
60  static const uint8_t MAX_NOVELTY = 4;
72  void addMeasurement(LedMeasurement const &meas, bool blobsKeepId);
73 
74  LedMeasurement const &getMeasurement() const {
75  return m_latestMeasurement;
76  }
77 
84  int getID() const { return m_id; }
85 
88  int getOneBasedID() const { return (m_id < 0) ? m_id : m_id + 1; }
89 
91  bool identified() const { return !(m_id < 0); }
92 
99  uint8_t novelty() const { return m_novelty; }
100 
102  cv::Point2f getLocation() const { return m_latestMeasurement.loc; }
103 
109  KeyPointIterator nearest(KeyPointList &keypoints,
110  double threshold) const;
111 
113  LedMeasurementIterator nearest(LedMeasurementList &meas,
114  double threshold) const;
115 
119  bool isBright() const { return m_lastBright; }
120 
122  bool wasUsedLastFrame() const { return m_wasUsedLastFrame; }
123 
125  void markAsUsed() { m_wasUsedLastFrame = true; }
126 
127  void resetUsed() { m_wasUsedLastFrame = false; }
128 
131  void markMisidentified();
132 
133  private:
135  LedMeasurement m_latestMeasurement;
136 
138  BrightnessList m_brightnessHistory;
139 
142  int m_id;
143 
145  LedIdentifier *m_identifier;
146 
148  bool m_lastBright = false;
149 
150  bool m_newlyRecognized = false;
151  uint8_t m_novelty;
152 
153  bool m_wasUsedLastFrame = false;
154  };
155 
156 } // End namespace vbtracker
157 } // End namespace osvr
158 
159 #endif // INCLUDED_LED_h_GUID_C53E1134_AD6B_46B0_4808_19C7EAA7D0EC
void markAsUsed()
Call from inside the tracking algorithm to mark that it was used.
Definition: LED.h:125
Header file for class that identifies LEDs based on blink codes.
The main namespace for all C++ elements of the framework, internal and external.
Definition: namespace_osvr.dox:3
Led(LedIdentifier *identifier, LedMeasurement const &meas)
Definition: LED.cpp:30
uint8_t novelty() const
Returns a value (decreasing per frame from some maximum down to a minimum of zero) indicating how new...
Definition: LED.h:99
void addMeasurement(LedMeasurement const &meas, bool blobsKeepId)
Add a new measurement for this LED, which must be for a frame that is just following the previous mea...
Definition: LED.cpp:37
void markMisidentified()
Called from within pose estimation or elsewhere with model-based knowledge that can refute the identi...
Definition: LED.cpp:76
bool isBright() const
Returns the most-recent boolean "bright" state according to the LED identifier.
Definition: LED.h:119
cv::Point2f loc
Location in image space - should be undistorted when passed to the Led class.
Definition: LedMeasurement.h:77
cv::Point2f getLocation() const
Reports the most-recently-added position.
Definition: LED.h:102
int getOneBasedID() const
Gets either the raw negative sentinel ID or a 1-based ID (for display purposes)
Definition: LED.h:88
bool wasUsedLastFrame() const
Used for a status display in debug windows.
Definition: LED.h:122
bool identified() const
Do we have a positive identification as a known LED?
Definition: LED.h:91
Definition: LedMeasurement.h:41
int getID() const
Tells which LED I am.
Definition: LED.h:84
KeyPointIterator nearest(KeyPointList &keypoints, double threshold) const
Find the nearest KeyPoint from a container of points to me, if there is one within the specified thre...
Definition: LED.cpp:74
Helper class to identify an LED based on its pattern of brightness over time.
Definition: LedIdentifier.h:53