led检测
This commit is contained in:
@@ -79,6 +79,11 @@ public class LedDetector
|
|||||||
double avgH = CvInvoke.Mean(H).V0;
|
double avgH = CvInvoke.Mean(H).V0;
|
||||||
double avgS = CvInvoke.Mean(S).V0;
|
double avgS = CvInvoke.Mean(S).V0;
|
||||||
double avgV = CvInvoke.Mean(V).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();
|
H.Dispose();
|
||||||
S.Dispose();
|
S.Dispose();
|
||||||
|
|||||||
@@ -142,6 +142,7 @@ namespace Camera
|
|||||||
private int[] _handleOffsetsX = { 0, 1, 2, 2, 1, 0, 0 };
|
private int[] _handleOffsetsX = { 0, 1, 2, 2, 1, 0, 0 };
|
||||||
private int[] _handleOffsetsY = { 0, 0, 0, 1, 2, 2, 2, 1 };
|
private int[] _handleOffsetsY = { 0, 0, 0, 1, 2, 2, 2, 1 };
|
||||||
private int _lastSelectedZoneIndex = -1;
|
private int _lastSelectedZoneIndex = -1;
|
||||||
|
private bool _isLoadingSettings = false;
|
||||||
private bool _isUpdatingDataGridView = false;
|
private bool _isUpdatingDataGridView = false;
|
||||||
public Setting()
|
public Setting()
|
||||||
{
|
{
|
||||||
@@ -218,9 +219,11 @@ namespace Camera
|
|||||||
|
|
||||||
if (_camera != null)
|
if (_camera != null)
|
||||||
{
|
{
|
||||||
|
System.Diagnostics.Debug.WriteLine("Setting加载阈值: BrightLimit=" + _camera.GetBrightLimit() + ", SatLimit=" + _camera.GetSatLimit());
|
||||||
_camera.ImageCaptured += Camera_ImageCaptured;
|
_camera.ImageCaptured += Camera_ImageCaptured;
|
||||||
_detectionZoneColor = _camera.GetDetectionZoneColor();
|
_detectionZoneColor = _camera.GetDetectionZoneColor();
|
||||||
_ledZoneColors = _camera.GetLedZoneColors();
|
_ledZoneColors = _camera.GetLedZoneColors();
|
||||||
|
_isLoadingSettings = true;
|
||||||
toolStripNumericUpDown5.Value = _camera.GetBrightLimit();
|
toolStripNumericUpDown5.Value = _camera.GetBrightLimit();
|
||||||
toolStripNumericUpDown6.Value = _camera.GetSatLimit();
|
toolStripNumericUpDown6.Value = _camera.GetSatLimit();
|
||||||
toolStripNumericUpDown7.Value = _camera.GetRedMin();
|
toolStripNumericUpDown7.Value = _camera.GetRedMin();
|
||||||
@@ -229,6 +232,7 @@ namespace Camera
|
|||||||
toolStripNumericUpDown10.Value = _camera.GetGreenMax();
|
toolStripNumericUpDown10.Value = _camera.GetGreenMax();
|
||||||
toolStripNumericUpDown11.Value = _camera.GetBlueMin();
|
toolStripNumericUpDown11.Value = _camera.GetBlueMin();
|
||||||
toolStripNumericUpDown12.Value = _camera.GetBlueMax();
|
toolStripNumericUpDown12.Value = _camera.GetBlueMax();
|
||||||
|
_isLoadingSettings = false;
|
||||||
}
|
}
|
||||||
picBoxCamera.BackColor = Color.Gray;
|
picBoxCamera.BackColor = Color.Gray;
|
||||||
splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
|
splitContainer1.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
|
||||||
@@ -1695,7 +1699,7 @@ namespace Camera
|
|||||||
// 亮度阈值事件
|
// 亮度阈值事件
|
||||||
private void ToolStripNumericUpDown5_ValueChanged(object sender, EventArgs e)
|
private void ToolStripNumericUpDown5_ValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_camera == null) return;
|
if (_camera == null || _isLoadingSettings) return;
|
||||||
int brightLimit = (int)toolStripNumericUpDown5.Value;
|
int brightLimit = (int)toolStripNumericUpDown5.Value;
|
||||||
int satLimit = (int)toolStripNumericUpDown6.Value;
|
int satLimit = (int)toolStripNumericUpDown6.Value;
|
||||||
_camera.SetLedDetectorParams(brightLimit, satLimit);
|
_camera.SetLedDetectorParams(brightLimit, satLimit);
|
||||||
@@ -1704,7 +1708,7 @@ namespace Camera
|
|||||||
// 饱和度阈值事件
|
// 饱和度阈值事件
|
||||||
private void ToolStripNumericUpDown6_ValueChanged(object sender, EventArgs e)
|
private void ToolStripNumericUpDown6_ValueChanged(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (_camera == null) return;
|
if (_camera == null || _isLoadingSettings) return;
|
||||||
int brightLimit = (int)toolStripNumericUpDown5.Value;
|
int brightLimit = (int)toolStripNumericUpDown5.Value;
|
||||||
int satLimit = (int)toolStripNumericUpDown6.Value;
|
int satLimit = (int)toolStripNumericUpDown6.Value;
|
||||||
_camera.SetLedDetectorParams(brightLimit, satLimit);
|
_camera.SetLedDetectorParams(brightLimit, satLimit);
|
||||||
@@ -1759,6 +1763,7 @@ namespace Camera
|
|||||||
|
|
||||||
private void UpdateColorThresholds()
|
private void UpdateColorThresholds()
|
||||||
{
|
{
|
||||||
|
if (_camera == null || _isLoadingSettings) return;
|
||||||
int redMin = (int)toolStripNumericUpDown7.Value;
|
int redMin = (int)toolStripNumericUpDown7.Value;
|
||||||
int redMax = (int)toolStripNumericUpDown8.Value;
|
int redMax = (int)toolStripNumericUpDown8.Value;
|
||||||
int greenMin = (int)toolStripNumericUpDown9.Value;
|
int greenMin = (int)toolStripNumericUpDown9.Value;
|
||||||
|
|||||||
Reference in New Issue
Block a user