OSVR-Core
Public Types | Public Member Functions | Static Public Attributes | List of all members
osvr::vbtracker::Led Class Reference

Helper class to keep track of the state of a blob over time. More...

#include <LED.h>

Public Types

typedef int ID
 

Public Member Functions

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 measurement, so that the encoding of brightness and darkness can be used to identify it. More...
 
LedMeasurement const & getMeasurement () const
 
ZeroBasedBeaconId getID () const
 Tells which LED I am. More...
 
OneBasedBeaconId getOneBasedID () const
 Gets either the raw negative sentinel ID or a 1-based ID (for display purposes)
 
bool identified () const
 Do we have a positive identification as a known LED?
 
uint8_t novelty () const
 Returns a value (decreasing per frame from some maximum down to a minimum of zero) indicating how new the identification of this blob with its current ID is. More...
 
cv::Point2f getLocation () const
 Reports the most-recently-added position.
 
cv::Point2f getInverseLocation () const
 Gets the most-recently-added position, in a xy-origin-at-bottom-left coordinate system.
 
cv::Point2f getLocationForTracking () const
 Gets the most-recently-added position in the coordinate system to be used for tracking. More...
 
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 threshold. More...
 
LedMeasurementVecIterator nearest (LedMeasurementVec &meas, double threshold) const
 
bool isBright () const
 Returns the most-recent boolean "bright" state according to the LED identifier. More...
 
bool wasUsedLastFrame () const
 Used for a status display in debug windows.
 
void markAsUsed ()
 Call from inside the tracking algorithm to mark that it was used.
 
void resetUsed ()
 
void markMisidentified ()
 Called from within pose estimation or elsewhere with model-based knowledge that can refute the identification of this blob. More...
 
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 measurement, so that the encoding of brightness and darkness can be used to identify it. More...
 
LedMeasurement const & getMeasurement () const
 
int getID () const
 Tells which LED I am. More...
 
int getOneBasedID () const
 Gets either the raw negative sentinel ID or a 1-based ID (for display purposes)
 
bool identified () const
 Do we have a positive identification as a known LED?
 
uint8_t novelty () const
 Returns a value (decreasing per frame from some maximum down to a minimum of zero) indicating how new the identification of this blob with its current ID is. More...
 
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 threshold. More...
 
LedMeasurementIterator nearest (LedMeasurementList &meas, double threshold) const
 
bool isBright () const
 Returns the most-recent boolean "bright" state according to the LED identifier. More...
 
bool wasUsedLastFrame () const
 Used for a status display in debug windows.
 
void markAsUsed ()
 Call from inside the tracking algorithm to mark that it was used.
 
void resetUsed ()
 
void markMisidentified ()
 Called from within pose estimation or elsewhere with model-based knowledge that can refute the identification of this blob. More...
 
Constructors

Constructor takes initial values for the location and brightness, and a pointer to an object that will be used to identify the LEDs based on their brightness over time.

 Led (LedIdentifier *identifier, LedMeasurement const &meas)
 
 Led (LedIdentifier *identifier, LedMeasurement const &meas)
 

Static Public Attributes

static const int SENTINEL_NO_IDENTIFIER_OBJECT_OR_INSUFFICIENT_DATA
 
static const int SENTINEL_INSUFFICIENT_EXTREMA_DIFFERENCE = -2
 
static const int SENTINEL_NO_PATTERN_RECOGNIZED_DESPITE_SUFFICIENT_DATA = -3
 
static const int SENTINEL_NO_IDENTIFIER_OBJECT = -4
 
static const int SENTINEL_MARKED_MISIDENTIFIED = -5
 
static const uint8_t MAX_NOVELTY = 4
 
static const ID SENTINEL_NO_IDENTIFIER_OBJECT_OR_INSUFFICIENT_DATA = -1
 
static const ID SENTINEL_INSUFFICIENT_EXTREMA_DIFFERENCE = -2
 
static const ID SENTINEL_NO_PATTERN_RECOGNIZED_DESPITE_SUFFICIENT_DATA
 

Detailed Description

Helper class to keep track of the state of a blob over time.

This is used to help determine the identity of each LED in the scene. The LEDs are identified by their blink codes. A steady one is presumed to be a light source.

Constructor & Destructor Documentation

§ Led()

osvr::vbtracker::Led::Led ( LedIdentifier identifier,
LedMeasurement const &  meas 
)

Doesn't matter what the blobs keep ID pref is here, because this is a new blob so there's no ID to keep.

Doesn't matter what the blobs keep ID pref is here, because this is a new blob so there's no ID to keep.

Member Function Documentation

§ addMeasurement() [1/2]

void osvr::vbtracker::Led::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 measurement, so that the encoding of brightness and darkness can be used to identify it.

Parameters
measA number of measurement parameters, of which only brightness and location are used in identifying beacon patterns. brightness is an abstract quantity that is fed into the identity detector; it may be area or summed brightness or another useful estimate of the LED state. The other parameters are carried along in the hope that they may be useful to later code. (For instance, not all identified beacons may be good choices to use in determining tracking pose)

§ addMeasurement() [2/2]

