]> git.sesse.net Git - casparcg/blobdiff - protocol/amcp/AMCPCommandsImpl.cpp
[chroma key] Implemented much better chroma spill suppression using the HSV color...
[casparcg] / protocol / amcp / AMCPCommandsImpl.cpp
index b877bf90d4d2fc10924bd77f6c41b6b1b746293d..4b222b9c2c7f5213053d92e7f46cf3a7269d8a80 100644 (file)
@@ -1294,28 +1294,28 @@ std::wstring ANIMATION_SYNTAX = L" {[duration:int] {[tween:string]|linear}|0 lin
 void mixer_chroma_describer(core::help_sink& sink, const core::help_repository& repo)
 {
        sink.short_description(L"Enable chroma keying on a layer.");
-       sink.syntax(L"MIXER [video_channel:int]{-[layer:int]|-0} CHROMA {[enable:0,1] {[target_hue:float] [hue_width:float] [min_saturation:float] [min_brightness:float] [softness:float] [spill:float] [spill_darken:float] [show_mask:0,1]}}" + ANIMATION_SYNTAX);
+       sink.syntax(L"MIXER [video_channel:int]{-[layer:int]|-0} CHROMA {[enable:0,1] {[target_hue:float] [hue_width:float] [min_saturation:float] [min_brightness:float] [softness:float] [spill_suppress:float] [spill_suppress_saturation:float] [show_mask:0,1]}}" + ANIMATION_SYNTAX);
        sink.para()
                ->text(L"Enables or disables chroma keying on the specified video layer. Giving no parameters returns the current chroma settings.");
        sink.para()->text(L"The chroma keying is done in the HSB/HSV color space.");
        sink.para()->text(L"Parameters:");
        sink.definitions()
-               ->item(L"enable", L"0 to disable chroma keying on layer. The rest of the parameters should not be given when disabling.")
-               ->item(L"target_hue", L"The hue in degrees between 0-360 where the center of the hue window will open up.")
-               ->item(L"hue_width", L"The width of the hue window within 0.0-1.0 where 1.0 means 100% of 360 degrees around target_hue.")
-               ->item(L"min_saturation", L"The minimum saturation within 0.0-1.0 required for a color to be within the chroma window.")
-               ->item(L"min_brightness", L"The minimum brightness within 0.0-1.0 required for a color to be within the chroma window.")
-               ->item(L"softness", L"The softness of the chroma keying window.")
-               ->item(L"spill", L"Controls the amount of spill. A value of 1.0 does not suppress any spill. A lower value gradually turns the spill into grayscale and more transparent.")
-               ->item(L"spill_darken", L"Controls the shade of gray that the spill suppression is done towards. Lower values goes towards white and higher values goes towards black.")
-               ->item(L"show_mask", L"If enabled, only shows the mask. Useful while editing the chroma key settings.")
+               ->item(L"enable",                                               L"0 to disable chroma keying on layer. The rest of the parameters should not be given when disabling.")
+               ->item(L"target_hue",                                   L"The hue in degrees between 0-360 where the center of the hue window will open up.")
+               ->item(L"hue_width",                                            L"The width of the hue window within 0.0-1.0 where 1.0 means 100% of 360 degrees around target_hue.")
+               ->item(L"min_saturation",                               L"The minimum saturation within 0.0-1.0 required for a color to be within the chroma window.")
+               ->item(L"min_brightness",                               L"The minimum brightness within 0.0-1.0 required for a color to be within the chroma window.")
+               ->item(L"softness",                                             L"The softness of the chroma keying window.")
+               ->item(L"spill_suppress",                               L"How much to suppress spill by within 0.0-180.0. It works by taking all hue values within +- this value from target_hue and clamps it to either target_hue - this value or target_hue + this value depending on which side it is closest to.")
+               ->item(L"spill_suppress_saturation",            L"Controls how much saturation should be kept on colors affected by spill_suppress within 0.0-1.0. Full saturation may not always be desirable to be kept on suppressed colors.")
+               ->item(L"show_mask",                                            L"If enabled, only shows the mask. Useful while editing the chroma key settings.")
                ;
-       sink.example(L">> MIXER 1-1 CHROMA 1 120 0.1 0 0 0.1 1 2 0", L"for enabling chroma keying centered around a hue of 120 degrees (green) and with a 10% hue width");
+       sink.example(L">> MIXER 1-1 CHROMA 1 120 0.1 0 0 0.1 0.1 0.7 0", L"for enabling chroma keying centered around a hue of 120 degrees (green) and with a 10% hue width");
        sink.example(L">> MIXER 1-1 CHROMA 0", L"for disabling chroma keying");
        sink.example(
                L">> MIXER 1-1 CHROMA 0\n"
                L"<< 202 MIXER OK\n"
-               L"<< 1 120 0.1 0 0 0.1 1 2 0", L"for getting the current chroma key mode");
+               L"<< 1 120 0.1 0 0 0.1 0 1 0", L"for getting the current chroma key mode");
        sink.para()->text(L"Deprecated legacy syntax:");
        sink.syntax(L"MIXER [video_channel:int]{-[layer:int]|-0} CHROMA {[color:none,green,blue] {[threshold:float] [softness:float] [spill:float]}}" + ANIMATION_SYNTAX);
        sink.para()->text(L"Deprecated legacy examples:");
