增加調整IDS曝光時間功能

This commit is contained in:
JEFF 2025-01-22 13:40:19 +08:00
parent 9edf6a3a44
commit a508338501
2 changed files with 65 additions and 5 deletions

View File

@ -39,6 +39,11 @@
label2 = new Label(); label2 = new Label();
label3 = new Label(); label3 = new Label();
Bt_disconnect = new Button(); Bt_disconnect = new Button();
IDS_ExposureTime = new TextBox();
label1 = new Label();
Basler_ExposureTime = new TextBox();
label4 = new Label();
label5 = new Label();
((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit(); ((System.ComponentModel.ISupportInitialize)pictureBox1).BeginInit();
SuspendLayout(); SuspendLayout();
// //
@ -111,7 +116,7 @@
// //
// camera_serialnumber // camera_serialnumber
// //
camera_serialnumber.Location = new Point(1279, 75); camera_serialnumber.Location = new Point(1283, 127);
camera_serialnumber.Name = "camera_serialnumber"; camera_serialnumber.Name = "camera_serialnumber";
camera_serialnumber.Size = new Size(182, 30); camera_serialnumber.Size = new Size(182, 30);
camera_serialnumber.TabIndex = 7; camera_serialnumber.TabIndex = 7;
@ -119,7 +124,7 @@
// label2 // label2
// //
label2.AutoSize = true; label2.AutoSize = true;
label2.Location = new Point(1279, 29); label2.Location = new Point(1283, 81);
label2.Name = "label2"; label2.Name = "label2";
label2.Size = new Size(75, 23); label2.Size = new Size(75, 23);
label2.TabIndex = 10; label2.TabIndex = 10;
@ -128,7 +133,7 @@
// label3 // label3
// //
label3.AutoSize = true; label3.AutoSize = true;
label3.Location = new Point(1172, 78); label3.Location = new Point(1176, 130);
label3.Name = "label3"; label3.Name = "label3";
label3.Size = new Size(82, 23); label3.Size = new Size(82, 23);
label3.TabIndex = 11; label3.TabIndex = 11;
@ -144,11 +149,57 @@
Bt_disconnect.UseVisualStyleBackColor = true; Bt_disconnect.UseVisualStyleBackColor = true;
Bt_disconnect.Click += Bt_disconnect_Click; Bt_disconnect.Click += Bt_disconnect_Click;
// //
// IDS_ExposureTime
//
IDS_ExposureTime.Location = new Point(1283, 189);
IDS_ExposureTime.Name = "IDS_ExposureTime";
IDS_ExposureTime.Size = new Size(150, 30);
IDS_ExposureTime.TabIndex = 13;
//
// label1
//
label1.AutoSize = true;
label1.Location = new Point(1176, 192);
label1.Name = "label1";
label1.Size = new Size(82, 23);
label1.TabIndex = 14;
label1.Text = "曝光時間";
//
// Basler_ExposureTime
//
Basler_ExposureTime.Location = new Point(940, 189);
Basler_ExposureTime.Name = "Basler_ExposureTime";
Basler_ExposureTime.Size = new Size(150, 30);
Basler_ExposureTime.TabIndex = 15;
//
// label4
//
label4.AutoSize = true;
label4.Location = new Point(835, 192);
label4.Name = "label4";
label4.Size = new Size(82, 23);
label4.TabIndex = 16;
label4.Text = "曝光時間";
//
// label5
//
label5.AutoSize = true;
label5.Location = new Point(951, 81);
label5.Name = "label5";
label5.Size = new Size(97, 23);
label5.TabIndex = 17;
label5.Text = "Basler參數";
//
// Main // Main
// //
AutoScaleDimensions = new SizeF(11F, 23F); AutoScaleDimensions = new SizeF(11F, 23F);
AutoScaleMode = AutoScaleMode.Font; AutoScaleMode = AutoScaleMode.Font;
ClientSize = new Size(1746, 1294); ClientSize = new Size(1746, 1294);
Controls.Add(label5);
Controls.Add(label4);
Controls.Add(Basler_ExposureTime);
Controls.Add(label1);
Controls.Add(IDS_ExposureTime);
Controls.Add(Bt_disconnect); Controls.Add(Bt_disconnect);
Controls.Add(label3); Controls.Add(label3);
Controls.Add(label2); Controls.Add(label2);
@ -181,5 +232,10 @@
private Label label2; private Label label2;
private Label label3; private Label label3;
private Button Bt_disconnect; private Button Bt_disconnect;
public TextBox IDS_ExposureTime;
private Label label1;
public TextBox Basler_ExposureTime;
private Label label4;
private Label label5;
} }
} }

View File

@ -71,7 +71,8 @@ namespace Camera_connect
if (connectionResult) if (connectionResult)
{ {
// 設置曝光時間 // 設置曝光時間
IDS_camera.SetExposureTime(10000); if (string.IsNullOrWhiteSpace(IDS_ExposureTime.Text)) IDS_camera.SetExposureTime(10000);
else IDS_camera.SetExposureTime(Convert.ToDouble(IDS_ExposureTime.Text));
Label_status.Text = "IDS連線成功"; Label_status.Text = "IDS連線成功";
Bt_OneShot.Enabled = true; Bt_OneShot.Enabled = true;
Bt_KeepShot.Enabled = true; Bt_KeepShot.Enabled = true;
@ -145,6 +146,8 @@ namespace Camera_connect
{ {
if (IDS_camera != null) if (IDS_camera != null)
{ {
if (string.IsNullOrWhiteSpace(IDS_ExposureTime.Text)) IDS_camera.SetExposureTime(10000);
else IDS_camera.SetExposureTime(Convert.ToDouble(IDS_ExposureTime.Text));
Bitmap image = IDS_camera.GetPicture(); Bitmap image = IDS_camera.GetPicture();
if (image != null) if (image != null)
{ {
@ -238,7 +241,8 @@ namespace Camera_connect
{ {
return; return;
} }
if (string.IsNullOrWhiteSpace(IDS_ExposureTime.Text)) IDS_camera.SetExposureTime(10000);
else IDS_camera.SetExposureTime(Convert.ToDouble(IDS_ExposureTime.Text));
isKeepShotting = true; isKeepShotting = true;
cts = new CancellationTokenSource(); cts = new CancellationTokenSource();
CancellationToken token = cts.Token; CancellationToken token = cts.Token;