From a80ebf3ee72e48244d0c6ed78857cfa2fbb6a881 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tomas=20Wenstr=C3=B6m?= Date: Sun, 11 Aug 2019 12:32:33 +0200 Subject: [PATCH] Made saturation configuration --- src/kaka/cakelight/Configuration.java | 2 ++ src/kaka/cakelight/VideoFrame.java | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/kaka/cakelight/Configuration.java b/src/kaka/cakelight/Configuration.java index a68bb39..51b2a00 100644 --- a/src/kaka/cakelight/Configuration.java +++ b/src/kaka/cakelight/Configuration.java @@ -53,6 +53,7 @@ public class Configuration { public int height; public int bpp; public int format; + public double saturation; public CropConfiguration crop; public ListConfiguration list; @@ -70,6 +71,7 @@ public class Configuration { default: format = Imgproc.COLOR_YUV2BGR_UYVY; } + saturation = Double.parseDouble(get(prop, "video.saturation", "0.5")); crop = new CropConfiguration(prop); list = new ListConfiguration(prop); } diff --git a/src/kaka/cakelight/VideoFrame.java b/src/kaka/cakelight/VideoFrame.java index 6435242..931237d 100644 --- a/src/kaka/cakelight/VideoFrame.java +++ b/src/kaka/cakelight/VideoFrame.java @@ -104,7 +104,10 @@ public class VideoFrame { private Color wrappedGetLedColor(ListPosition listPosition, int xy) { Color c = getLedColor(listPosition, xy); double[] hsv = c.toHSV(); - return Color.hsv(hsv[0], 1, 1); + double saturation = config.video.saturation >= 0.5 + ? hsv[1] + (config.video.saturation - 0.5) * 2 * (1 - hsv[1]) + : hsv[1] - (1 - config.video.saturation * 2) * hsv[1]; + return Color.hsv(hsv[0], saturation, hsv[2]); } private Color getLedColor(ListPosition listPosition, int xy) { -- 2.11.0