修改逻辑

This commit is contained in:
xhm\HP 2024-07-09 17:06:36 +08:00
parent ca2403b323
commit 08ab697a02
2 changed files with 135 additions and 15 deletions

View File

@ -29,6 +29,11 @@
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
OpenCvSharp.Mat mat4 = new OpenCvSharp.Mat();
OpenCvSharp.Mat mat3 = new OpenCvSharp.Mat();
OpenCvSharp.Mat mat2 = new OpenCvSharp.Mat();
OpenCvSharp.Mat mat1 = new OpenCvSharp.Mat();
OpenCvSharp.Mat mat5 = new OpenCvSharp.Mat();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
tabPage2 = new TabPage();
panel1 = new Panel();
@ -184,6 +189,11 @@
richTextBox1 = new RichTextBox();
contextMenuStrip1 = new ContextMenuStrip(components);
backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
canvas1 = new XKRS.UI.Canvas();
canvas2 = new XKRS.UI.Canvas();
canvas3 = new XKRS.UI.Canvas();
canvas4 = new XKRS.UI.Canvas();
canvas5 = new XKRS.UI.Canvas();
tabPage2.SuspendLayout();
panel1.SuspendLayout();
groupBox5.SuspendLayout();
@ -1194,13 +1204,17 @@
// groupBox2
//
groupBox2.AutoSize = true;
groupBox2.Controls.Add(canvas4);
groupBox2.Controls.Add(canvas3);
groupBox2.Controls.Add(canvas2);
groupBox2.Controls.Add(canvas1);
groupBox2.Controls.Add(originMatShow);
groupBox2.Controls.Add(ResultMatShow);
groupBox2.Location = new Point(0, 0);
groupBox2.Margin = new Padding(4, 2, 4, 2);
groupBox2.Name = "groupBox2";
groupBox2.Padding = new Padding(4, 2, 4, 2);
groupBox2.Size = new Size(738, 718);
groupBox2.Size = new Size(738, 736);
groupBox2.TabIndex = 0;
groupBox2.TabStop = false;
groupBox2.Text = "图片";
@ -1228,6 +1242,7 @@
//
// panel8
//
panel8.Controls.Add(canvas5);
panel8.Controls.Add(textBox2);
panel8.Controls.Add(label36);
panel8.Controls.Add(textBox1);
@ -1813,6 +1828,111 @@
contextMenuStrip1.Name = "contextMenuStrip1";
contextMenuStrip1.Size = new Size(61, 4);
//
// canvas1
//
canvas1.AllowSelectDefect = true;
canvas1.BrushColor = null;
canvas1.ImagePath = "";
mat4.IsEnabledDispose = true;
canvas1.ImaMAt = mat4;
canvas1.ImgData = null;
canvas1.Location = new Point(8, 237);
canvas1.MoveStep = 5F;
canvas1.Name = "canvas1";
canvas1.Route = 0D;
canvas1.Scale = 1D;
canvas1.Size = new Size(351, 198);
canvas1.TabIndex = 4;
canvas1.WholeScale = 0F;
canvas1.XMove = 0F;
canvas1.XScale = 0F;
canvas1.YMove = 0F;
canvas1.YScale = 0F;
//
// canvas2
//
canvas2.AllowSelectDefect = true;
canvas2.BrushColor = null;
canvas2.ImagePath = "";
mat3.IsEnabledDispose = true;
canvas2.ImaMAt = mat3;
canvas2.ImgData = null;
canvas2.Location = new Point(367, 237);
canvas2.MoveStep = 5F;
canvas2.Name = "canvas2";
canvas2.Route = 0D;
canvas2.Scale = 1D;
canvas2.Size = new Size(351, 198);
canvas2.TabIndex = 5;
canvas2.WholeScale = 0F;
canvas2.XMove = 0F;
canvas2.XScale = 0F;
canvas2.YMove = 0F;
canvas2.YScale = 0F;
//
// canvas3
//
canvas3.AllowSelectDefect = true;
canvas3.BrushColor = null;
canvas3.ImagePath = "";
mat2.IsEnabledDispose = true;
canvas3.ImaMAt = mat2;
canvas3.ImgData = null;
canvas3.Location = new Point(0, 515);
canvas3.MoveStep = 5F;
canvas3.Name = "canvas3";
canvas3.Route = 0D;
canvas3.Scale = 1D;
canvas3.Size = new Size(351, 198);
canvas3.TabIndex = 6;
canvas3.WholeScale = 0F;
canvas3.XMove = 0F;
canvas3.XScale = 0F;
canvas3.YMove = 0F;
canvas3.YScale = 0F;
//
// canvas4
//
canvas4.AllowSelectDefect = true;
canvas4.BrushColor = null;
canvas4.ImagePath = "";
mat1.IsEnabledDispose = true;
canvas4.ImaMAt = mat1;
canvas4.ImgData = null;
canvas4.Location = new Point(367, 517);
canvas4.MoveStep = 5F;
canvas4.Name = "canvas4";
canvas4.Route = 0D;
canvas4.Scale = 1D;
canvas4.Size = new Size(351, 198);
canvas4.TabIndex = 7;
canvas4.WholeScale = 0F;
canvas4.XMove = 0F;
canvas4.XScale = 0F;
canvas4.YMove = 0F;
canvas4.YScale = 0F;
//
// canvas5
//
canvas5.AllowSelectDefect = true;
canvas5.BrushColor = null;
canvas5.ImagePath = "";
mat5.IsEnabledDispose = true;
canvas5.ImaMAt = mat5;
canvas5.ImgData = null;
canvas5.Location = new Point(7, 515);
canvas5.MoveStep = 5F;
canvas5.Name = "canvas5";
canvas5.Route = 0D;
canvas5.Scale = 1D;
canvas5.Size = new Size(351, 198);
canvas5.TabIndex = 18;
canvas5.WholeScale = 0F;
canvas5.XMove = 0F;
canvas5.XScale = 0F;
canvas5.YMove = 0F;
canvas5.YScale = 0F;
//
// MainForm
//
AutoScaleDimensions = new SizeF(8F, 17F);

