30 Led::Led(LedIdentifier *identifier, LedMeasurement
const &meas)
31 : m_id(SENTINEL_NO_IDENTIFIER_OBJECT_OR_INSUFFICIENT_DATA),
32 m_identifier(identifier) {
39 m_latestMeasurement = meas;
40 m_brightnessHistory.push_back(meas.brightness);
45 m_id = SENTINEL_NO_IDENTIFIER_OBJECT_OR_INSUFFICIENT_DATA;
48 m_id = m_identifier->
getId(m_id, m_brightnessHistory, m_lastBright,
51 m_newlyRecognized = oldId < 0 && m_id >= 0;
52 auto lostRecognition = m_id < 0 && oldId >= 0;
53 if (!m_newlyRecognized && !lostRecognition && oldId != m_id) {
54 std::cout <<
"Identity theft detected!" << std::endl;
66 m_novelty = MAX_NOVELTY;
67 }
else if (m_novelty != 0) {
75 double threshold)
const {
77 if (keypoints.empty()) {
78 return end(keypoints);
82 auto thresholdSquared = threshold * threshold;
85 auto computeDistSquared = [location](KeyPointIterator it) {
86 auto diff = (location - it->pt);
87 return diff.dot(diff);
92 auto ret = begin(keypoints);
93 auto minDistSq = computeDistSquared(ret);
97 for (
auto it = begin(keypoints), e = end(keypoints); it != e; ++it) {
98 auto distSq = computeDistSquared(it);
99 if (distSq < minDistSq) {
107 if (minDistSq <= thresholdSquared) {
110 return end(keypoints);
114 double threshold)
const {
121 auto thresholdSquared = threshold * threshold;
124 auto computeDistSquared = [location](LedMeasurementIterator it) {
125 auto diff = (location - it->loc);
126 return diff.dot(diff);
131 auto ret = begin(meas);
132 auto minDistSq = computeDistSquared(ret);
136 for (
auto it = begin(meas), e = end(meas); it != e; ++it) {
137 auto distSq = computeDistSquared(it);
138 if (distSq < minDistSq) {
146 if (minDistSq <= thresholdSquared) {
153 m_id = SENTINEL_NO_IDENTIFIER_OBJECT_OR_INSUFFICIENT_DATA;
154 if (!m_brightnessHistory.empty()) {
155 m_brightnessHistory.clear();
156 m_brightnessHistory.push_back(getMeasurement().brightness);
cv::Point2f getLocation() const
Reports the most-recently-added position.
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...
Led(LedIdentifier *identifier, LedMeasurement const &meas)
Header file for class that tracks and identifies LEDs.
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...
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...