Commit 0b7e7fc4 LN

界面调整

1 个父辈 b63041d8
......@@ -120,6 +120,7 @@ namespace AOI
}
return false;
}).ToList();
blobList = resultBlobs;
return resultBlobs.Count;
}
}
......
......@@ -95,7 +95,7 @@ namespace AOI
//double same = Cv2.MatchShapes(grayMarkMat, graySearchMat, ShapeMatchModes.I1);
//Console.WriteLine("===============" + same);
Mat result = new Mat(searchMat.Cols - markMat.Cols + 1, searchMat.Rows - markMat.Cols + 1, MatType.CV_32FC1);
Mat result = new Mat(searchMat.Cols - markMat.Cols + 1, searchMat.Rows - markMat.Rows + 1, MatType.CV_32FC1);
//进行匹配(1母图,2模版子图,3返回的result,4匹配模式_这里的算法比opencv少,具体可以看opencv的相关资料说明)
Cv2.MatchTemplate(searchMat, markMat, result, TemplateMatchModes.CCoeffNormed);
......
......@@ -58,24 +58,30 @@ namespace AOI
//搜索区域
Image searchImage = GetRoiImage(imageToCheck, RoiPath, needCut);
cutImg = searchImage;
//searchImage = imageToCheck;
if (templateImage != null && searchImage != null)
try
{
Mat searchMat = ImageUtil.ToMat(new Bitmap(searchImage));
Mat templateMat = ImageUtil.ToMat(new Bitmap(templateImage));
//searchImage = imageToCheck;
if (templateImage != null && searchImage != null)
{
Mat searchMat = ImageUtil.ToMat(new Bitmap(searchImage));
Mat templateMat = ImageUtil.ToMat(new Bitmap(templateImage));
Mat result = new Mat(searchMat.Cols - templateMat.Cols + 1, searchMat.Rows - templateMat.Cols + 1, MatType.CV_32FC1);
Mat result = new Mat(searchMat.Cols - templateMat.Cols + 1, searchMat.Rows - templateMat.Rows + 1, MatType.CV_32FC1);
//进行匹配(1母图,2模版子图,3返回的result,4匹配模式_这里的算法比opencv少,具体可以看opencv的相关资料说明)
Cv2.MatchTemplate(searchMat, templateMat, result, TemplateMatchModes.CCoeffNormed);
//进行匹配(1母图,2模版子图,3返回的result,4匹配模式_这里的算法比opencv少,具体可以看opencv的相关资料说明)
Cv2.MatchTemplate(searchMat, templateMat, result, TemplateMatchModes.CCoeffNormed);
//对结果进行归一化(这里我测试的时候没有发现有什么用,但在opencv的书里有这个操作,应该有什么神秘加成,这里也加上)
//Cv2.Normalize(result, result, 1, 0, NormTypes.MinMax, -1);
/// 通过函数 minMaxLoc 定位最匹配的位置
/// (这个方法在opencv里有5个参数,这里我写的时候发现在有3个重载,看了下可以直接写成拿到起始坐标就不取最大值和最小值了)
/// minLocation和maxLocation根据匹配调用的模式取不同的点
Cv2.MinMaxLoc(result, out double minVal, out double maxVal, out OpenCvSharp.Point minLocation, out OpenCvSharp.Point maxLocation);
return maxVal * 100;
//对结果进行归一化(这里我测试的时候没有发现有什么用,但在opencv的书里有这个操作,应该有什么神秘加成,这里也加上)
//Cv2.Normalize(result, result, 1, 0, NormTypes.MinMax, -1);
/// 通过函数 minMaxLoc 定位最匹配的位置
/// (这个方法在opencv里有5个参数,这里我写的时候发现在有3个重载,看了下可以直接写成拿到起始坐标就不取最大值和最小值了)
/// minLocation和maxLocation根据匹配调用的模式取不同的点
Cv2.MinMaxLoc(result, out double minVal, out double maxVal, out OpenCvSharp.Point minLocation, out OpenCvSharp.Point maxLocation);
return maxVal * 100;
}
}catch(Exception ex)
{
Console.Write(ex.ToString());
}
return 0;
}
......
......@@ -224,6 +224,10 @@ namespace AccAOI
Project.methodMap.Add(methodInfo.MethodName, methodInfo);
ShowAoi(methodInfo);
aoiList.ItemAdd(aoiControl.TitleName);
if (imageBox1.Visible.Equals(false))
{
btnImageChange_Click(null, null);
}
}
private void ShowAoi(AoiMethod method)
{
......@@ -310,6 +314,10 @@ namespace AccAOI
}
}
}
if (imageBox1.Visible.Equals(false))
{
btnImageChange_Click(null, null);
}
}
}
......@@ -332,6 +340,10 @@ namespace AccAOI
ShowAoi(method);
}
}
if (imageBox1.Visible.Equals(false))
{
btnImageChange_Click(null, null);
}
}
}
......
......@@ -60,7 +60,6 @@
this.panResult.Controls.Add(this.btnOpenImage);
this.panResult.Controls.Add(this.btnTest);
this.panResult.Controls.Add(this.lblResult);
this.panResult.Size = new System.Drawing.Size(298, 197);
//
// flatLabel1
//
......@@ -184,7 +183,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(312, 700);
this.ClientSize = new System.Drawing.Size(312, 833);
this.Name = "AioMarkControl";
this.TitleName = "Mark设置";
this.panParam.ResumeLayout(false);
......
......@@ -41,7 +41,18 @@ namespace AccAOI.control
}
return AoiInfo;
}
public override void ShowAoiInfo()
{
if (this.AoiInfo is AoiMarkMethod)
{
AoiMarkMethod method = (AoiMarkMethod)AoiInfo;
trackBarSamePercent.Value = (int)method.SamePercent;
IsShowOk = true;
UpdateImage();
}
}
private void btnTest_Click(object sender, EventArgs e)
{
if (this.AoiInfo is AoiMarkMethod)
......
......@@ -54,7 +54,6 @@
this.panResult.Controls.Add(this.btnOpenImage);
this.panResult.Controls.Add(this.btnTest);
this.panResult.Controls.Add(this.lblResult);
this.panResult.Size = new System.Drawing.Size(298, 197);
//
// lblResult
//
......@@ -145,12 +144,12 @@
this.txtSamePercent.Text = "50";
this.txtSamePercent.TextChanged += new System.EventHandler(this.txtSamePercent_TextChanged);
//
// AioMatchControl
// AioTempMatchControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(312, 700);
this.Name = "AioMatchControl";
this.ClientSize = new System.Drawing.Size(312, 833);
this.Name = "AioTempMatchControl";
this.TitleName = "模板匹配";
this.panParam.ResumeLayout(false);
this.panParam.PerformLayout();
......
......@@ -40,7 +40,18 @@ namespace AccAOI.control
}
return AoiInfo;
}
public override void ShowAoiInfo()
{
if (this.AoiInfo is AoiTemplateMethod)
{
AoiTemplateMethod method = (AoiTemplateMethod)AoiInfo;
trackBarSamePercent.Value = (int)method.SamePercent;
IsShowOk = true;
UpdateImage();
}
}
private void btnTest_Click(object sender, EventArgs e)
{
if (this.AoiInfo is AoiTemplateMethod)
......
......@@ -44,23 +44,26 @@
this.btnUpdate = new Asa.Theme.FlatButton();
this.flatLabel7 = new Asa.Theme.FlatLabel();
this.txtNumResult = new Asa.Theme.FlatText();
this.lblList = new System.Windows.Forms.Label();
this.panResult.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBarThresh)).BeginInit();
this.SuspendLayout();
//
// panParam
//
this.panParam.Location = new System.Drawing.Point(2, 319);
this.panParam.Size = new System.Drawing.Size(302, 146);
this.panParam.Size = new System.Drawing.Size(302, 128);
//
// panResult
//
this.panResult.Location = new System.Drawing.Point(2, 471);
this.panResult.Size = new System.Drawing.Size(302, 216);
this.panResult.Controls.Add(this.lblList);
this.panResult.Location = new System.Drawing.Point(2, 450);
this.panResult.Size = new System.Drawing.Size(302, 370);
//
// flatLabel1
//
this.flatLabel1.Inside = false;
this.flatLabel1.Location = new System.Drawing.Point(14, 358);
this.flatLabel1.Location = new System.Drawing.Point(14, 350);
this.flatLabel1.Name = "flatLabel1";
this.flatLabel1.Size = new System.Drawing.Size(42, 30);
this.flatLabel1.TabIndex = 8;
......@@ -70,7 +73,7 @@
// trackBarThresh
//
this.trackBarThresh.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.trackBarThresh.Location = new System.Drawing.Point(63, 364);
this.trackBarThresh.Location = new System.Drawing.Point(63, 356);
this.trackBarThresh.Maximum = 255;
this.trackBarThresh.Minimum = -1;
this.trackBarThresh.Name = "trackBarThresh";
......@@ -83,7 +86,7 @@
// lblthresh
//
this.lblthresh.Inside = false;
this.lblthresh.Location = new System.Drawing.Point(265, 358);
this.lblthresh.Location = new System.Drawing.Point(265, 350);
this.lblthresh.Name = "lblthresh";
this.lblthresh.Size = new System.Drawing.Size(30, 30);
this.lblthresh.TabIndex = 10;
......@@ -92,7 +95,7 @@
// flatLabel3
//
this.flatLabel3.Inside = false;
this.flatLabel3.Location = new System.Drawing.Point(14, 508);
this.flatLabel3.Location = new System.Drawing.Point(14, 484);
this.flatLabel3.Name = "flatLabel3";
this.flatLabel3.Size = new System.Drawing.Size(75, 30);
this.flatLabel3.TabIndex = 13;
......@@ -101,7 +104,7 @@
// chkwhiteOnBlack
//
this.chkwhiteOnBlack.Inside = false;
this.chkwhiteOnBlack.Location = new System.Drawing.Point(125, 419);
this.chkwhiteOnBlack.Location = new System.Drawing.Point(125, 405);
this.chkwhiteOnBlack.Name = "chkwhiteOnBlack";
this.chkwhiteOnBlack.Size = new System.Drawing.Size(62, 30);
this.chkwhiteOnBlack.TabIndex = 15;
......@@ -110,7 +113,7 @@
// flatLabel2
//
this.flatLabel2.Inside = false;
this.flatLabel2.Location = new System.Drawing.Point(12, 419);
this.flatLabel2.Location = new System.Drawing.Point(12, 405);
this.flatLabel2.Name = "flatLabel2";
this.flatLabel2.Size = new System.Drawing.Size(75, 30);
this.flatLabel2.TabIndex = 16;
......@@ -121,7 +124,7 @@
//
this.txtminArea.Font = new System.Drawing.Font("宋体", 9F);
this.txtminArea.Inside = false;
this.txtminArea.Location = new System.Drawing.Point(98, 508);
this.txtminArea.Location = new System.Drawing.Point(98, 484);
this.txtminArea.Name = "txtminArea";
this.txtminArea.Padding = new System.Windows.Forms.Padding(3);
this.txtminArea.Size = new System.Drawing.Size(74, 30);
......@@ -132,7 +135,7 @@
//
this.txtmaxArea.Font = new System.Drawing.Font("宋体", 9F);
this.txtmaxArea.Inside = false;
this.txtmaxArea.Location = new System.Drawing.Point(205, 508);
this.txtmaxArea.Location = new System.Drawing.Point(205, 484);
this.txtmaxArea.Name = "txtmaxArea";
this.txtmaxArea.Padding = new System.Windows.Forms.Padding(3);
this.txtmaxArea.Size = new System.Drawing.Size(74, 30);
......@@ -142,7 +145,7 @@
// flatLabel5
//
this.flatLabel5.Inside = false;
this.flatLabel5.Location = new System.Drawing.Point(176, 514);
this.flatLabel5.Location = new System.Drawing.Point(176, 490);
this.flatLabel5.Name = "flatLabel5";
this.flatLabel5.Size = new System.Drawing.Size(24, 25);
this.flatLabel5.TabIndex = 19;
......@@ -151,7 +154,7 @@
// flatLabel4
//
this.flatLabel4.Inside = false;
this.flatLabel4.Location = new System.Drawing.Point(176, 557);
this.flatLabel4.Location = new System.Drawing.Point(176, 526);
this.flatLabel4.Name = "flatLabel4";
this.flatLabel4.Size = new System.Drawing.Size(24, 39);
this.flatLabel4.TabIndex = 23;
......@@ -161,7 +164,7 @@
//
this.txtmaxNum.Font = new System.Drawing.Font("宋体", 9F);
this.txtmaxNum.Inside = false;
this.txtmaxNum.Location = new System.Drawing.Point(205, 557);
this.txtmaxNum.Location = new System.Drawing.Point(205, 526);
this.txtmaxNum.Name = "txtmaxNum";
this.txtmaxNum.Padding = new System.Windows.Forms.Padding(3);
this.txtmaxNum.Size = new System.Drawing.Size(74, 30);
......@@ -172,7 +175,7 @@
//
this.txtminNum.Font = new System.Drawing.Font("宋体", 9F);
this.txtminNum.Inside = false;
this.txtminNum.Location = new System.Drawing.Point(98, 557);
this.txtminNum.Location = new System.Drawing.Point(98, 526);
this.txtminNum.Name = "txtminNum";
this.txtminNum.Padding = new System.Windows.Forms.Padding(3);
this.txtminNum.Size = new System.Drawing.Size(74, 30);
......@@ -182,7 +185,7 @@
// flatLabel6
//
this.flatLabel6.Inside = false;
this.flatLabel6.Location = new System.Drawing.Point(14, 557);
this.flatLabel6.Location = new System.Drawing.Point(14, 526);
this.flatLabel6.Name = "flatLabel6";
this.flatLabel6.Size = new System.Drawing.Size(75, 30);
this.flatLabel6.TabIndex = 20;
......@@ -192,7 +195,7 @@
//
this.btnUpdate.ImageSize = new System.Drawing.Size(0, 0);
this.btnUpdate.Inside = false;
this.btnUpdate.Location = new System.Drawing.Point(189, 613);
this.btnUpdate.Location = new System.Drawing.Point(189, 571);
this.btnUpdate.Name = "btnUpdate";
this.btnUpdate.Size = new System.Drawing.Size(90, 30);
this.btnUpdate.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
......@@ -203,7 +206,7 @@
// flatLabel7
//
this.flatLabel7.Inside = false;
this.flatLabel7.Location = new System.Drawing.Point(10, 613);
this.flatLabel7.Location = new System.Drawing.Point(10, 571);
this.flatLabel7.Name = "flatLabel7";
this.flatLabel7.Size = new System.Drawing.Size(83, 30);
this.flatLabel7.TabIndex = 43;
......@@ -214,17 +217,30 @@
this.txtNumResult.Enabled = false;
this.txtNumResult.Font = new System.Drawing.Font("宋体", 9F);
this.txtNumResult.Inside = false;
this.txtNumResult.Location = new System.Drawing.Point(98, 613);
this.txtNumResult.Location = new System.Drawing.Point(98, 571);
this.txtNumResult.Name = "txtNumResult";
this.txtNumResult.Padding = new System.Windows.Forms.Padding(3);
this.txtNumResult.Size = new System.Drawing.Size(74, 30);
this.txtNumResult.TabIndex = 42;
//
// lblList
//
this.lblList.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.lblList.BackColor = System.Drawing.Color.Transparent;
this.lblList.ForeColor = System.Drawing.Color.White;
this.lblList.Location = new System.Drawing.Point(14, 168);
this.lblList.Name = "lblList";
this.lblList.Size = new System.Drawing.Size(269, 191);
this.lblList.TabIndex = 0;
this.lblList.Text = "面积列表:";
//
// AoiBlobControl
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(312, 699);
this.ClientSize = new System.Drawing.Size(312, 833);
this.Controls.Add(this.flatLabel7);
this.Controls.Add(this.txtNumResult);
this.Controls.Add(this.btnUpdate);
......@@ -261,6 +277,7 @@
this.Controls.SetChildIndex(this.btnUpdate, 0);
this.Controls.SetChildIndex(this.txtNumResult, 0);
this.Controls.SetChildIndex(this.flatLabel7, 0);
this.panResult.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.trackBarThresh)).EndInit();
this.ResumeLayout(false);
this.PerformLayout();
......@@ -285,5 +302,6 @@
private Asa.Theme.FlatButton btnUpdate;
private Asa.Theme.FlatLabel flatLabel7;
private Asa.Theme.FlatText txtNumResult;
private System.Windows.Forms.Label lblList;
}
}
......@@ -89,6 +89,7 @@ namespace AccAOI.control
{
try
{
lblList.Text = "面积列表:";
Image BaseImage = GetImg();
if (BaseImage == null || currPath == null)
{
......@@ -112,6 +113,17 @@ namespace AccAOI.control
this.CutImage = cutImage;
}
}
list = (from m in list orderby m.Area descending select m).ToList< CvBlob > ();
string text= "编号".PadLeft(5,' ') + "面积↓".PadLeft(8, ' ') + "X坐标".PadLeft(10, ' ') + "Y坐标".PadLeft(10, ' ');
int index = 1;
foreach (CvBlob cv in list)
{
text += "\r\n" + index.ToString().PadLeft(5, ' ')+ cv.Area.ToString().PadLeft(12, ' ')+ Math.Round(cv.Centroid.X, 2).ToString().PadLeft(12, ' ') +
Math.Round(cv.Centroid.Y, 2).ToString().PadLeft(12, ' ');
index++;
}
lblList.Text = text;
GC.Collect();
}
catch (Exception ex)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!