V1.0.2 晶宝更新

This commit is contained in:
CPL 2024-07-18 14:34:13 +08:00
parent 161dd29404
commit e2ccac8f71
7 changed files with 138 additions and 73 deletions

View File

@ -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;

View File

@ -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)

View File

@ -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

View File

@ -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;
/// <summary>
/// 相机控制
@ -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<double>("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<string>("ThresholdsClass");
if (processParam.Value<string>("ThresholdsClass").Split(',').Length < 30)
{
for (int i = 0; i < 30 - processParam.Value<string>("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<float>("Thresholds"),
thresholdsClass = processParam.Value<string>("ThresholdsClass"),
thresholdsClass = ThresholdsClassStr,
recAreaThreshold = getProductAreaThreshol(model), //qxName,面积; qxName,面积; qxName,面积;
finishEvent = (res) =>
{
@ -3040,7 +3085,7 @@ namespace MaiMuAOI.SysCtrl
return 0;
}
}
#endregion
#endregion
#region
#region

View File

@ -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);