From 028dd4c61b412bd19b0c35edeb70a23cdecbfc2d Mon Sep 17 00:00:00 2001 From: zqm Date: Fri, 27 Mar 2026 15:51:17 +0800 Subject: [PATCH] led --- Windows/CS/Framework4.0/Camera/Camera/Camera.cs | 13 +++++++++++++ Windows/CS/Framework4.0/Camera/Camera/Setting.cs | 14 ++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/Windows/CS/Framework4.0/Camera/Camera/Camera.cs b/Windows/CS/Framework4.0/Camera/Camera/Camera.cs index 98da549..95f555c 100644 --- a/Windows/CS/Framework4.0/Camera/Camera/Camera.cs +++ b/Windows/CS/Framework4.0/Camera/Camera/Camera.cs @@ -34,6 +34,7 @@ namespace Camera private ConcurrentDictionary _ledZoneColors = new ConcurrentDictionary(); private ConcurrentDictionary _ledZoneDetectionResults = new ConcurrentDictionary(); private ConcurrentDictionary> _ledZoneHsvValues = new ConcurrentDictionary>(); + private ConcurrentDictionary _ledZoneVisibility = new ConcurrentDictionary(); private LedDetector _ledDetector = new LedDetector(); public void SetLedDetectorParams(int brightLimit, int satLimit) @@ -427,6 +428,18 @@ namespace Camera return Color.Lime; } + public bool GetLedZoneVisibility(int index) + { + if (_ledZoneVisibility.ContainsKey(index)) + return _ledZoneVisibility[index]; + return true; + } + + public void SetLedZoneVisibility(int index, bool visible) + { + _ledZoneVisibility[index] = visible; + } + /// /// 获取LED区域检测结果 /// diff --git a/Windows/CS/Framework4.0/Camera/Camera/Setting.cs b/Windows/CS/Framework4.0/Camera/Camera/Setting.cs index 777ec4e..f9044a0 100644 --- a/Windows/CS/Framework4.0/Camera/Camera/Setting.cs +++ b/Windows/CS/Framework4.0/Camera/Camera/Setting.cs @@ -132,7 +132,6 @@ namespace Camera private bool _isEditingLedZone = false; private bool _isDrawingLedMode = false; private int _ledZoneState = 0; - private bool _showLedZones = true; private Color _detectionZoneColor = Color.Black; private ConcurrentDictionary _ledZoneColors = new ConcurrentDictionary(); private ConcurrentDictionary _ledZoneDetectionResults = new ConcurrentDictionary(); @@ -382,8 +381,8 @@ namespace Camera var hsvValues = _camera.GetLedZoneHsvValues(); foreach (var kvp in allLedZones) { - if (!_showLedZones) continue; int index = kvp.Key; + if (index == _selectedZoneIndex && _selectedZoneIndex >= 0 && !_camera.GetLedZoneVisibility(_selectedZoneIndex)) continue; Rectangle ledZone = kvp.Value; Color ledColor = _camera.GetLedZoneColor(index); string detectionResult = _camera.GetLedZoneDetectionResult(index); @@ -598,6 +597,7 @@ namespace Camera foreach (var kvp in allLedZones) { int index = kvp.Key; + if (index == _selectedZoneIndex && _selectedZoneIndex >= 0 && !_camera.GetLedZoneVisibility(_selectedZoneIndex)) continue; Rectangle ledZone = kvp.Value; Color ledColor = _camera.GetLedZoneColor(index); @@ -651,6 +651,7 @@ namespace Camera foreach (var kvp in allLedZones) { int index = kvp.Key; + if (index == _selectedZoneIndex && _selectedZoneIndex >= 0 && !_camera.GetLedZoneVisibility(_selectedZoneIndex)) continue; Rectangle ledZone = kvp.Value; Color ledColor = _camera.GetLedZoneColor(index); @@ -705,6 +706,7 @@ namespace Camera foreach (var kvp in allLedZones) { int index = kvp.Key; + if (!_camera.GetLedZoneVisibility(index)) continue; Rectangle ledZone = kvp.Value; Color ledColor = _camera.GetLedZoneColor(index); @@ -1295,6 +1297,7 @@ namespace Camera toolStripNumericUpDown2.Value = zone.Y; toolStripNumericUpDown3.Value = zone.Width; toolStripNumericUpDown4.Value = zone.Height; + toolStripButton5.Checked = _camera.GetLedZoneVisibility(_selectedZoneIndex); } foreach (DataGridViewRow row in dataGridView2.Rows) { @@ -1710,8 +1713,11 @@ namespace Camera // 显示Led框复选框事件 private void ToolStripButton5_Click(object sender, EventArgs e) { - _showLedZones = toolStripButton5.Checked; - picBoxCamera.Invalidate(); + if (_camera != null && _selectedZoneIndex >= 0) + { + _camera.SetLedZoneVisibility(_selectedZoneIndex, toolStripButton5.Checked); + } + picBoxCamera.Refresh(); } // 红绿蓝阈值事件