From f1a9e759173b1841ca19ac78a67238cb90ddda61 Mon Sep 17 00:00:00 2001 From: YZJ Date: Mon, 15 Jul 2024 17:45:27 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HisenceYoloDetection/MainForm.Designer.cs | 140 ++++------------------ HisenceYoloDetection/MainForm.cs | 75 +++++------- 2 files changed, 58 insertions(+), 157 deletions(-) diff --git a/HisenceYoloDetection/MainForm.Designer.cs b/HisenceYoloDetection/MainForm.Designer.cs index d6f33c4..cbbba00 100644 --- a/HisenceYoloDetection/MainForm.Designer.cs +++ b/HisenceYoloDetection/MainForm.Designer.cs @@ -29,11 +29,6 @@ private void InitializeComponent() { components = new System.ComponentModel.Container(); - OpenCvSharp.Mat mat1 = new OpenCvSharp.Mat(); - OpenCvSharp.Mat mat2 = new OpenCvSharp.Mat(); - OpenCvSharp.Mat mat3 = new OpenCvSharp.Mat(); - OpenCvSharp.Mat mat4 = 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(); @@ -128,6 +123,8 @@ originMatShow = new PictureBox(); ResultMatShow = new PictureBox(); panel8 = new Panel(); + label24 = new Label(); + ScannerBox = new TextBox(); textBox2 = new TextBox(); label36 = new Label(); textBox1 = new TextBox(); @@ -173,11 +170,6 @@ queryALLBtn = new Button(); label32 = new Label(); InsertDataDgv = new DataGridView(); - canvas4 = new XKRS.UI.Canvas(); - canvas3 = new XKRS.UI.Canvas(); - canvas2 = new XKRS.UI.Canvas(); - canvas1 = new XKRS.UI.Canvas(); - canvas5 = new XKRS.UI.Canvas(); timer1 = new System.Windows.Forms.Timer(components); timer2 = new System.Windows.Forms.Timer(components); timer3 = new System.Windows.Forms.Timer(components); @@ -1230,6 +1222,8 @@ // // panel8 // + panel8.Controls.Add(label24); + panel8.Controls.Add(ScannerBox); panel8.Controls.Add(textBox2); panel8.Controls.Add(label36); panel8.Controls.Add(textBox1); @@ -1253,6 +1247,25 @@ panel8.TabIndex = 2; panel8.Paint += panel8_Paint; // + // label24 + // + label24.AutoSize = true; + label24.Location = new Point(33, 287); + label24.Margin = new Padding(4, 0, 4, 0); + label24.Name = "label24"; + label24.Size = new Size(50, 17); + label24.TabIndex = 19; + label24.Text = "扫码器"; + // + // ScannerBox + // + ScannerBox.Location = new Point(91, 284); + ScannerBox.Margin = new Padding(4, 2, 4, 2); + ScannerBox.Name = "ScannerBox"; + ScannerBox.ReadOnly = true; + ScannerBox.Size = new Size(255, 23); + ScannerBox.TabIndex = 18; + // // textBox2 // textBox2.Location = new Point(437, 287); @@ -1724,111 +1737,6 @@ InsertDataDgv.Size = new Size(1601, 206); InsertDataDgv.TabIndex = 0; // - // 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; - // - // 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; - // - // 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; - // - // 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; - // - // 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; - // // richTextBox1 // richTextBox1.Dock = DockStyle.Bottom; @@ -2054,5 +1962,7 @@ private XKRS.UI.Canvas canvas6; private XKRS.UI.Canvas canvas2; private Button button1; + private Label label24; + private TextBox ScannerBox; } } diff --git a/HisenceYoloDetection/MainForm.cs b/HisenceYoloDetection/MainForm.cs index 04fc9b3..98428dc 100644 --- a/HisenceYoloDetection/MainForm.cs +++ b/HisenceYoloDetection/MainForm.cs @@ -597,7 +597,7 @@ namespace HisenceYoloDetection melsecPLCTCPDriver.WriteInt(YellowLightingAdress, 1);//Ƶ melsecPLCTCPDriver.WriteInt(GreenLightingAdress, 0);//̵ - + melsecPLCTCPDriver.WriteInt(WaringAdress, 0);// //t = new System.Timers.Timer(10000);//ʵTimer࣬üʱΪ10000룻 //t.Elapsed += new System.Timers.ElapsedEventHandler(Execute);//ʱʱִ¼ //t.AutoReset = true;//ִһΣfalseһֱִ(true) @@ -1486,16 +1486,22 @@ namespace HisenceYoloDetection //ijɺͺŵĶԽ string OcrBar = ""; string FinalDefIDToFind = m_sKEYENCEBar.Substring(1, 18);// Ŀ FinalDefID -#if false - { - OcrBar=FormBarType(FinalDefIDToFind) + this.Invoke(new Action(() => + { + + ScannerBox.Text = FinalDefIDToFind; + + })); + myLog("ɨ" + m_sKEYENCEBar, DateTime.Now); +#if true + + OcrBar = FormBarType(FinalDefIDToFind); +#else + OcrBar = "OZ.ϴ».WF3G7014-NVW001CZA.WSG374A."; #endif // if(Oldm_sKEYENCEBar!= m_sKEYENCEBar) - if (DayTypeDics.ContainsKey(FinalDefIDToFind))//յpostдSN õͺ - { - OcrBar = DayTypeDics[FinalDefIDToFind]; - } + if (OcrBar.IsNullOrEmpty()) { break; @@ -1512,7 +1518,7 @@ namespace HisenceYoloDetection if (Regex.IsMatch(xKNow.MoveX.ToString(), @"^[0-9]+$") && Regex.IsMatch(xKNow.MoveY.ToString(), @"^[0-9]+$") && Regex.IsMatch(xKNow.MoveZ.ToString(), @"^[0-9]+$")) { - myLog("ͺƥɹ" + xKNow.OcrBar, DateTime.Now); + // myLog("ͺƥɹ" + xKNow.OcrBar, DateTime.Now); } @@ -1706,8 +1712,8 @@ namespace HisenceYoloDetection { - Cam1ImgOne = Cv2.ImRead("D:\\Hisence\\\\1\\001.jpg"); ; - //Cam1ImgOne = cameraMat; + // Cam1ImgOne = Cv2.ImRead("D:\\Hisence\\\\1\\001.jpg"); ; + Cam1ImgOne = cameraMat; IfCam1OneTriger = true; originMatShow.Image = cameraMat.ToBitmap(); //pictureBox1.Image = cameraMat.ToBitmap(); @@ -1800,6 +1806,17 @@ namespace HisenceYoloDetection // IOcrBAr = "W821PWMS27106WD2"; // IOcrBAr= //ݿȶ + if (xKNow == null) + { + myLog("δƥ" , DateTime.Now); + break; + } + + if (xKNow.OcrBar == null) + { + myLog("δƥɹ" + xKNow.OcrBar, DateTime.Now); + break; + } string IOcrBAr = xKNow.OcrBar; //xKNow = GetModeFromBar(IOcrBAr);//ݿвѯֵ //ijɺͺŵĶԽ @@ -1811,17 +1828,7 @@ namespace HisenceYoloDetection { xK_HisenceSQLWord = xkWordList[0]; } - if (xKNow == null) - { - myLog("δƥ" + IOcrBAr, DateTime.Now); - break; - } - - if (xKNow.OcrBar == null) - { - myLog("δƥɹ" + IOcrBAr, DateTime.Now); - break; - } + if (xKNow.Detect != "") { ////ʱеϴ»Ǻ֮ǰһģ @@ -1893,22 +1900,6 @@ namespace HisenceYoloDetection } - //// - //MLRequest req2 = new MLRequest(); - //req2.currentMat = Cam1ImgTwo; - //req2.ResizeWidth = 640; - //req2.ResizeHeight = 640; - //req2.Score = 0.3f; - //req2.in_lable_path = LablePath;//ǩ· - //req2.confThreshold = 0.3f;//ģŶ - //req2.iouThreshold = 0.4f;//IOU - //req2.out_node_name = "output"; - //MLResult mL2 = simboObjectDetection.RunInferenceFixed(req2); - //if (mL2.ResultMap != null) - //{ - // mL2.ResultMap.Save("D://cam1//" + dt.Year.ToString() + dt.Month.ToString() + dt.Day.ToString() + dt.Hour.ToString() + dt.Minute.ToString() + dt.Millisecond.ToString() + "2result.jpg"); - // ResultMatShow2.Image = mL2.ResultMap; - //} List strMatListTwo = new List(); List strMatFuzzyListTwo = new List(); @@ -1967,8 +1958,8 @@ namespace HisenceYoloDetection { //жϿֵǷкƥfalse bool containsFalseValue = keyValueResult.ContainsValue(false); - bool containsFalseValue2 = keyValueResult2.ContainsValue(false); - if (containsFalseValue || containsFalseValue2) + + if (containsFalseValue) MatchStr = false; @@ -1979,7 +1970,7 @@ namespace HisenceYoloDetection // int sqlblocksum= - + melsecPLCTCPDriver.WriteInt("550", 0);// if (MatchStr) { @@ -2351,7 +2342,7 @@ namespace HisenceYoloDetection TriggerCameral2();//紥 SNȡͺ ݿеõֵ ReadyDetect();//պ߳ - ThreadPost();//պȡյͺ + //ThreadPost();//պȡյͺ myLog("̳ɹ", DateTime.Now); }