From 3e781179f5ffc496e4af492c92a527f7884257ec Mon Sep 17 00:00:00 2001 From: zqm Date: Thu, 26 Mar 2026 23:04:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=A3=80=E6=B5=8B=E5=88=B0Off=E7=8A=B6?= =?UTF-8?q?=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Windows/CS/Framework4.0/Camera/Camera/LedDetector.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Windows/CS/Framework4.0/Camera/Camera/LedDetector.cs b/Windows/CS/Framework4.0/Camera/Camera/LedDetector.cs index 1160801..8bb8430 100644 --- a/Windows/CS/Framework4.0/Camera/Camera/LedDetector.cs +++ b/Windows/CS/Framework4.0/Camera/Camera/LedDetector.cs @@ -5,11 +5,13 @@ using Emgu.CV.CvEnum; using Emgu.CV.Structure; public enum LedState { Off, On } - public enum LedColor { Unknown, Red, Green, Blue } public class LedDetector { + private const int BRIGHT_LIMIT = 110; + private const int SAT_LIMIT = 35; + public Tuple Detect(Image image, Rectangle roi) { using (Image subImg = image.GetSubRect(roi)) @@ -27,9 +29,12 @@ public class LedDetector S.Dispose(); V.Dispose(); - bool isOff = (avgS < 38) || (avgV < 55); - if (isOff) + bool isOn = avgV > BRIGHT_LIMIT && avgS < SAT_LIMIT; + + if (!isOn) + { return new Tuple(LedState.Off, LedColor.Unknown); + } LedColor color = LedColor.Unknown; if ((avgH >= 0 && avgH <= 10) || (avgH >= 170 && avgH <= 180))