diff --git a/MaiMuAOI/.vs/MaiMuAOI/FileContentIndex/16917a73-edc7-470d-90ed-59ba1be8fa33.vsidx b/MaiMuAOI/.vs/MaiMuAOI/FileContentIndex/16917a73-edc7-470d-90ed-59ba1be8fa33.vsidx deleted file mode 100644 index 4f1d14e..0000000 Binary files a/MaiMuAOI/.vs/MaiMuAOI/FileContentIndex/16917a73-edc7-470d-90ed-59ba1be8fa33.vsidx and /dev/null differ diff --git a/MaiMuAOI/.vs/MaiMuAOI/FileContentIndex/9d565955-7297-42d5-860b-f3abe0a1df7f.vsidx b/MaiMuAOI/.vs/MaiMuAOI/FileContentIndex/9d565955-7297-42d5-860b-f3abe0a1df7f.vsidx new file mode 100644 index 0000000..8300e20 Binary files /dev/null and b/MaiMuAOI/.vs/MaiMuAOI/FileContentIndex/9d565955-7297-42d5-860b-f3abe0a1df7f.vsidx differ diff --git a/MaiMuAOI/MaiMuAOI/ImageProcessing/DefectLib.cs b/MaiMuAOI/MaiMuAOI/ImageProcessing/DefectLib.cs index baaa826..021bfe7 100644 --- a/MaiMuAOI/MaiMuAOI/ImageProcessing/DefectLib.cs +++ b/MaiMuAOI/MaiMuAOI/ImageProcessing/DefectLib.cs @@ -213,7 +213,9 @@ namespace MaiMuAOI.ImageProcessing //Bitmap bmp = yolo1.Read2Bmp(file_path); //切割图像,输入图像格式14208*10640 stopwatch.Start(); - task.bmps_cut = yolo1.OpenCVToCutsMat(task.bmp, task.cut_size.Width, task.cut_size.Height); + var toMat = task.bmp.Clone(); + task.bmps_cut = yolo1.OpenCVToCutsMat(toMat, task.cut_size.Width, task.cut_size.Height); + toMat.Dispose(); stopwatch.Stop(); task.stopwatch[0] = stopwatch.ElapsedMilliseconds; @@ -269,7 +271,7 @@ namespace MaiMuAOI.ImageProcessing if(t_ClaseeName == "钢网") task.informationList = yolo1.ScreeningResults_YD_GW(results, task.bmps_resize, task.thresholds, task.thresholdsClass, task.recAreaThreshold); else - task.informationList = yolo1.ScreeningResults_YD(results, task.bmps_resize, task.thresholds, task.thresholdsClass, task.recAreaThreshold); + task.informationList = yolo1.ScreeningResults_JB(results, task.bmps_resize, task.thresholds, task.thresholdsClass, task.recAreaThreshold); liStep = 2; diff --git a/MaiMuAOI/MaiMuAOI/ImageProcessing/SizeLib.cs b/MaiMuAOI/MaiMuAOI/ImageProcessing/SizeLib.cs index f89c9c3..3d8af94 100644 --- a/MaiMuAOI/MaiMuAOI/ImageProcessing/SizeLib.cs +++ b/MaiMuAOI/MaiMuAOI/ImageProcessing/SizeLib.cs @@ -1,4 +1,6 @@ -using HalconDotNet; +#define JB + +using HalconDotNet; using MaiMuControl.Device; using Newtonsoft.Json; using Newtonsoft.Json.Linq; @@ -215,6 +217,10 @@ namespace MaiMuAOI.ImageProcessing if (!string.IsNullOrWhiteSpace(task.drawingPagePath) && task.defectInfor2RestorationDesk != null && task.defectInfor2RestorationDesk.Count > 0) task.defectInfor2RestorationDeskPage = yolo5.DefectDrawGerberImage(task.drawingPagePath, task.defectInfor2RestorationDesk); } +#if JB + var shanxian = ProcCall1_PI_PT.GetOutputIconicParamObject("Image_shanxian"); + task.JB_Mat = yolo5.HImageToMat(shanxian); +#endif break; case 111: task.MarkPointList[0] = (double)ProcCall1_PI_PT.GetOutputCtrlParamTuple("PoseMarkX_1"); @@ -326,6 +332,8 @@ namespace MaiMuAOI.ImageProcessing public double PT1,PT2, Shanxian, Circle_Ymm, Circle_Xmm, offsetX, offsetY; public bool isSucceed;//转换是否成功 public string resultInfo = "";//成功或失败信息 + + public Mat JB_Mat;//晶宝使用 } public void add(SizeTask task) diff --git a/MaiMuAOI/MaiMuAOI/SysCtrl/SysEnum.cs b/MaiMuAOI/MaiMuAOI/SysCtrl/SysEnum.cs index abde28c..0b9f61e 100644 --- a/MaiMuAOI/MaiMuAOI/SysCtrl/SysEnum.cs +++ b/MaiMuAOI/MaiMuAOI/SysCtrl/SysEnum.cs @@ -108,7 +108,13 @@ namespace MaiMuAOI.SysCtrl [Description("栅线")] sx, [Description("断栅")] - ds, + ds, + [Description("正常1")] + na, + [Description("断线")] + dx, + [Description("未打穿")] + wdc, } public enum DefectNameEnum { @@ -123,7 +129,10 @@ namespace MaiMuAOI.SysCtrl 压线, 斜边, 栅线, - 断栅 + 断栅, + 正常1, + 断线, + 未打穿 } public enum DefectCode2Enum diff --git a/MaiMuAOI/MaiMuAOI/SysCtrl/SysMgr.cs b/MaiMuAOI/MaiMuAOI/SysCtrl/SysMgr.cs index 3de55cf..9c82862 100644 --- a/MaiMuAOI/MaiMuAOI/SysCtrl/SysMgr.cs +++ b/MaiMuAOI/MaiMuAOI/SysCtrl/SysMgr.cs @@ -1,4 +1,7 @@ -using HalconDotNet; +//#define JB + +using CCWin.Win32.Const; +using HalconDotNet; using HZH_Controls.Forms; using MaiMuAOI.ImageProcessing; using MaiMuAOI.SysUI.ProductAndStep; @@ -282,6 +285,8 @@ namespace MaiMuAOI.SysCtrl public string LightName { get { return "Light"; } } public int LightChCount = 6; + private int snapCnt = 15;//拍照失败后重新拍照 + private CamDev camDev; /// /// 相机控制 @@ -1887,6 +1892,8 @@ namespace MaiMuAOI.SysCtrl case "sx": order.SXCount++; break; + default: + break; } } } @@ -2180,40 +2187,55 @@ namespace MaiMuAOI.SysCtrl CamDev.SetGain(Gain); CamDev.SetResultingFrameRate(ResultingFrameRate); - DateTime dt = DateTime.Now; - CamDev.ClearImageQueue(); - Acquisition acq = CamDev.Snap(1, 5000); - if (acq.GrabStatus != "GrabPass") - { - Log($"{stepIndex + 1}-{processName}", $"相机采集照片失败!", WarningEnum.High); - return stepIndex; - } - Log($"{stepIndex + 1}-{processName}", $"相机采集照片完成[" + (DateTime.Now - dt).Milliseconds.ToString() + "ms]" ); - //显示 - OnAutoRuning(new RunEventArgs(acq.Image)); - //----缺陷队列 + for (int snapi = 0; snapi < snapCnt; snapi++) + { + DateTime dt = DateTime.Now; + CamDev.ClearImageQueue(); + Acquisition acq = CamDev.Snap(1, 6000); + if (acq.GrabStatus != "GrabPass") + { + if (snapi < snapCnt - 1) + { + Log($"{stepIndex + 1}-{processName}", $"相机采集照片失败{acq.GrabStatus}-{snapi}!", WarningEnum.Low); + Thread.Sleep(500); + continue; + } + else + { + Log($"{stepIndex + 1}-{processName}", $"相机采集照片失败{acq.GrabStatus}-{snapi}!", WarningEnum.High); + return stepIndex; + } + } + Log($"{stepIndex + 1}-{processName}", $"相机采集照片完成[" + (DateTime.Now - dt).Milliseconds.ToString() + "ms]" ); + //显示 + OnAutoRuning(new RunEventArgs(acq.Image)); + //----缺陷队列 - if (AIEngineLib == AIEngineLibEnum.缺陷库 || AIEngineLib == AIEngineLibEnum.缺陷与测量库) - { - - var mat = CamDev.HImageToMat(acq.Image); - scannerGBmpQueue.Enqueue(new scannerGBmpLoc(mat, - GetAxisPosValueMM((int)AxisName.Axis0), - GetAxisPosValueMM((int)AxisName.Axis1)));//Dequeue - Log($"{stepIndex + 1}-{processName}", $"缺陷图像队列数量: {scannerGBmpQueue.Count}"); + if (AIEngineLib == AIEngineLibEnum.缺陷库 || AIEngineLib == AIEngineLibEnum.缺陷与测量库) + { +#if JB + Log($"{stepIndex + 1}-{processName}", $"跳过,缺陷图像队列数量: {scannerGBmpQueue.Count}"); +#else + var mat = CamDev.HImageToMat(acq.Image); + scannerGBmpQueue.Enqueue(new scannerGBmpLoc(mat, + GetAxisPosValueMM((int)AxisName.Axis0), + GetAxisPosValueMM((int)AxisName.Axis1)));//Dequeue + Log($"{stepIndex + 1}-{processName}", $"缺陷图像队列数量: {scannerGBmpQueue.Count}"); +#endif + } + if (AIEngineLib == AIEngineLibEnum.测量库 || AIEngineLib == AIEngineLibEnum.缺陷与测量库) + { + scannerCBmpQueue.Enqueue(new scannerCBmpLoc( + acq.Image.Clone(), + GetAxisPosValueMM((int)AxisName.Axis0), + GetAxisPosValueMM((int)AxisName.Axis1)));//Dequeue + Log($"{stepIndex + 1}-{processName}", $"添加尺寸图像队列," + + $"X:{GetAxisPosValueMM((int)AxisName.Axis0)},y:{GetAxisPosValueMM((int)AxisName.Axis1)}," + + $"数量: {scannerCBmpQueue.Count}"); + } + break; } - if (AIEngineLib == AIEngineLibEnum.测量库 || AIEngineLib == AIEngineLibEnum.缺陷与测量库) - { - scannerCBmpQueue.Enqueue(new scannerCBmpLoc( - acq.Image.Clone(), - GetAxisPosValueMM((int)AxisName.Axis0), - GetAxisPosValueMM((int)AxisName.Axis1)));//Dequeue - Log($"{stepIndex + 1}-{processName}", $"添加尺寸图像队列," + - $"X:{GetAxisPosValueMM((int)AxisName.Axis0)},y:{GetAxisPosValueMM((int)AxisName.Axis1)}," + - $"数量: {scannerCBmpQueue.Count}"); - } - - #endregion +#endregion break; case "Scanner_CC": #region @@ -2276,7 +2298,7 @@ namespace MaiMuAOI.SysCtrl double[] getPosArray = getPosList.ToArray(); if (scannerCBmpQueue.Count < 1) { - Log($"{stepIndex + 1}-{processName}", $"尺寸检测异常,无源图像!!", WarningEnum.Low); + Log($"{stepIndex + 1}-{processName}", $"尺寸检测异常,无源图像!!", WarningEnum.High); return stepIndex; } var bmpCBmpQueue = scannerCBmpQueue.Dequeue(); @@ -2403,6 +2425,13 @@ namespace MaiMuAOI.SysCtrl Log($"{res.stepIndex + 1}-{res.processName}", $"图像比对失败,index:{res.index}-{compBmpIndex}.", WarningEnum.Low); } compBmpIndex++; +#if JB + //将比对图片传入缺陷检测 + scannerGBmpQueue.Enqueue(new scannerGBmpLoc(res.JB_Mat.Clone(), + res.posX, + res.posY));//Dequeue + Log($"{stepIndex + 1}-{processName}", $"获取缺陷图像队列数量: {scannerGBmpQueue.Count},位置{res.posX}-{res.posY}"); +#endif } //MARK else if (res.index == 111 || res.index == 222 || res.index == 333 || res.index == 444) @@ -2562,13 +2591,20 @@ namespace MaiMuAOI.SysCtrl } }); +#if JB + //强制等到比对完成才可以缺陷检测 + if (!endEvent.WaitOne(60000)) + Log($"{stepIndex + 1}-{processName}", $"{sizeIndex}等待超时!", WarningEnum.High); + +#else //需等上面异步回调中的相对偏移校正完成再继续 if (!asynRun || sizeIndex % 10 == 0) { if (!endEvent.WaitOne(60000)) Log($"{stepIndex + 1}-{processName}", $"{sizeIndex}等待超时,忽略继续!", WarningEnum.Low); } - #endregion +#endif +#endregion break; case "Defect": #region @@ -2576,7 +2612,7 @@ namespace MaiMuAOI.SysCtrl lowerThresholdVal = processParam.Value("LowerThresholdVal"); if (scannerGBmpQueue.Count < 1) { - Log($"{stepIndex + 1}-{processName}", $"缺陷检测异常,无源图像!!", WarningEnum.Low); + Log($"{stepIndex + 1}-{processName}", $"缺陷检测异常,无源图像!!", WarningEnum.High); return stepIndex; } var bmpLoc = scannerGBmpQueue.Dequeue(); @@ -2591,6 +2627,15 @@ namespace MaiMuAOI.SysCtrl if (!File.Exists(gbxBmpPath + attachmentFile.ExtendName)) gbxBmpPath = ""; } Log($"{stepIndex + 1}-{processName}", $"图纸路径:{gbxBmpPath}"); + string ThresholdsClassStr = processParam.Value("ThresholdsClass"); + if (processParam.Value("ThresholdsClass").Split(',').Length < 30) + { + for (int i = 0; i < 30 - processParam.Value("ThresholdsClass").Split(',').Length; i++) + { + ThresholdsClassStr += ",0.3"; + } + Log($"{stepIndex + 1}-{processName}", $"新模型补全:{ThresholdsClassStr}"); + } defectLib.add(new DefectTask() { stepIndex = stepIndex, @@ -2603,7 +2648,7 @@ namespace MaiMuAOI.SysCtrl cut_size = new System.Drawing.Size(Convert.ToInt32(aarCut_size[0]), Convert.ToInt32(aarCut_size[1])), resize = new System.Drawing.Size(Convert.ToInt32(aarResize[0]), Convert.ToInt32(aarResize[1])), thresholds = processParam.Value("Thresholds"), - thresholdsClass = processParam.Value("ThresholdsClass"), + thresholdsClass = ThresholdsClassStr, recAreaThreshold = getProductAreaThreshol(model), //qxName,面积; qxName,面积; qxName,面积; finishEvent = (res) => { @@ -3040,7 +3085,7 @@ namespace MaiMuAOI.SysCtrl return 0; } } - #endregion +#endregion #region 日志图片删除 #region 文件删除 diff --git a/MaiMuAOI/MaiMuAOI/SysUI/ProductAndStep/ProductInfoFrm.Designer.cs b/MaiMuAOI/MaiMuAOI/SysUI/ProductAndStep/ProductInfoFrm.Designer.cs index 2d8a9b1..1126fb9 100644 --- a/MaiMuAOI/MaiMuAOI/SysUI/ProductAndStep/ProductInfoFrm.Designer.cs +++ b/MaiMuAOI/MaiMuAOI/SysUI/ProductAndStep/ProductInfoFrm.Designer.cs @@ -30,10 +30,10 @@ { this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProductInfoFrm)); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle5 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle6 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle7 = new System.Windows.Forms.DataGridViewCellStyle(); - System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle8 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle(); + System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle4 = new System.Windows.Forms.DataGridViewCellStyle(); this.uiTitel1 = new MaiMuControl.UIKits.MaiMuMenu.UITitel(); this.toolStrip1 = new System.Windows.Forms.ToolStrip(); this.tsbtnSave = new System.Windows.Forms.ToolStripButton(); @@ -405,46 +405,46 @@ // this.dgvBatchList.AllowUserToAddRows = false; this.dgvBatchList.AllowUserToDeleteRows = false; - dataGridViewCellStyle5.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle5.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle5.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle5.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle5.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle5.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle5.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dgvBatchList.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle5; + dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgvBatchList.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1; this.dgvBatchList.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; this.dgvBatchList.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { this.colBatchId, this.colTargetCount, this.colCompleteCount, this.colCreateTime}); - dataGridViewCellStyle6.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle6.BackColor = System.Drawing.SystemColors.Window; - dataGridViewCellStyle6.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle6.ForeColor = System.Drawing.SystemColors.ControlLightLight; - dataGridViewCellStyle6.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle6.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle6.WrapMode = System.Windows.Forms.DataGridViewTriState.False; - this.dgvBatchList.DefaultCellStyle = dataGridViewCellStyle6; + dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window; + dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlLightLight; + dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False; + this.dgvBatchList.DefaultCellStyle = dataGridViewCellStyle2; this.dgvBatchList.Dock = System.Windows.Forms.DockStyle.Fill; this.dgvBatchList.Location = new System.Drawing.Point(2, 16); this.dgvBatchList.Margin = new System.Windows.Forms.Padding(2); this.dgvBatchList.MultiSelect = false; this.dgvBatchList.Name = "dgvBatchList"; this.dgvBatchList.ReadOnly = true; - dataGridViewCellStyle7.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; - dataGridViewCellStyle7.BackColor = System.Drawing.SystemColors.Control; - dataGridViewCellStyle7.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - dataGridViewCellStyle7.ForeColor = System.Drawing.SystemColors.WindowText; - dataGridViewCellStyle7.SelectionBackColor = System.Drawing.SystemColors.Highlight; - dataGridViewCellStyle7.SelectionForeColor = System.Drawing.SystemColors.HighlightText; - dataGridViewCellStyle7.WrapMode = System.Windows.Forms.DataGridViewTriState.True; - this.dgvBatchList.RowHeadersDefaultCellStyle = dataGridViewCellStyle7; + dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft; + dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control; + dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText; + dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight; + dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText; + dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True; + this.dgvBatchList.RowHeadersDefaultCellStyle = dataGridViewCellStyle3; this.dgvBatchList.RowHeadersVisible = false; this.dgvBatchList.RowHeadersWidth = 62; - dataGridViewCellStyle8.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.dgvBatchList.RowsDefaultCellStyle = dataGridViewCellStyle8; + dataGridViewCellStyle4.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.dgvBatchList.RowsDefaultCellStyle = dataGridViewCellStyle4; this.dgvBatchList.RowTemplate.Height = 30; this.dgvBatchList.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect; this.dgvBatchList.Size = new System.Drawing.Size(532, 262); @@ -1259,6 +1259,7 @@ // // flpQualifiedPannel // + this.flpQualifiedPannel.AutoScroll = true; this.flpQualifiedPannel.Dock = System.Windows.Forms.DockStyle.Fill; this.flpQualifiedPannel.Location = new System.Drawing.Point(0, 0); this.flpQualifiedPannel.Margin = new System.Windows.Forms.Padding(2);