@@ -1335,8 +1335,8 @@ std::wstring mixer_chroma_command(command_context& ctx)
                        + boost::lexical_cast<std::wstring>(chroma.min_saturation) + L" "
                        + boost::lexical_cast<std::wstring>(chroma.min_brightness) + L" "
                        + boost::lexical_cast<std::wstring>(chroma.softness) + L" "
-                       + boost::lexical_cast<std::wstring>(chroma.spill) + L" "
-                       + boost::lexical_cast<std::wstring>(chroma.spill_darken) + L" "
+                       + boost::lexical_cast<std::wstring>(chroma.spill_suppress) + L" "
+                       + boost::lexical_cast<std::wstring>(chroma.spill_suppress_saturation) + L" "
                        + std::wstring(chroma.show_mask ? L"1" : L"0") + L"\r\n";
        }
 
@@ -1360,13 +1360,13 @@ std::wstring mixer_chroma_command(command_context& ctx)
                }
                else
                {
-                       chroma.enable = true;
-                       chroma.hue_width = 0.5 - boost::lexical_cast<double>(ctx.parameters.at(1)) * 0.5;
-                       chroma.min_brightness = boost::lexical_cast<double>(ctx.parameters.at(1));
-                       chroma.min_saturation = boost::lexical_cast<double>(ctx.parameters.at(1));
-                       chroma.softness = boost::lexical_cast<double>(ctx.parameters.at(2)) - boost::lexical_cast<double>(ctx.parameters.at(1));
-                       chroma.spill = boost::lexical_cast<double>(ctx.parameters.at(3));
-                       chroma.spill_darken = 2;
+                       chroma.enable                                           = true;
+                       chroma.hue_width                                        = 0.5 - boost::lexical_cast<double>(ctx.parameters.at(1)) * 0.5;
+                       chroma.min_brightness                           = boost::lexical_cast<double>(ctx.parameters.at(1));
+                       chroma.min_saturation                           = boost::lexical_cast<double>(ctx.parameters.at(1));
+                       chroma.softness                                         = boost::lexical_cast<double>(ctx.parameters.at(2)) - boost::lexical_cast<double>(ctx.parameters.at(1));
+                       chroma.spill_suppress                           = 180.0 - boost::lexical_cast<double>(ctx.parameters.at(3)) * 180.0;
+                       chroma.spill_suppress_saturation        = 1;
 
                        if (*legacy_mode == chroma::legacy_type::green)
                                chroma.target_hue = 120;
@@ -1383,14 +1383,14 @@ std::wstring mixer_chroma_command(command_context& ctx)
 
                if (chroma.enable)
                {
-                       chroma.target_hue               = boost::lexical_cast<double>(ctx.parameters.at(1));
-                       chroma.hue_width                = boost::lexical_cast<double>(ctx.parameters.at(2));
-                       chroma.min_saturation   = boost::lexical_cast<double>(ctx.parameters.at(3));
-                       chroma.min_brightness   = boost::lexical_cast<double>(ctx.parameters.at(4));
-                       chroma.softness                 = boost::lexical_cast<double>(ctx.parameters.at(5));
-                       chroma.spill                    = boost::lexical_cast<double>(ctx.parameters.at(6));
-                       chroma.spill_darken             = boost::lexical_cast<double>(ctx.parameters.at(7));
-                       chroma.show_mask                = boost::lexical_cast<double>(ctx.parameters.at(8));
+                       chroma.target_hue                                       = boost::lexical_cast<double>(ctx.parameters.at(1));
+                       chroma.hue_width                                        = boost::lexical_cast<double>(ctx.parameters.at(2));
+                       chroma.min_saturation                           = boost::lexical_cast<double>(ctx.parameters.at(3));
+                       chroma.min_brightness                           = boost::lexical_cast<double>(ctx.parameters.at(4));
+                       chroma.softness                                         = boost::lexical_cast<double>(ctx.parameters.at(5));
+                       chroma.spill_suppress                           = boost::lexical_cast<double>(ctx.parameters.at(6));
+                       chroma.spill_suppress_saturation        = boost::lexical_cast<double>(ctx.parameters.at(7));
+                       chroma.show_mask                                        = boost::lexical_cast<double>(ctx.parameters.at(8));
                }
        }