From ebcc1d53f14112363bbf539bcaf0202aadcdc9d7 Mon Sep 17 00:00:00 2001
From: C3032 <1057644574@qq.com>
Date: 星期一, 13 四月 2026 12:58:58 +0800
Subject: [PATCH] 2D取图计数功能完成
---
LB_VisionProcesses/Cameras/2DCameraForm.cs | 446 ++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 374 insertions(+), 72 deletions(-)
diff --git a/LB_VisionProcesses/Cameras/2DCameraForm.cs b/LB_VisionProcesses/Cameras/2DCameraForm.cs
index 1bbdd63..2409faf 100644
--- a/LB_VisionProcesses/Cameras/2DCameraForm.cs
+++ b/LB_VisionProcesses/Cameras/2DCameraForm.cs
@@ -1,5 +1,8 @@
锘縰sing HalconDotNet;
+using LB_SmartVisionCameraDevice.PHM6000;
using LB_VisionControl;
+using LB_VisionProcesses.Cameras.HRCameras;
+using LB_VisionProcesses.Cameras.LBCameras;
using MVSDK_Net;
using Newtonsoft.Json.Linq;
using OpenCvSharp;
@@ -37,9 +40,9 @@
{
InitializeComponent();
//浼犲叆鐩告満鍙ユ焺鍚庣鐢ㄨ繛鎺�/鏂紑鎸夐敭
- this.btnOpen.Enabled = false;
- this.btnClose.Enabled = false;
- this.cmbBrand.Enabled = false;
+ //this.btnOpen.Enabled = false;
+ //this.btnClose.Enabled = false;
+ //this.cmbBrand.Enabled = false;
this.panel_Picture.Controls.Clear();
this.dicCameras = dicCameras;
@@ -75,11 +78,25 @@
UserPictureBox onlinePictureBox { get; set; }
private System.Windows.Forms.Timer updateTimer;
- Total total = new Total { iImageCount = 0, iScanCount = 0 };
+ Total total = new Total { iImageCount = 0, iScanCount = 0, ImagesPerTyre = 1 };
DateTime startGrabtime = DateTime.Now;
+
+ // 鍔ㄦ�佹坊鍔犵殑澧炵泭涓嬫媺妗�
+ private ComboBox cmbGain;
private void CameraForm_Load(object sender, EventArgs e)
{
+ // 鍒濆鍖栧鐩婁笅鎷夋
+ cmbGain = new ComboBox();
+ cmbGain.Visible = false; // 榛樿闅愯棌
+ cmbGain.DropDownStyle = ComboBoxStyle.DropDownList;
+ cmbGain.Size = txtGain.Size;
+ cmbGain.Location = txtGain.Location;
+ cmbGain.Font = txtGain.Font;
+ cmbGain.SelectedIndexChanged += CmbGain_SelectedIndexChanged;
+ this.txtGain.Parent.Controls.Add(cmbGain);
+ cmbGain.BringToFront();
+
// 璁剧疆涓�涓畾鏃跺櫒锛屾瘡 100 姣瑙﹀彂涓�娆�
updateTimer = new System.Windows.Forms.Timer();
updateTimer.Interval = 1000; // 璁剧疆瀹氭椂鍣ㄩ棿闅斾负 1000 姣
@@ -107,6 +124,12 @@
cmbSN.Text = SN;
cmbSN.SelectedIndex = Index;
+ // 濡傛灉娌℃壘鍒扮储寮曪紙鍙兘鏄柊澧炵殑锛夛紝鎵嬪姩瑙﹀彂涓�娆¢�昏緫浠ユ洿鏂癠I
+ if (Index == -1)
+ {
+ cmbSN_SelectedIndexChanged(null, null);
+ }
+
ckbLocalTest.Checked = Convert.ToBoolean(camConfig.Params.Inputs["鏄惁鏈湴鍙栧浘"].ToString());
ckbUpParams.Checked = Convert.ToBoolean(camConfig.Params.Inputs["鏄惁姣忔鍐欏叆鍙傛暟"].ToString());
ckbRegrab.Checked = Convert.ToBoolean(camConfig.Params.Inputs["鏄惁澶辫触閲嶆柊鍙栧浘"].ToString());
@@ -115,6 +138,16 @@
if (camConfig.OutputImage != null && camConfig.OutputImage is Bitmap bitmap)
onlinePictureBox.Image = bitmap;
lblCapTime.Text = $"{camConfig.RunTime}ms";
+ }
+ }
+
+ private void CmbGain_SelectedIndexChanged(object sender, EventArgs e)
+ {
+ if (camera != null && camera is LBCamera && cmbGain.Visible)
+ {
+ // LBCamera SetGain expects double which is cast to int for enum value
+ // ComboBox index corresponds directly to EnumAnalogGain value (0-4)
+ camera.SetGain((double)cmbGain.SelectedIndex);
}
}
@@ -154,10 +187,10 @@
switch (brand)
{
case CameraBrand.HRCamera:
- //camera = new HRCamera();
+ camera = new HRCamera();
break;
case CameraBrand.LBCamera:
- //camera = new LBCamera();
+ camera = new LBCamera();
break;
default:
Debug.WriteLine("鏈煡鍝佺墝");
@@ -195,14 +228,26 @@
camera = dicCameras[cmbSN.Text];
//璇存槑鐩告満宸茬粡鍒濆鍖栨垚鍔�
- if (camera != null && camera.isGrabbing)
+ if (camera != null)
{
- camera.ImageGrabbed -= GetImageBllComplete;
- camera.ImageGrabbed += GetImageBllComplete;
+ int Index = cmbBrand.FindString(camera.Brand.ToString());
+ if (Index >= 0)
+ {
+ cmbBrand.Text = camera.Brand.ToString();
+ cmbBrand.SelectedIndex = Index;
+ }
- int Index = cmbBrand.FindString(camera.Brand.ToString()); ;
- cmbBrand.Text = camera.Brand.ToString();
- cmbBrand.SelectedIndex = Index;
+ if (camera.isGrabbing)
+ {
+ camera.ImageGrabbed -= GetImageBllComplete;
+ camera.ImageGrabbed += GetImageBllComplete;
+ this.btnEdit.Enabled = true;
+ }
+ // 濡傛灉鐩告満瀛樺湪浜庡瓧鍏镐腑锛岃鏄庢槸宸茶繛鎺ョ殑璁惧锛屽厑璁哥紪杈�
+ else if (dicCameras != null && dicCameras.ContainsKey(camera.SN))
+ {
+ this.btnEdit.Enabled = true;
+ }
}
}
@@ -211,49 +256,123 @@
// 灏濊瘯灏嗚緭鍏ュ瓧绗︿覆杞崲涓烘灇涓惧��
if (Enum.TryParse(cmbBrand.Text, true, out CameraBrand brand))
{
- if (camera != null)
+ string selectedSN = cmbSN.Text.ToString();
+ bool isReusingExisting = false;
+
+ // 1. 灏濊瘯浠庣幇鏈夊瓧鍏镐腑鏌ユ壘宸插垵濮嬪寲鐨勭浉鏈�
+ if (dicCameras != null && dicCameras.ContainsKey(selectedSN))
+ {
+ var existingCamera = dicCameras[selectedSN];
+ // 纭繚鍝佺墝鍖归厤
+ if (existingCamera.Brand == brand)
+ {
+ camera = existingCamera;
+ isReusingExisting = true;
+ }
+ }
+
+ // 2. 濡傛灉娌℃湁澶嶇敤鐜版湁鐩告満锛屼笖褰撳墠camera瀵硅薄涓嶆槸鎴戜滑瑕佸鐢ㄧ殑瀵硅薄锛屽垯娓呯悊鏃у璞�
+ if (!isReusingExisting && camera != null)
{
camera.ImageGrabbed -= GetImageBllComplete;
camera.Dispose();
+ camera = null;
}
- // 浣跨敤 switch 璇彞鏉ュ垽鏂灇涓惧��
- switch (brand)
+ // 3. 濡傛灉娌℃湁澶嶇敤锛屽垯鍒涘缓鏂板疄渚�
+ if (!isReusingExisting)
{
- case CameraBrand.LBCamera:
- //camera = new LBCamera();
- break;
- case CameraBrand.HRCamera:
- //camera = new HRCamera();
- break;
- default:
- Debug.WriteLine($"銆恵DateTime.Now:HH:mm:ss.fff}銆戞湭鐭ュ搧鐗�");
- return;
+ // 浣跨敤 switch 璇彞鏉ュ垽鏂灇涓惧��
+ switch (brand)
+ {
+ case CameraBrand.LBCamera:
+ camera = new LBCamera();
+ break;
+ case CameraBrand.HRCamera:
+ camera = new HRCamera();
+ break;
+ default:
+ Debug.WriteLine($"銆恵DateTime.Now:HH:mm:ss.fff}銆戞湭鐭ュ搧鐗�");
+ return;
+ }
}
- if (cmbSN.Items.Count > 0 && camera.InitDevice(cmbSN.Text.ToString(), this.Handle))
+ IntPtr displayHandle = onlinePictureBox.Handle;
+ onlinePictureBox.Visible = true;
+
+ bool initSuccess = false;
+ if (isReusingExisting)
{
+ // 澶嶇敤鏃朵笉闇�瑕佸啀娆nitDevice锛屼絾鍙兘闇�瑕佹洿鏂版樉绀哄彞鏌�(瑙嗗叿浣揝DK瀹炵幇鑰屽畾锛孡BCamera閫氬父涓嶉渶瑕�)
+ initSuccess = true;
+ MessageBox.Show(camera.SN + "宸茶繛鎺� (澶嶇敤)");
+ }
+ else
+ {
+ if (cmbSN.Items.Count > 0 && camera.InitDevice(selectedSN, displayHandle))
+ {
+ initSuccess = true;
+ MessageBox.Show(camera.SN + "鎵撳紑鎴愬姛");
+ }
+ }
+
+ if (initSuccess)
+ {
+ // 閲嶆柊缁戝畾鏄剧ず鍥炶皟
camera.ImageGrabbed -= GetImageBllComplete;
camera.ImageGrabbed += GetImageBllComplete;
- MessageBox.Show(camera.SN + "鎵撳紑鎴愬姛");
+ this.btnEdit.Enabled = true;
}
}
else
{
Debug.WriteLine($"銆恵DateTime.Now:HH:mm:ss.fff}銆戞棤鏁堢殑鏋氫妇鍊硷紒");
}
+
+ // ... (rest of the UI update logic)
if (camera != null)
{
this.BeginInvoke(new Action(() =>
{
- double exp = 0;
- double gain = 0;
- camera.GetExpouseTime(out exp);
- txtExp.Text = exp.ToString();
+ if (camera is LBCamera lbCam)
+ {
+ // 鍒囨崲鍒颁笅鎷夋鏄剧ず
+ txtGain.Visible = false;
+ cmbGain.Visible = true;
+
+ // 濉厖閫夐」 (瀵瑰簲 EnumAnalogGain: Gain_1_0, Gain_1_3, Gain_1_9, Gain_2_8, Gain_5_5)
+ cmbGain.Items.Clear();
+ cmbGain.Items.AddRange(new object[] { "1.0x", "1.3x", "1.9x", "2.8x", "5.5x" });
- camera.GetGain(out gain);
- txtGain.Text = gain.ToString();
+ var config = lbCam.GetSensorConfig();
+ txtExp.Text = config.ExposureTime.ToString();
+
+ // 璁剧疆褰撳墠閫変腑鐨勫鐩�
+ int gainIndex = (int)config.AnalogGain;
+ if (gainIndex >= 0 && gainIndex < cmbGain.Items.Count)
+ {
+ cmbGain.SelectedIndex = gainIndex;
+ }
+ else
+ {
+ cmbGain.SelectedIndex = 0;
+ }
+ }
+ else
+ {
+ // 鎭㈠鏂囨湰妗嗘樉绀�
+ txtGain.Visible = true;
+ cmbGain.Visible = false;
+
+ double exp = 0;
+ double gain = 0;
+ camera.GetExpouseTime(out exp);
+ txtExp.Text = exp.ToString();
+
+ camera.GetGain(out gain);
+ txtGain.Text = gain.ToString();
+ }
camera.GetTriggerMode(out TriggerMode mode, out TriggerSource source);
@@ -273,24 +392,103 @@
if (camera.CloseDevice())
{
+ onlinePictureBox.Visible = true;
MessageBox.Show(camera.SN + "鏂紑鎴愬姛");
this.panel_Picture.Controls.Clear();
+ this.panel_Picture.Controls.Add(onlinePictureBox);
}
}
private void btnEdit_Click(object sender, EventArgs e)
{
if (camera == null)
+ {
return;
+ }
+ using (Form editForm = new Form())
+ {
+ editForm.Text = "楂樼骇鍙傛暟璁剧疆 - " + camera.SN;
+ editForm.Size = new System.Drawing.Size(400, 500);
+ editForm.StartPosition = FormStartPosition.CenterParent;
+ editForm.FormBorderStyle = FormBorderStyle.SizableToolWindow;
+
+ PropertyGrid pg = new PropertyGrid();
+ pg.Dock = DockStyle.Fill;
+
+ if (camera is LBCamera phmCamera)
+ {
+ pg.SelectedObject = phmCamera.GetSensorConfig();
+ pg.PropertyValueChanged += (s, ev) =>
+ {
+ phmCamera.UpdateSensorConfig((PHM6000SensorConfig)pg.SelectedObject);
+ };
+ }
+ else
+ {
+ pg.SelectedObject = new CameraAdvancedSettings(camera);
+ }
+
+ editForm.Controls.Add(pg);
+ editForm.ShowDialog();
+ }
+ }
+
+ /// <summary>
+ /// 鐩告満楂樼骇璁剧疆鍖呰绫�
+ /// </summary>
+ public class CameraAdvancedSettings
+ {
+ private BaseCamera _camera;
+ public CameraAdvancedSettings(BaseCamera camera)
+ {
+ _camera = camera;
+ }
+
+ [System.ComponentModel.Category("瑙﹀彂璁剧疆"), System.ComponentModel.Description("瑙﹀彂婧�")]
+ public TriggerSource TriggerSource
+ {
+ get { _camera.GetTriggerMode(out _, out TriggerSource s); return s; }
+ set { _camera.GetTriggerMode(out TriggerMode m, out _); _camera.SetTriggerMode(m, value); }
+ }
+
+ [System.ComponentModel.Category("瑙﹀彂璁剧疆"), System.ComponentModel.Description("瑙﹀彂鏋佹��")]
+ public TriggerPolarity TriggerPolarity
+ {
+ get { _camera.GetTriggerPolarity(out TriggerPolarity p); return p; }
+ set { _camera.SetTriggerPolarity(value); }
+ }
+
+ [System.ComponentModel.Category("瑙﹀彂璁剧疆"), System.ComponentModel.Description("瑙﹀彂寤舵椂(us)")]
+ public double TriggerDelay
+ {
+ get { _camera.GetTriggerDelay(out double d); return d; }
+ set { _camera.SetTriggerDelay(value); }
+ }
+
+ [System.ComponentModel.Category("瑙﹀彂璁剧疆"), System.ComponentModel.Description("瑙﹀彂婊ゆ尝(us)")]
+ public double TriggerFilter
+ {
+ get { _camera.GetTriggerFliter(out double f); return f; }
+ set { _camera.SetTriggerFliter(value); }
+ }
+
+ [System.ComponentModel.Category("鍥惧儚璁剧疆"), System.ComponentModel.Description("鑷姩鐧藉钩琛�")]
+ public void AutoBalanceWhite()
+ {
+ _camera.AutoBalanceWhite();
+ }
}
/// <summary>
/// 鐩告満鍥炶皟杩愯
+ /// 娉ㄦ剰锛氬浜嶭BCamera锛�3D绾挎壂鐩告満锛夛紝浣跨敤SDK鑷姩鏄剧ず妯″紡
+ /// SDK浼氳嚜鍔ㄥ皢鍥惧儚鏄剧ず鍒板搴旂殑鎺т欢涓婏紝姝ゅ洖璋冨彧鐢ㄤ簬缁熻閲囬泦娆℃暟
/// </summary>
/// <param name="CCDName"></param>
/// <param name="image"></param>
private void GetImageBllComplete(object sender, CameraEventArgs e)
{
+ // 瀵逛簬2D鐩告満锛堟墜鍔ㄥ鐞嗘ā寮忥級鍜岀幇鍦ㄧ殑LBCamera锛堟墜鍔ㄥ鐞嗘ā寮忥級
if (e.Bitmap == null)
return;
@@ -308,7 +506,6 @@
onlinePictureBox.Image = e.Bitmap;
}
}
-
total.iImageCount++;
try
{
@@ -331,23 +528,79 @@
Task.Factory.StartNew(() =>
{
- //camera.GetCamConfig(out CameraConfig OriCamConfig);
-
+ // 璁剧疆鏇濆厜鍜屽鐩�
camera.SetExpouseTime(Convert.ToDouble(txtExp.Text));
camera.SetGain(Convert.ToDouble(txtGain.Text));
- camera.GetImageWithSoftTrigger(out Bitmap bitmap);
+ bool success = false;
+ Bitmap bitmap = null;
- this.BeginInvoke(new Action(() =>
+ // 璋冪敤鍩虹被鎺ュ彛鐨勫崟娆¢噰闆嗘柟娉�
+ // LBCamera閲嶅啓浜哠tartSingleGrab鏂规硶锛屽叾浠栫浉鏈鸿皟鐢ㄨ繑鍥瀎alse
+ success = camera.StartSingleGrab();
+
+ if (success)
{
- if (bitmap != null)
- this.lblCapTime.Text = $"{(DateTime.Now - StartTime).TotalMilliseconds}ms";
- else
- this.lblCapTime.Text = "-1ms";
- }));
+ // 绛夊緟鍥惧儚鏁版嵁
+ using (AutoResetEvent waitHandle = new AutoResetEvent(false))
+ {
+ Bitmap captured = null;
+ EventHandler<CameraEventArgs> handler = (s, evt) =>
+ {
+ if (evt.Bitmap != null)
+ {
+ captured = evt.Bitmap.Clone() as Bitmap;
+ waitHandle.Set();
+ }
+ };
- //澶嶅師鍘熼�氳鍙h缃�
- //camera.SetCamConfig(OriCamConfig);
+ camera.ImageGrabbed += handler;
+ try
+ {
+ // 绛夊緟5绉掕秴鏃�
+ if (waitHandle.WaitOne(5000))
+ {
+ bitmap = captured;
+ }
+ }
+ finally
+ {
+ camera.ImageGrabbed -= handler;
+ camera.StopGrabbing();
+ }
+ }
+
+ this.BeginInvoke(new Action(() =>
+ {
+ if (bitmap != null)
+ {
+ this.lblCapTime.Text = $"{(DateTime.Now - StartTime).TotalMilliseconds}ms";
+ onlinePictureBox.Image = bitmap;
+ }
+ else
+ {
+ this.lblCapTime.Text = "-1ms";
+ }
+ }));
+ }
+ else
+ {
+ // 濡傛灉StartSingleGrab澶辫触锛屽洖閫�鍒颁紶缁熺殑GetImageWithSoftTrigger
+ camera.GetImageWithSoftTrigger(out bitmap);
+
+ this.BeginInvoke(new Action(() =>
+ {
+ if (bitmap != null)
+ {
+ this.lblCapTime.Text = $"{(DateTime.Now - StartTime).TotalMilliseconds}ms";
+ onlinePictureBox.Image = bitmap;
+ }
+ else
+ {
+ this.lblCapTime.Text = "-1ms";
+ }
+ }));
+ }
});
}
@@ -358,12 +611,12 @@
total.Clear();
- // 灏濊瘯灏嗚緭鍏ュ瓧绗︿覆杞崲涓烘灇涓惧��
- if (Enum.TryParse(cmbBrand.Text, true, out CameraBrand brand))
- {
- camera.StopGrabbing();
- camera.StartWith_HardTriggerModel();
- }
+ // 鍋滄褰撳墠閲囬泦
+ camera.StopGrabbing();
+
+ // 璋冪敤鍩虹被鎺ュ彛鐨勮繛缁噰闆嗘柟娉�
+ // LBCamera浼氳皟鐢⊿tartContinuousGrab鏂规硶锛屽叾浠栫浉鏈轰娇鐢ㄥ師鏈夌殑StartWith_HardTriggerModel
+ camera.StartContinuousGrab();
startGrabtime = DateTime.Now;
@@ -378,18 +631,15 @@
total.Clear();
- // 灏濊瘯灏嗚緭鍏ュ瓧绗︿覆杞崲涓烘灇涓惧��
- if (Enum.TryParse(cmbBrand.Text, true, out CameraBrand brand))
- {
- Task.Factory.StartNew(() =>
- {
- camera.StopGrabbing();
- camera.StartWith_SoftTriggerModel();
+ // 鍋滄褰撳墠閲囬泦
+ camera.StopGrabbing();
- });
- }
+ // 璋冪敤鍩虹被鎺ュ彛鐨勮繛缁噰闆嗘柟娉�
+ // LBCamera浼氳皟鐢⊿tartContinuousGrab鏂规硶锛屽叾浠栫浉鏈轰娇鐢ㄥ師鏈夌殑StartWith_SoftTriggerModel
+ camera.StartContinuousGrab();
startGrabtime = DateTime.Now;
+
cmbSN.Enabled = false;
cmbBrand.Enabled = false;
}
@@ -407,8 +657,11 @@
Task.Factory.StartNew(() =>
{
camera.StopGrabbing();
- camera.SetTriggerMode(TriggerMode.On, TriggerSource.Software);
- camera.StartGrabbing();
+ if (brand != CameraBrand.LBCamera)
+ {
+ camera.SetTriggerMode(TriggerMode.On, TriggerSource.Software);
+ camera.StartGrabbing();
+ }
});
}
@@ -463,7 +716,8 @@
private void txtGain_TextChanged(object sender, EventArgs e)
{
- if (camera == null)
+ // 濡傛灉姝e湪浣跨敤涓嬫媺妗嗘ā寮�(LBCamera)锛屽拷鐣ユ枃鏈鐨勫彉鍖�
+ if (camera == null || (cmbGain != null && cmbGain.Visible))
return;
double gain = 10;
@@ -516,9 +770,25 @@
if (res == DialogResult.Yes) //淇濆瓨VPP
{
+ TriggerSource actualSource = TriggerSource.Line0;
+ TriggerPolarity polarity = TriggerPolarity.RisingEdge;
+ double delay = 0;
+ double filter = 0;
+
+ if (camera != null)
+ {
+ camera.GetTriggerMode(out _, out actualSource);
+ camera.GetTriggerPolarity(out polarity);
+ camera.GetTriggerDelay(out delay);
+ camera.GetTriggerFliter(out filter);
+ }
+
camConfig.Params.Inputs.Add("鐩告満SN", cmbSN.Text);
camConfig.Params.Inputs.Add("瑙﹀彂妯″紡", TriggerMode.On);
- camConfig.Params.Inputs.Add("瑙﹀彂鏂瑰紡", radioButtonSoft.Checked ? TriggerSource.Software : TriggerSource.Line0);
+ camConfig.Params.Inputs.Add("瑙﹀彂鏂瑰紡", radioButtonSoft.Checked ? TriggerSource.Software : actualSource);
+ camConfig.Params.Inputs.Add("瑙﹀彂鏋佹��", polarity);
+ camConfig.Params.Inputs.Add("瑙﹀彂寤舵椂", delay);
+ camConfig.Params.Inputs.Add("瑙﹀彂娑堟姈", filter);
camConfig.Params.Inputs.Add("鏄惁鏈湴鍙栧浘", ckbLocalTest.Checked);
camConfig.Params.Inputs.Add("鏈湴鍙栧浘璺緞", cmbImagesPath.Items.Cast<string>().ToList());
camConfig.Params.Inputs.Add("鏄惁澶辫触閲嶆柊鍙栧浘", ckbRegrab.Checked);
@@ -541,18 +811,34 @@
private void CameraForm_FormClosed(object sender, FormClosedEventArgs e)
{
+ onlinePictureBox.Visible = true;
+ this.panel_Picture.Controls.Clear();
+ this.panel_Picture.Controls.Add(onlinePictureBox);
+
this.onlinePictureBox.Image = null;
if (camera != null)
{
camera.ImageGrabbed -= GetImageBllComplete;
- camera.StopGrabbing();
+
+ // 妫�鏌ヨ鐩告満鏄惁鐢变富绯荤粺绠$悊
+ bool isManagedBySystem = dicCameras != null && dicCameras.ContainsKey(camera.SN);
- if (radioButtonSoft.Checked)
- camera.SetTriggerMode(TriggerMode.On, TriggerSource.Software);
- else
- camera.SetTriggerMode(TriggerMode.On, TriggerSource.Line0);
+ if (!isManagedBySystem)
+ {
+ // 鍙湁闈炴墭绠$殑锛堜复鏃舵墦寮�鐨勶級鐩告満鎵嶅仠姝㈤噰闆嗗拰閲婃斁
+ camera.StopGrabbing();
- camera.StartGrabbing();
+ camera.GetTriggerMode(out _, out TriggerSource actualSource);
+ if (radioButtonSoft.Checked)
+ camera.SetTriggerMode(TriggerMode.On, TriggerSource.Software);
+ else
+ camera.SetTriggerMode(TriggerMode.On, actualSource);
+
+ if (camera.Brand != CameraBrand.LBCamera)
+ {
+ camera.StartGrabbing();
+ }
+ }
}
//璺緞涓虹┖璇存槑涓烘祴璇曟ā寮忥紝闇�瑕侀噴鏀剧浉鏈�
@@ -620,10 +906,21 @@
if (camera == null)
return;
+
+ camera.GetTriggerMode(out _, out TriggerSource currentSource);
+
if (radioButtonSoft.Checked)
+ {
camera.SetTriggerMode(TriggerMode.On, TriggerSource.Software);
+ }
else
- camera.SetTriggerMode(TriggerMode.On, TriggerSource.Line0);
+ {
+ // 濡傛灉褰撳墠宸茬粡鏄‖浠惰Е鍙戞簮锛屽垯淇濇寔锛涘惁鍒欓粯璁ine0
+ if (currentSource == TriggerSource.Software)
+ camera.SetTriggerMode(TriggerMode.On, TriggerSource.Line0);
+ else
+ camera.SetTriggerMode(TriggerMode.On, currentSource);
+ }
}
System.Windows.Forms.ToolTip ToolTip = new System.Windows.Forms.ToolTip();
@@ -649,12 +946,17 @@
private void controlBox_2DCameraForm_Click(object sender, EventArgs e)
{
-
+
}
private void dungeonControlBox_2DCameraForm_Click(object sender, EventArgs e)
{
- // this.Close();
+ // this.Close();
+ }
+
+ private void theme_2DCameraForm_Click(object sender, EventArgs e)
+ {
+
}
}
}
--
Gitblit v1.9.3