void osvr::vbtracker::Led::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 measurement, so that the encoding of brightness and darkness can be used to identify it.

Parameters
measA number of measurement parameters, of which only brightness and location are used in identifying beacon patterns. brightness is an abstract quantity that is fed into the identity detector; it may be area or summed brightness or another useful estimate of the LED state. The other parameters are carried along in the hope that they may be useful to later code. (For instance, not all identified beacons may be good choices to use in determining tracking pose)

Make the "misidentified" sentinel a little stickier than "insufficient data" or "no pattern recognized" so we can see it on the debug view.

Todo:
Identify "theft" is possible and takes place - right now it's handled just the same as any other change in ID.

Right now, any change in ID is considered being "newly recognized".

If newly recognized, start at max novelty

Novelty decays linearly to 0

Todo:
it seems like LEDs are re-recognized every frame? so presumably it's possible that oldId != m_id without one being a sentinel.

Right now, any change in ID is considered being "newly recognized".

If newly recognized, start at max novelty

Novelty decays linearly to 0

§ getID() [1/2]

int osvr::vbtracker::Led::getID ( ) const
inline

Tells which LED I am.

  • An index of -1 means not yet determined.
  • An index below -1 means known not to be an LED (different identifiers use different codes to differentiate between cases).
  • An index of 0 or higher is determined based on the flash pattern.

§ getID() [2/2]

ZeroBasedBeaconId osvr::vbtracker::Led::getID ( ) const
inline

Tells which LED I am.

  • An index of -1 means not yet determined.
  • An index below -1 means known not to be an LED (different identifiers use different codes to differentiate between cases).
  • An index of 0 or higher is determined based on the flash pattern.

§ getLocationForTracking()

cv::Point2f osvr::vbtracker::Led::getLocationForTracking ( ) const
inline

Gets the most-recently-added position in the coordinate system to be used for tracking.

Provides a centralized place to switch between getLocation() and getInverseLocation() for tracking purposes.

§ isBright() [1/2]

bool osvr::vbtracker::Led::isBright ( ) const
inline

Returns the most-recent boolean "bright" state according to the LED identifier.

Note that the value is only meaningful if identified() is true.

§ isBright() [2/2]

bool osvr::vbtracker::Led::isBright ( ) const
inline

Returns the most-recent boolean "bright" state according to the LED identifier.

Note that the value is only meaningful if identified() is true.

§ markMisidentified() [1/2]

void osvr::vbtracker::Led::markMisidentified ( )

Called from within pose estimation or elsewhere with model-based knowledge that can refute the identification of this blob.

§ markMisidentified() [2/2]

void osvr::vbtracker::Led::markMisidentified ( )

Called from within pose estimation or elsewhere with model-based knowledge that can refute the identification of this blob.

§ nearest() [1/4]

KeyPointIterator osvr::vbtracker::Led::nearest ( KeyPointList &  keypoints,
double  threshold 
) const

Find the nearest KeyPoint from a container of points to me, if there is one within the specified threshold.

Runtime: O(n) where n is the number of elements in keypoints.

Returns
end() if there is not a nearest within threshold (or an empty container).

§ nearest() [2/4]

LedMeasurementIterator osvr::vbtracker::Led::nearest ( LedMeasurementList &  meas,
double  threshold 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

§ nearest() [3/4]

KeyPointIterator osvr::vbtracker::Led::nearest ( KeyPointList &  keypoints,
double  threshold 
) const

Find the nearest KeyPoint from a container of points to me, if there is one within the specified threshold.

Runtime: O(n) where n is the number of elements in keypoints.

Returns
end() if there is not a nearest within threshold (or an empty container).

§ nearest() [4/4]

LedMeasurementIterator osvr::vbtracker::Led::nearest ( LedMeasurementVec &  meas,
double  threshold 
) const

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

§ novelty() [1/2]

uint8_t osvr::vbtracker::Led::novelty ( ) const
inline

Returns a value (decreasing per frame from some maximum down to a minimum of zero) indicating how new the identification of this blob with its current ID is.

This can be used to compensate for accidental mis-identifications, identity switching, or the simple fact that new identifications might contain highly novel information that would otherwise "shock" the tracked state.

§ novelty() [2/2]

uint8_t osvr::vbtracker::Led::novelty ( ) const
inline

Returns a value (decreasing per frame from some maximum down to a minimum of zero) indicating how new the identification of this blob with its current ID is.

This can be used to compensate for accidental mis-identifications, identity switching, or the simple fact that new identifications might contain highly novel information that would otherwise "shock" the tracked state.

Member Data Documentation

§ SENTINEL_NO_IDENTIFIER_OBJECT_OR_INSUFFICIENT_DATA

const int osvr::vbtracker::Led::SENTINEL_NO_IDENTIFIER_OBJECT_OR_INSUFFICIENT_DATA
static
Initial value:
=
-1

§ SENTINEL_NO_PATTERN_RECOGNIZED_DESPITE_SUFFICIENT_DATA

const ID osvr::vbtracker::Led::SENTINEL_NO_PATTERN_RECOGNIZED_DESPITE_SUFFICIENT_DATA
static
Initial value:
=
-3

The documentation for this class was generated from the following files: