OSVR Framework (Internal Development Docs)  0.6-1962-g59773924
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
LED.cpp
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 #include "LED.h"
26 
27 namespace osvr {
28 namespace vbtracker {
29 
30  Led::Led(LedIdentifier *identifier, LedMeasurement const &meas)
31  : m_identifier(identifier) {
34  addMeasurement(meas, false);
35  }
36 
37  void Led::addMeasurement(LedMeasurement const &meas, bool blobsKeepId) {
38  m_latestMeasurement = meas;
39  m_brightnessHistory.push_back(meas.brightness);
40 
41  // If we don't have an identifier, then our ID is unknown.
42  // Otherwise, try and find it.
43  if (!m_identifier) {
44  m_id = ZeroBasedBeaconId(SENTINEL_NO_IDENTIFIER_OBJECT);
45  } else {
46  auto const oldId = m_id;
47  m_id = m_identifier->getId(m_id, m_brightnessHistory, m_lastBright,
48  blobsKeepId);
49  using Id = ZeroBasedBeaconId;
50  if (Id(SENTINEL_MARKED_MISIDENTIFIED) == oldId &&
51  (Id(SENTINEL_NO_IDENTIFIER_OBJECT_OR_INSUFFICIENT_DATA) ==
52  m_id ||
53  Id(SENTINEL_NO_PATTERN_RECOGNIZED_DESPITE_SUFFICIENT_DATA) ==
54  m_id)) {
58  m_id = Id(SENTINEL_MARKED_MISIDENTIFIED);
59  }
60 
63 
66  if (oldId != m_id) {
68  m_novelty = MAX_NOVELTY;
69  } else if (m_novelty != 0) {
71  m_novelty--;
72  }
73  }
74  }
75 
77  m_id = ZeroBasedBeaconId(SENTINEL_MARKED_MISIDENTIFIED);
78  if (!m_brightnessHistory.empty()) {
79  m_brightnessHistory.clear();
80  m_brightnessHistory.push_back(getMeasurement().brightness);
81  }
82  }
83 
84 } // End namespace vbtracker
85 } // End namespace osvr
Led(LedIdentifier *identifier, LedMeasurement const &meas)
Definition: LED.cpp:30
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
Header file for class that tracks and identifies LEDs.
void markMisidentified()
Definition: LED.cpp:76
Brightness brightness
"Brightness" - currently actually diameter.
Helper class to identify an LED based on its pattern of brightness over time. The base class defines ...
Definition: LedIdentifier.h:53
virtual ZeroBasedBeaconId getId(ZeroBasedBeaconId currentId, BrightnessList &brightnesses, bool &lastBright, bool blobsKeepId) const =0
Determine the identity of the LED whose brightness pattern is passed in. Truncates the passed-in list...