@@ -128,10 +128,10 @@ namespace hyperion
128128 // / @return The vector containing the output
129129 // /
130130 template <typename Pixel_T>
131- std::vector<ColorRgb> getMeanLedColorSqrt (const Image<Pixel_T> & image) const
131+ std::vector<ColorRgb> getMeanSqrtLedColor (const Image<Pixel_T> & image) const
132132 {
133133 std::vector<ColorRgb> colors (_colorsMap.size (), ColorRgb{0 ,0 ,0 });
134- getMeanLedColorSqrt (image, colors);
134+ getMeanSqrtLedColor (image, colors);
135135 return colors;
136136 }
137137
@@ -143,7 +143,7 @@ namespace hyperion
143143 // / @param[out] ledColors The vector containing the output
144144 // /
145145 template <typename Pixel_T>
146- void getMeanLedColorSqrt (const Image<Pixel_T> & image, std::vector<ColorRgb> & ledColors) const
146+ void getMeanSqrtLedColor (const Image<Pixel_T> & image, std::vector<ColorRgb> & ledColors) const
147147 {
148148 if (_colorsMap.size () != ledColors.size ())
149149 {
@@ -239,18 +239,54 @@ namespace hyperion
239239 }
240240
241241 // /
242- // / Determines the dominant color using a k-means algorithm for each LED using the LED area mapping given
242+ // / Determines the dominant color of the image and assigns it to all LEDs
243+ // /
244+ // / @param[in] image The image from which to extract the led color
245+ // /
246+ // / @return The vector containing the output
247+ // /
248+ template <typename Pixel_T>
249+ std::vector<ColorRgb> getDominantUniLedColor (const Image<Pixel_T> & image) const
250+ {
251+ std::vector<ColorRgb> colors (_colorsMap.size (), ColorRgb{0 ,0 ,0 });
252+ getDominantUniLedColor (image, colors);
253+ return colors;
254+ }
255+
256+ // /
257+ // / Determines the dominant color of the image and assigns it to all LEDs
258+ // /
259+ // / @param[in] image The image from which to extract the LED colors
260+ // / @param[out] ledColors The vector containing the output
261+ // /
262+ template <typename Pixel_T>
263+ void getDominantUniLedColor (const Image<Pixel_T> & image, std::vector<ColorRgb> & ledColors) const
264+ {
265+ if (_colorsMap.size () != ledColors.size ())
266+ {
267+ Debug (_log, " ImageToLedsMap: colorsMap.size != ledColors.size -> %d != %d" , _colorsMap.size (), ledColors.size ());
268+ return ;
269+ }
270+
271+ // calculate dominant color
272+ const ColorRgb color = calculateDominantColor (image);
273+ // Update all LEDs with same color
274+ std::fill (ledColors.begin (),ledColors.end (), color);
275+ }
276+
277+ // /
278+ // / Determines the dominant color using a k-means algorithm for each LED using the LED area mapping given
243279 // / at construction.
244280 // /
245281 // / @param[in] image The image from which to extract the LED color
246282 // /
247283 // / @return The vector containing the output
248284 // /
249285 template <typename Pixel_T>
250- std::vector<ColorRgb> getDominantLedColorAdv (const Image<Pixel_T> & image) const
286+ std::vector<ColorRgb> getDominantAdvLedColor (const Image<Pixel_T> & image) const
251287 {
252288 std::vector<ColorRgb> colors (_colorsMap.size (), ColorRgb{0 ,0 ,0 });
253- getDominantLedColorAdv (image, colors);
289+ getDominantAdvLedColor (image, colors);
254290 return colors;
255291 }
256292
@@ -262,7 +298,7 @@ namespace hyperion
262298 // / @param[out] ledColors The vector containing the output
263299 // /
264300 template <typename Pixel_T>
265- void getDominantLedColorAdv (const Image<Pixel_T> & image, std::vector<ColorRgb> & ledColors) const
301+ void getDominantAdvLedColor (const Image<Pixel_T> & image, std::vector<ColorRgb> & ledColors) const
266302 {
267303 // Sanity check for the number of LEDs
268304 if (_colorsMap.size () != ledColors.size ())
@@ -280,6 +316,42 @@ namespace hyperion
280316 }
281317 }
282318
319+ // /
320+ // / Determines the dominant color of the image using a k-means algorithm and assigns it to all LEDs
321+ // /
322+ // / @param[in] image The image from which to extract the led color
323+ // /
324+ // / @return The vector containing the output
325+ // /
326+ template <typename Pixel_T>
327+ std::vector<ColorRgb> getDominantAdvUniLedColor (const Image<Pixel_T> & image) const
328+ {
329+ std::vector<ColorRgb> colors (_colorsMap.size (), ColorRgb{0 ,0 ,0 });
330+ getDominantAdvUniLedColor (image, colors);
331+ return colors;
332+ }
333+
334+ // /
335+ // / Determines the dominant color of the image using a k-means algorithm and assigns it to all LEDs
336+ // /
337+ // / @param[in] image The image from which to extract the LED colors
338+ // / @param[out] ledColors The vector containing the output
339+ // /
340+ template <typename Pixel_T>
341+ void getDominantAdvUniLedColor (const Image<Pixel_T> & image, std::vector<ColorRgb> & ledColors) const
342+ {
343+ if (_colorsMap.size () != ledColors.size ())
344+ {
345+ Debug (_log, " ImageToLedsMap: colorsMap.size != ledColors.size -> %d != %d" , _colorsMap.size (), ledColors.size ());
346+ return ;
347+ }
348+
349+ // calculate dominant color
350+ const ColorRgb color = calculateDominantColorAdv (image);
351+ // Update all LEDs with same color
352+ std::fill (ledColors.begin (),ledColors.end (), color);
353+ }
354+
283355 private:
284356
285357 Logger* _log;
0 commit comments