View File

@ -1339,6 +1339,12 @@ namespace HisenceYoloDetection
}
if (iNum1 >= 2)
{
if (!StopM)
{
melsecPLCTCPDriver.WriteInt("550", 1);//阻塞
StopM = true;
}
if (bBar)
{
_runHandleBefore.WaitOne();
@ -1402,26 +1408,21 @@ namespace HisenceYoloDetection
{
// Old_xKNow = xKNow;
myLog("型号匹配成功" + xKNow.OcrBar, DateTime.Now);
bBarTriger = true;
//MoveToP(xKNow.MoveX, xKNow.MoveY, xKNow.MoveZ);// PLC控制电机移动四轴
}
break;
// break;
}
Thread.Sleep(2);
bBar = false;
#if true
if (bBarTriger)//证明读码器读到东西
// if (bBarTriger)//证明读码器读到东西
{
if (!StopM)
{
melsecPLCTCPDriver.WriteInt("550", 1);//阻塞
StopM = true;
}
myLog("第一次采集图像", DateTime.Now);
//移动模组 读三次测距的地址 看是否往前移动
@ -1447,8 +1448,7 @@ namespace HisenceYoloDetection
{
MoveToP(5815, YPos, ZPos + (int)(dismove));
}
//Thread.Sleep(2000);//删
// Thread.Sleep(500);
Cam1.SnapshotCount = 0;
Cam1.Snapshot();
@ -1603,7 +1603,7 @@ namespace HisenceYoloDetection
IfCam1OneTriger = true;
originMatShow.Image = cameraMat.ToBitmap();
//pictureBox1.Image = cameraMat.ToBitmap();
_runHandleAfter.Set();
}
//第二次拍照
@ -1615,7 +1615,7 @@ namespace HisenceYoloDetection
IfCam1TwoTriger = true;
//originMatShow2.Image = cameraMat.ToBitmap();
_runHandleAfter.Set();
}
@ -3036,7 +3036,7 @@ namespace HisenceYoloDetection
break;
case 6:
{
canvas6.ImaMAt = detectionImage;
//canvas6.ImaMAt = detectionImage;
}
break;
case 7: