From 85ba963a935d18fe4ecf7b82c78c0e87404d96f0 Mon Sep 17 00:00:00 2001 From: "xhm\\HP" <1173131411@qq.com> Date: Fri, 31 May 2024 11:16:22 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HisenceYoloDetection/MainForm.cs | 35 ++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/HisenceYoloDetection/MainForm.cs b/HisenceYoloDetection/MainForm.cs index bf92fb8..dcbdf39 100644 --- a/HisenceYoloDetection/MainForm.cs +++ b/HisenceYoloDetection/MainForm.cs @@ -497,7 +497,7 @@ namespace HisenceYoloDetection int IfXZeros = melsecPLCTCPDriver.ReadInt("102"); int IfYZeros = melsecPLCTCPDriver.ReadInt("112"); int IfZZeros = melsecPLCTCPDriver.ReadInt("122"); - if (IfXZeros <= 40 && IfYZeros <= 140 && IfZZeros <= 40) + if (IfXZeros <= 140 && IfYZeros <= 140 && IfZZeros <= 140) { StartDecBtn.Enabled = true; break; @@ -519,15 +519,15 @@ namespace HisenceYoloDetection /// /// 全图洗衣机 裁剪之后 OCR识别的结果 /// - /// - /// - /// + /// 全图图片 + /// 全局图片上的目标定位结果(包括定位矩形框) + /// 返回的定位框的结果 private void InsertSqlRunData(ref Mat currentMatC, MLResult cam1TwoML, ref List strMatListList, ref PaddleOcrModel IOcrModel) { -#if false +#if true try { List mats = new List(); @@ -900,6 +900,11 @@ namespace HisenceYoloDetection myLog("第一次采集图像", DateTime.Now); //移动模组 读三次测距的地址 看是否往前移动 + MoveToP(8974, 0, 0); + + + + List DisList = new List(); for (int i = 0; i < 5; i++) { @@ -911,9 +916,12 @@ namespace HisenceYoloDetection // 计算剩余值的平均数 double average = DisList.Average(); double disreal = average * (-0.54054) + 1324.3232; - - - MoveToP(8974, 0, (int)(disreal)); + //测距距离-标准距离=要移动的距离 + double dismove = disreal - 876; + if(dismove>0&& dismove<4000) + { + MoveToP(8974, 0, (int)(dismove)); + } Thread.Sleep(500); Cam1.SnapshotCount = 0; Cam1.Snapshot(); @@ -925,8 +933,7 @@ namespace HisenceYoloDetection // MoveToP(xKNow.MoveTwoX, xKNow.MoveTwoY, xKNow.MoveTwoZ); //} // currentXP = 54964; - MoveToP(54964, 0, (int)(disreal)); - //Thread.Sleep(3000); + MoveToP(54964, 0, (int)(dismove)); Cam1.Snapshot(); MoveToP(8974, 0, 0); //if (xKNow != null) @@ -999,7 +1006,7 @@ namespace HisenceYoloDetection { // Mat mat = Cv2.ImRead("F:\\海信洗衣机\\cam1\\2024517161641.jpg"); Cam1ImgOne = cameraMat; - IfCam2Triger = true; + IfCam1OneTriger = true; originMatShow.Image = cameraMat.ToBitmap(); //pictureBox1.Image = cameraMat.ToBitmap(); @@ -1035,9 +1042,7 @@ namespace HisenceYoloDetection { Directory.CreateDirectory(fitImageFolder); } - //第一次拍照 - if (SnapshotCount == 1) - { + // Mat mat = Cv2.ImRead("F:\\海信洗衣机\\cam1\\2024517161641.jpg"); Cam2ImgShowBar = cameraMat; IfCam2Triger = true; @@ -1045,7 +1050,7 @@ namespace HisenceYoloDetection //pictureBox1.Image = cameraMat.ToBitmap(); - } + pictureBox2.Image = cameraMat.ToBitmap();