捕获图像

This commit is contained in:
zqm
2026-03-18 08:58:39 +08:00
parent 7cd923b91b
commit 47733146ac
8 changed files with 208 additions and 81 deletions

View File

@@ -46,27 +46,31 @@ namespace Test
this.lblIpAddress = new System.Windows.Forms.Label();
this.txtIpAddress = new System.Windows.Forms.TextBox();
this.btnSetIP = new System.Windows.Forms.Button();
this.camera = new System.Windows.Forms.PictureBox();
((System.ComponentModel.ISupportInitialize)(this.LedImage)).BeginInit();
this.statusStrip1.SuspendLayout();
this.groupBox1.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.camera)).BeginInit();
this.SuspendLayout();
//
// LedImage
//
this.LedImage.BackColor = System.Drawing.SystemColors.ControlDark;
this.LedImage.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
this.LedImage.Location = new System.Drawing.Point(12, 12);
this.LedImage.Location = new System.Drawing.Point(16, 15);
this.LedImage.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.LedImage.Name = "LedImage";
this.LedImage.Size = new System.Drawing.Size(557, 426);
this.LedImage.Size = new System.Drawing.Size(742, 532);
this.LedImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;
this.LedImage.TabIndex = 0;
this.LedImage.TabStop = false;
//
// btnInitialize
//
this.btnInitialize.Location = new System.Drawing.Point(608, 38);
this.btnInitialize.Location = new System.Drawing.Point(811, 48);
this.btnInitialize.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnInitialize.Name = "btnInitialize";
this.btnInitialize.Size = new System.Drawing.Size(111, 31);
this.btnInitialize.Size = new System.Drawing.Size(148, 39);
this.btnInitialize.TabIndex = 1;
this.btnInitialize.Text = "1. 初始化";
this.btnInitialize.UseVisualStyleBackColor = true;
@@ -74,46 +78,21 @@ namespace Test
//
// btnSetConfigFile
//
this.btnSetConfigFile.Location = new System.Drawing.Point(608, 89);
this.btnSetConfigFile.Location = new System.Drawing.Point(811, 111);
this.btnSetConfigFile.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnSetConfigFile.Name = "btnSetConfigFile";
this.btnSetConfigFile.Size = new System.Drawing.Size(111, 31);
this.btnSetConfigFile.Size = new System.Drawing.Size(148, 39);
this.btnSetConfigFile.TabIndex = 2;
this.btnSetConfigFile.Text = "2. 设置配置文件";
this.btnSetConfigFile.UseVisualStyleBackColor = true;
this.btnSetConfigFile.Click += new System.EventHandler(this.btnSetConfigFile_Click);
//
// lblIpAddress
//
this.lblIpAddress.AutoSize = true;
this.lblIpAddress.Location = new System.Drawing.Point(608, 125);
this.lblIpAddress.Name = "lblIpAddress";
this.lblIpAddress.Size = new System.Drawing.Size(65, 12);
this.lblIpAddress.TabIndex = 3;
this.lblIpAddress.Text = "IP地址:";
//
// txtIpAddress
//
this.txtIpAddress.Location = new System.Drawing.Point(675, 122);
this.txtIpAddress.Name = "txtIpAddress";
this.txtIpAddress.Size = new System.Drawing.Size(100, 21);
this.txtIpAddress.TabIndex = 4;
this.txtIpAddress.Text = "192.168.100.10";
//
// btnSetIP
//
this.btnSetIP.Location = new System.Drawing.Point(608, 140);
this.btnSetIP.Name = "btnSetIP";
this.btnSetIP.Size = new System.Drawing.Size(111, 31);
this.btnSetIP.TabIndex = 5;
this.btnSetIP.Text = "3. 设置IP地址";
this.btnSetIP.UseVisualStyleBackColor = true;
this.btnSetIP.Click += new System.EventHandler(this.btnSetIP_Click);
//
// btnStartCamera
//
this.btnStartCamera.Location = new System.Drawing.Point(608, 177);
this.btnStartCamera.Location = new System.Drawing.Point(811, 221);
this.btnStartCamera.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnStartCamera.Name = "btnStartCamera";
this.btnStartCamera.Size = new System.Drawing.Size(111, 31);
this.btnStartCamera.Size = new System.Drawing.Size(148, 39);
this.btnStartCamera.TabIndex = 6;
this.btnStartCamera.Text = "4. 启动摄像头";
this.btnStartCamera.UseVisualStyleBackColor = true;
@@ -121,9 +100,10 @@ namespace Test
//
// btnStartCapture
//
this.btnStartCapture.Location = new System.Drawing.Point(608, 228);
this.btnStartCapture.Location = new System.Drawing.Point(811, 285);
this.btnStartCapture.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnStartCapture.Name = "btnStartCapture";
this.btnStartCapture.Size = new System.Drawing.Size(111, 31);
this.btnStartCapture.Size = new System.Drawing.Size(148, 39);
this.btnStartCapture.TabIndex = 7;
this.btnStartCapture.Text = "5. 开始捕获";
this.btnStartCapture.UseVisualStyleBackColor = true;
@@ -131,9 +111,10 @@ namespace Test
//
// btnDetectLeds
//
this.btnDetectLeds.Location = new System.Drawing.Point(608, 279);
this.btnDetectLeds.Location = new System.Drawing.Point(811, 349);
this.btnDetectLeds.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnDetectLeds.Name = "btnDetectLeds";
this.btnDetectLeds.Size = new System.Drawing.Size(111, 31);
this.btnDetectLeds.Size = new System.Drawing.Size(148, 39);
this.btnDetectLeds.TabIndex = 8;
this.btnDetectLeds.Text = "6. LED识别";
this.btnDetectLeds.UseVisualStyleBackColor = true;
@@ -141,9 +122,10 @@ namespace Test
//
// btnGetLedStatuses
//
this.btnGetLedStatuses.Location = new System.Drawing.Point(608, 330);
this.btnGetLedStatuses.Location = new System.Drawing.Point(811, 412);
this.btnGetLedStatuses.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnGetLedStatuses.Name = "btnGetLedStatuses";
this.btnGetLedStatuses.Size = new System.Drawing.Size(111, 31);
this.btnGetLedStatuses.Size = new System.Drawing.Size(148, 39);
this.btnGetLedStatuses.TabIndex = 9;
this.btnGetLedStatuses.Text = "7. 状态查询";
this.btnGetLedStatuses.UseVisualStyleBackColor = true;
@@ -151,9 +133,10 @@ namespace Test
//
// btnShowRegionEditor
//
this.btnShowRegionEditor.Location = new System.Drawing.Point(608, 381);
this.btnShowRegionEditor.Location = new System.Drawing.Point(811, 476);
this.btnShowRegionEditor.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnShowRegionEditor.Name = "btnShowRegionEditor";
this.btnShowRegionEditor.Size = new System.Drawing.Size(111, 31);
this.btnShowRegionEditor.Size = new System.Drawing.Size(148, 39);
this.btnShowRegionEditor.TabIndex = 10;
this.btnShowRegionEditor.Text = "8. 区域编辑器";
this.btnShowRegionEditor.UseVisualStyleBackColor = true;
@@ -161,9 +144,10 @@ namespace Test
//
// btnShutdown
//
this.btnShutdown.Location = new System.Drawing.Point(608, 432);
this.btnShutdown.Location = new System.Drawing.Point(811, 540);
this.btnShutdown.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnShutdown.Name = "btnShutdown";
this.btnShutdown.Size = new System.Drawing.Size(111, 31);
this.btnShutdown.Size = new System.Drawing.Size(148, 39);
this.btnShutdown.TabIndex = 11;
this.btnShutdown.Text = "9. 关闭";
this.btnShutdown.UseVisualStyleBackColor = true;
@@ -171,9 +155,10 @@ namespace Test
//
// btnStopCapture
//
this.btnStopCapture.Location = new System.Drawing.Point(725, 228);
this.btnStopCapture.Location = new System.Drawing.Point(967, 285);
this.btnStopCapture.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnStopCapture.Name = "btnStopCapture";
this.btnStopCapture.Size = new System.Drawing.Size(63, 31);
this.btnStopCapture.Size = new System.Drawing.Size(84, 39);
this.btnStopCapture.TabIndex = 12;
this.btnStopCapture.Text = "停止";
this.btnStopCapture.UseVisualStyleBackColor = true;
@@ -181,9 +166,10 @@ namespace Test
//
// btnStopCamera
//
this.btnStopCamera.Location = new System.Drawing.Point(725, 177);
this.btnStopCamera.Location = new System.Drawing.Point(967, 221);
this.btnStopCamera.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnStopCamera.Name = "btnStopCamera";
this.btnStopCamera.Size = new System.Drawing.Size(63, 31);
this.btnStopCamera.Size = new System.Drawing.Size(84, 39);
this.btnStopCamera.TabIndex = 13;
this.btnStopCamera.Text = "停止";
this.btnStopCamera.UseVisualStyleBackColor = true;
@@ -191,26 +177,30 @@ namespace Test
//
// statusStrip1
//
this.statusStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
this.statusStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.lblStatus});
this.statusStrip1.Location = new System.Drawing.Point(0, 451);
this.statusStrip1.Location = new System.Drawing.Point(0, 693);
this.statusStrip1.Name = "statusStrip1";
this.statusStrip1.Size = new System.Drawing.Size(800, 22);
this.statusStrip1.Padding = new System.Windows.Forms.Padding(1, 0, 19, 0);
this.statusStrip1.Size = new System.Drawing.Size(1067, 25);
this.statusStrip1.TabIndex = 11;
this.statusStrip1.Text = "statusStrip1";
//
// lblStatus
//
this.lblStatus.Name = "lblStatus";
this.lblStatus.Size = new System.Drawing.Size(68, 17);
this.lblStatus.Size = new System.Drawing.Size(107, 20);
this.lblStatus.Text = "状态: 未初始化";
//
// groupBox1
//
this.groupBox1.Controls.Add(this.txtLog);
this.groupBox1.Location = new System.Drawing.Point(12, 444);
this.groupBox1.Location = new System.Drawing.Point(16, 555);
this.groupBox1.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.groupBox1.Name = "groupBox1";
this.groupBox1.Size = new System.Drawing.Size(557, 100);
this.groupBox1.Padding = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.groupBox1.Size = new System.Drawing.Size(743, 125);
this.groupBox1.TabIndex = 12;
this.groupBox1.TabStop = false;
this.groupBox1.Text = "日志";
@@ -218,18 +208,58 @@ namespace Test
// txtLog
//
this.txtLog.Dock = System.Windows.Forms.DockStyle.Fill;
this.txtLog.Location = new System.Drawing.Point(3, 17);
this.txtLog.Location = new System.Drawing.Point(4, 22);
this.txtLog.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.txtLog.Multiline = true;
this.txtLog.Name = "txtLog";
this.txtLog.ScrollBars = System.Windows.Forms.ScrollBars.Vertical;
this.txtLog.Size = new System.Drawing.Size(551, 80);
this.txtLog.Size = new System.Drawing.Size(735, 99);
this.txtLog.TabIndex = 0;
//
// lblIpAddress
//
this.lblIpAddress.AutoSize = true;
this.lblIpAddress.Location = new System.Drawing.Point(811, 156);
this.lblIpAddress.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
this.lblIpAddress.Name = "lblIpAddress";
this.lblIpAddress.Size = new System.Drawing.Size(61, 15);
this.lblIpAddress.TabIndex = 3;
this.lblIpAddress.Text = "IP地址:";
//
// txtIpAddress
//
this.txtIpAddress.Location = new System.Drawing.Point(900, 152);
this.txtIpAddress.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.txtIpAddress.Name = "txtIpAddress";
this.txtIpAddress.Size = new System.Drawing.Size(132, 25);
this.txtIpAddress.TabIndex = 4;
this.txtIpAddress.Text = "192.168.100.10";
//
// btnSetIP
//
this.btnSetIP.Location = new System.Drawing.Point(811, 175);
this.btnSetIP.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.btnSetIP.Name = "btnSetIP";
this.btnSetIP.Size = new System.Drawing.Size(148, 39);
this.btnSetIP.TabIndex = 5;
this.btnSetIP.Text = "3. 设置IP地址";
this.btnSetIP.UseVisualStyleBackColor = true;
this.btnSetIP.Click += new System.EventHandler(this.btnSetIP_Click);
//
// camera
//
this.camera.Location = new System.Drawing.Point(980, 20);
this.camera.Name = "camera";
this.camera.Size = new System.Drawing.Size(52, 50);
this.camera.TabIndex = 14;
this.camera.TabStop = false;
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 574);
this.ClientSize = new System.Drawing.Size(1067, 718);
this.Controls.Add(this.camera);
this.Controls.Add(this.groupBox1);
this.Controls.Add(this.statusStrip1);
this.Controls.Add(this.btnStopCamera);
@@ -246,6 +276,7 @@ namespace Test
this.Controls.Add(this.btnSetConfigFile);
this.Controls.Add(this.btnInitialize);
this.Controls.Add(this.LedImage);
this.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
this.Name = "Form1";
this.Text = "XCamera LED灯识别测试程序";
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form1_FormClosing);
@@ -254,6 +285,7 @@ namespace Test
this.statusStrip1.PerformLayout();
this.groupBox1.ResumeLayout(false);
this.groupBox1.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.camera)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
@@ -279,5 +311,6 @@ namespace Test
private System.Windows.Forms.Label lblIpAddress;
private System.Windows.Forms.TextBox txtIpAddress;
private System.Windows.Forms.Button btnSetIP;
private System.Windows.Forms.PictureBox camera;
}
}

View File

@@ -186,7 +186,8 @@ namespace Test
LogMessage("正在启动摄像头...");
if (global::XCamera.XCamera.StartCamera())
// 使用camera控件的窗口句柄进行预览
if (global::XCamera.XCamera.StartCamera(camera.Handle))
{
LogMessage("摄像头启动成功!");
}

View File

@@ -117,4 +117,7 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="statusStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
<value>17, 17</value>
</metadata>
</root>