diff --git a/src/core/config.rs b/src/core/config.rs index ba22170..ceb4a5d 100644 --- a/src/core/config.rs +++ b/src/core/config.rs @@ -443,14 +443,16 @@ impl PerspectiveCorrectionConfig { impl ChromaKeyConfig { pub fn validate(&self) -> Result<()> { - validate_hsv_component("display.chroma_key.hsv_min[0]", self.hsv_min[0], 0, 180)?; - validate_hsv_component("display.chroma_key.hsv_min[1]", self.hsv_min[1], 0, 255)?; - validate_hsv_component("display.chroma_key.hsv_min[2]", self.hsv_min[2], 0, 255)?; - validate_hsv_component("display.chroma_key.hsv_max[0]", self.hsv_max[0], 0, 180)?; - validate_hsv_component("display.chroma_key.hsv_max[1]", self.hsv_max[1], 0, 255)?; - validate_hsv_component("display.chroma_key.hsv_max[2]", self.hsv_max[2], 0, 255)?; - - for index in 0..3 { + let hsv_ranges = [180, 255, 255]; // H, S, V max values + for (index, &max_val) in hsv_ranges.iter().enumerate() { + validate_hsv_component( + &format!("display.chroma_key.hsv_min[{index}]"), + self.hsv_min[index], 0, max_val, + )?; + validate_hsv_component( + &format!("display.chroma_key.hsv_max[{index}]"), + self.hsv_max[index], 0, max_val, + )?; if self.hsv_min[index] > self.hsv_max[index] { bail!("display.chroma_key hsv_min[{index}] 不能大于 hsv_max[{index}]"); }