led检测

This commit is contained in:
zqm
2026-03-30 09:40:11 +08:00
parent 028dd4c61b
commit 1f5d05e6d6
2 changed files with 12 additions and 2 deletions

View File

@@ -79,6 +79,11 @@ public class LedDetector
double avgH = CvInvoke.Mean(H).V0;
double avgS = CvInvoke.Mean(S).V0;
double avgV = CvInvoke.Mean(V).V0;
double minV = 0;
double maxV = 0; // <20><><EFBFBD><EFBFBD><EBB6A8>
Point minLoc = new Point(); // <20><><EFBFBD><EFBFBD><EBB6A8>
Point maxLoc = new Point(); // <20><><EFBFBD><EFBFBD><EBB6A8>
CvInvoke.MinMaxLoc(V, ref minV, ref maxV, ref minLoc, ref maxLoc);
H.Dispose();
S.Dispose();

View File

@@ -142,6 +142,7 @@ namespace Camera
private int[] _handleOffsetsX = { 0, 1, 2, 2, 1, 0, 0 };
private int[] _handleOffsetsY = { 0, 0, 0, 1, 2, 2, 2, 1 };
private int _lastSelectedZoneIndex = -1;
private bool _isLoadingSettings = false;
private bool _isUpdatingDataGridView = false;
public Setting()
{
@@ -218,9 +219,11 @@ namespace Camera
if (_camera != null)
{
System.Diagnostics.Debug.WriteLine("Setting加载阈值: BrightLimit=" + _camera.GetBrightLimit() + ", SatLimit=" + _camera.GetSatLimit());
_camera.ImageCaptured += Camera_ImageCaptured;
_detectionZoneColor = _camera.GetDetectionZoneColor();
_ledZoneColors = _camera.GetLedZoneColors();
_isLoadingSettings = true;
toolStripNumericUpDown5.Value = _camera.GetBrightLimit();
toolStripNumericUpDown6.Value = _camera.GetSatLimit();
toolStripNumericUpDown7.Value = _camera.GetRedMin();
@@ -229,6 +232,7 @@ namespace Camera
toolStripNumericUpDown10.Value = _camera.GetGreenMax();
toolStripNumericUpDown11.Value = _camera.GetBlueMin();
toolStripNumericUpDown12.Value = _camera.GetBlueMax();
_isLoadingSettings = false;
}
picBoxCamera.BackColor = Color.Gray;
splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
@@ -1695,7 +1699,7 @@ namespace Camera
// 亮度阈值事件
private void ToolStripNumericUpDown5_ValueChanged(object sender, EventArgs e)
{
if (_camera == null) return;
if (_camera == null || _isLoadingSettings) return;
int brightLimit = (int)toolStripNumericUpDown5.Value;
int satLimit = (int)toolStripNumericUpDown6.Value;
_camera.SetLedDetectorParams(brightLimit, satLimit);
@@ -1704,7 +1708,7 @@ namespace Camera
// 饱和度阈值事件
private void ToolStripNumericUpDown6_ValueChanged(object sender, EventArgs e)
{
if (_camera == null) return;
if (_camera == null || _isLoadingSettings) return;
int brightLimit = (int)toolStripNumericUpDown5.Value;
int satLimit = (int)toolStripNumericUpDown6.Value;
_camera.SetLedDetectorParams(brightLimit, satLimit);
@@ -1759,6 +1763,7 @@ namespace Camera
private void UpdateColorThresholds()
{
if (_camera == null || _isLoadingSettings) return;
int redMin = (int)toolStripNumericUpDown7.Value;
int redMax = (int)toolStripNumericUpDown8.Value;
int greenMin = (int)toolStripNumericUpDown9.Value;