@brief Helper for implementations of LedIdentifier to turn a brightness list into a boolean list based on thresholding on the halfway point between minimum and maximum brightness.
| 63 | /// brightness list into a boolean list based on thresholding on the |
| 64 | /// halfway point between minimum and maximum brightness. |
| 65 | inline LedPattern getBitsUsingThreshold(const BrightnessList &brightnesses, |
| 66 | float threshold) { |
| 67 | LedPattern ret; |
| 68 | // Allocate output space for our transform. |
| 69 | ret.resize(brightnesses.size()); |
| 70 | |
| 71 | // Transform the brightnesses into a container of bools using this |
| 72 | // little lambda |
| 73 | std::transform( |
| 74 | begin(brightnesses), end(brightnesses), begin(ret), |
| 75 | [threshold](Brightness val) { return val >= threshold; }); |
| 76 | |
| 77 | return ret; |
| 78 | } |
| 79 | } // End namespace vbtracker |
| 80 | } // End namespace osvr |
| 81 |