Commit afe4a2a0 LN

界面调整

1 个父辈 bb6a7e9a
......@@ -10,9 +10,17 @@ namespace AOI
{
public class ResultBean
{
public ResultBean(string name)
/// <summary>
///
/// </summary>
/// <param name="name">名称</param>
/// <param name="type">类型,1=mark点。2=斑点分析,3=颜色抽取,4=模板匹配</param>
public ResultBean(string name,int type,double targetMinV,double targetMaxV)
{
this.MethodName = name;
this.MethodType = type;
this.targetMinValue = targetMinV;
this.targetMaxValue = targetMaxV;
}
/// <summary>
/// 名称
......@@ -36,10 +44,25 @@ namespace AOI
public Image currentRoiImage;
public GraphicsPath roiPath;
public double targetMinValue;
public double targetMaxValue;
/// <summary>
/// 当为mark点和模板匹配时表示相似度。
/// 为颜色抽取表示像素占比
/// </summary>
public double percentValue;
/// <summary>
/// 类型,1=mark点。2=斑点分析,3=颜色抽取,4=模板匹配
/// </summary>
public int MethodType = 0;
/// <summary>
/// 实际相似度
/// 颜色抽取时表示List<CvBlob> blobList
/// </summary>
public double samePercent;
public object checkData;
}
}
......@@ -43,7 +43,7 @@ namespace AOI
public override ResultBean Check(Image standardImage, Image imageToCheck)
{
ResultBean resultBean = new ResultBean(MethodName);
ResultBean resultBean = new ResultBean(MethodName,2,minNum,maxNum);
bool needCut = true;
Image standardRoiImg = GetRoiImage(standardImage, needCut);
resultBean.standardRoiImage = standardRoiImg;
......@@ -64,6 +64,7 @@ namespace AOI
result = true;
}
}
resultBean.checkData =(object) blobList;
resultBean.result = result;
return resultBean;
}
......
......@@ -69,7 +69,7 @@ namespace AOI
/// <returns></returns>
public override ResultBean Check(Image standardImage, Image imageToCheck)
{
ResultBean resultBean = new ResultBean(MethodName);
ResultBean resultBean = new ResultBean(MethodName,1,SamePercent,SamePercent);
resultBean.standardRoiImage = standardImage;
double sameValue = 0;
Image resultImage = FixImage(standardImage, imageToCheck,out sameValue);
......@@ -77,7 +77,7 @@ namespace AOI
{
resultBean.result = true;
resultBean.currentRoiImage = resultImage;
resultBean.samePercent = sameValue;
resultBean.percentValue = sameValue;
}
return resultBean;
}
......
......@@ -23,7 +23,8 @@ namespace AOI
public override ResultBean Check(Image standardImage, Image imageToCheck)
{
ResultBean resultBean = new ResultBean(MethodName);
ResultBean resultBean = new ResultBean(MethodName,4,SamePercent,SamePercent);
bool needCut = true;
Image standardRoiImg = GetRoiImage(standardImage, needCut);
resultBean.standardRoiImage = standardRoiImg;
......@@ -40,7 +41,7 @@ namespace AOI
}
resultBean.currentRoiImage = cutImg;
resultBean.result = result;
resultBean.samePercent =Math.Round( percent,3);
resultBean.percentValue =Math.Round( percent,3);
return resultBean;
}
......
......@@ -40,7 +40,7 @@ namespace AOI
public override ResultBean Check(Image standardImage, Image imageToCheck)
{
ResultBean resultBean = new ResultBean(MethodName);
ResultBean resultBean = new ResultBean(MethodName,3, minRate, maxRate);
bool needCut = true;
Image standardRoiImg = GetRoiImage(standardImage, needCut);
resultBean.standardRoiImage = standardRoiImg;
......@@ -54,6 +54,7 @@ namespace AOI
{
result = true;
}
resultBean.percentValue =Math.Round( rate,3);
resultBean.result = result;
return resultBean;
}
......
......@@ -38,7 +38,7 @@ namespace AccAOI
{
LoadData();
}
ControlType.Mark = AOIResourceCulture.GetValue("Mark点设置");
ControlType.Mark = AOIResourceCulture.GetValue("图像校准点");
ControlType.AOIBlob = AOIResourceCulture.GetValue("斑点分析");
ControlType.AOIRGB = AOIResourceCulture.GetValue("颜色抽取");
ControlType.Match = AOIResourceCulture.GetValue("模板匹配");
......
......@@ -59,9 +59,9 @@ namespace AccAOI
public class ControlType
{
/// <summary>
/// Mark点设置
/// 图像校准点
/// </summary>
public static string Mark =AOIResourceCulture.GetValue( "Mark点设置");
public static string Mark =AOIResourceCulture.GetValue( "图像校准点");
/// <summary>
/// 斑点分析
/// </summary>
......
using AccAOI.camera;
using AOI;
using OpenCvSharp.Blob;
using System;
using System.Collections.Generic;
using System.ComponentModel;
......@@ -490,17 +491,66 @@ namespace AccAOI
List<ResultBean> result = Project.CheckAll(TestImage, out outImage);
if (outImage != null)
{
if (!this.testImageBox1.Visible)
if (!this.panTest.Visible)
{
btnImageChange_Click(null, null);
}
this.testImageBox1.SelectNone();
this.testImageBox1.Image = outImage;
}
if (result == null)
{
lblTestResult.Text = "Result: null";
}
else
{
lblTestResult.Text = GetResultsStr(result);
}
GC.Collect();
CanSel = true;
}
public static string GetResultsStr(List<ResultBean> result)
{
string msg = "";
bool isOk = true;
foreach (ResultBean bean in result)
{
if (bean.MethodType.Equals(2))
{
msg += (bean.result ? "✔ " : "✘ ") + bean.MethodName + "\r\n";
if (bean.checkData != null)
{
List<CvBlob> list = (List<CvBlob>)bean.checkData;
list = (from m in list orderby m.Area descending select m).ToList<CvBlob>();
string text = " " + AOIResourceCulture.GetValue("编号").PadLeft(5, ' ') + AOIResourceCulture.GetValue("面积↓").PadLeft(8, ' ') + AOIResourceCulture.GetValue("X坐标").PadLeft(10, ' ') +
AOIResourceCulture.GetValue("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++;
}
msg += text + "\r\n";
}
}
else if (bean.MethodType.Equals(1) || bean.MethodType.Equals(4))
{
msg += (bean.result ? "✔ " : "✘ ") + bean.MethodName + " ("+bean.targetMinValue+"/" + bean.percentValue + "%)" + "\r\n";
}
else
{
msg += (bean.result ? "✔ " : "✘ ") + bean.MethodName + "\r\n";
msg += " " + AOIResourceCulture.GetValue("实际值")+":"+bean.percentValue+" " + AOIResourceCulture.GetValue("目标范围")+":[" +bean.targetMinValue+" , " + bean.targetMaxValue + "] \r\n";
}
if (!bean.result)
{
isOk = false;
}
}
return "Result: " + (isOk ? "OK" : "NG") + "\r\n" + msg;
}
private void btnDel_Click(object sender, EventArgs e)
{
if (BaseImg == null)
......@@ -527,9 +577,9 @@ namespace AccAOI
private void btnImageChange_Click(object sender, EventArgs e)
{
if (testImageBox1.Visible)
if (panTest.Visible)
{
testImageBox1.Visible = false;
panTest.Visible = false;
imageBox1.Visible = true;
btnImageChange.Text = AOIResourceCulture.GetValue("显示测试图片");
lblCurrImage.Text = AOIResourceCulture.GetValue("基准图:");
......@@ -537,11 +587,11 @@ namespace AccAOI
}
else
{
testImageBox1.Visible = true;
panTest.Visible = true;
imageBox1.Visible = false;
btnImageChange.Text = AOIResourceCulture.GetValue("显示基准图片");
lblCurrImage.Text = AOIResourceCulture.GetValue("测试/效果图:");
lblCurrImage.ForeColor = Color.Orange;
lblCurrImage.ForeColor = Color.DodgerBlue;
}
}
......@@ -566,7 +616,7 @@ namespace AccAOI
TestImage = new Bitmap(file);
file.Dispose();
testImageBox1.Image = TestImage;
if (testImageBox1.Visible.Equals(false))
if (panTest.Visible.Equals(false))
{
btnImageChange_Click(null, null);
}
......@@ -574,9 +624,9 @@ namespace AccAOI
private void FrmAoiSetting_Shown(object sender, EventArgs e)
{
testImageBox1.Size = imageBox1.Size;
testImageBox1.Location = imageBox1.Location;
testImageBox1.Visible = false;
panTest.Size = imageBox1.Size;
panTest.Location = imageBox1.Location;
panTest.Visible = false;
}
......@@ -615,7 +665,7 @@ namespace AccAOI
//读取图片内容
testImageBox1.Image = TestImage;
if (testImageBox1.Visible.Equals(false))
if (panTest.Visible.Equals(false))
{
btnImageChange_Click(null, null);
}
......@@ -676,7 +726,7 @@ namespace AccAOI
try
{
Image needSaveImage = null;
if (testImageBox1.Visible)
if (panTest.Visible)
{
needSaveImage = testImageBox1.Image;
}
......
......@@ -24,6 +24,7 @@ namespace AccAOI
private void FrmMethodName_Load(object sender, EventArgs e)
{
txtName.Text = MethodName;
}
......@@ -36,7 +37,14 @@ namespace AccAOI
private void btnOk_Click(object sender, EventArgs e)
{
string newName = txtName.Text;
string newName = txtName.Text.Trim();
if (newName.Length > 30||newName.Length<2)
{
MyMessage.Show(" 请输入正确名称(长度 2~30)", newName);
txtName.Focus();
return;
}
if (AllNameList.Contains(newName))
{
MyMessage.Show("名称【{0}】已存在,请重新输入", newName);
......
......@@ -72,7 +72,7 @@ AioTempMatchControl_btnSetArea_Text=ellipse
AoiBlobControl_lblList_Text=Area of a list:
AoiBlobControl_btnImgType_Text=original
AoiBlobControl_btnSetArea_Text=ellipse
Mark点设置=Mark Point Set
图像校准点=Image calibration point
斑点分析=Spot analysis
颜色抽取=Color extraction
模板匹配=Template matching
......@@ -109,4 +109,7 @@ FrmMethodName_btnCancel_Text=Cancel
参数设置=parameter setting
结果判断=result judgment
中文=Chinese
英文=English
\ No newline at end of file
英文=English
请输入正确名称(长度 2~30)=Please enter the correct name (length 2~30)
目标范围=Target
实际值= actual
\ No newline at end of file
......@@ -17,7 +17,7 @@ AioMarkControl_panResult_Text=结果判断
AioMarkControl_panParam_Text=参数设置
AioMarkControl_panAreaSet_Text=区域设置-矩形
AioMarkControl_panAreaImage_Text=区域图片
AioMarkControl_panControl_Text=00_Mark点设置
AioMarkControl_panControl_Text=00_图像校准点
AoiRgbControl_btnUpdate_Text=更新
AoiRgbControl_flatLabel9_Text=像素实时占比:
AoiRgbControl_flatLabel2_Text=MinR:
......@@ -72,7 +72,7 @@ AioTempMatchControl_btnSetArea_Text=椭圆
AoiBlobControl_lblList_Text=面积列表:
AoiBlobControl_btnImgType_Text=原图
AoiBlobControl_btnSetArea_Text=椭圆
Mark点设置=Mark点设置
图像校准点=图像校准点
斑点分析=斑点分析
颜色抽取=颜色抽取
模板匹配=模板匹配
......@@ -109,4 +109,7 @@ FrmMethodName_btnCancel_Text=取消
参数设置=参数设置
结果判断=结果判断
中文=中文
英文=英文
\ No newline at end of file
英文=英文
请输入正确名称(长度 2~30)=请输入正确名称(长度 2~30)
目标范围=目标范围
实际值= 实际值
\ No newline at end of file
......@@ -56,6 +56,7 @@ namespace AccAOI.control
this.btnSetArea.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.btnSetArea.TabIndex = 7;
this.btnSetArea.Text = "椭圆";
this.btnSetArea.Visible = false;
this.btnSetArea.Click += new System.EventHandler(this.btnSetArea_Click);
//
// btnClearArea
......@@ -64,9 +65,9 @@ namespace AccAOI.control
this.btnClearArea.Font = new System.Drawing.Font("宋体", 9F);
this.btnClearArea.ImageSize = new System.Drawing.Size(0, 0);
this.btnClearArea.Inside = false;
this.btnClearArea.Location = new System.Drawing.Point(212, 274);
this.btnClearArea.Location = new System.Drawing.Point(163, 30);
this.btnClearArea.Name = "btnClearArea";
this.btnClearArea.Size = new System.Drawing.Size(83, 30);
this.btnClearArea.Size = new System.Drawing.Size(119, 30);
this.btnClearArea.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.btnClearArea.TabIndex = 6;
this.btnClearArea.Text = "清除";
......@@ -101,6 +102,7 @@ namespace AccAOI.control
//
this.panAreaSet.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.panAreaSet.Controls.Add(this.btnClearArea);
this.panAreaSet.Controls.Add(this.btnImgType);
this.panAreaSet.Controls.Add(this.btnSetArea);
this.panAreaSet.Inside = false;
......@@ -119,7 +121,7 @@ namespace AccAOI.control
this.btnImgType.Inside = false;
this.btnImgType.Location = new System.Drawing.Point(6, 30);
this.btnImgType.Name = "btnImgType";
this.btnImgType.Size = new System.Drawing.Size(115, 30);
this.btnImgType.Size = new System.Drawing.Size(151, 30);
this.btnImgType.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.btnImgType.TabIndex = 8;
this.btnImgType.Text = "原图";
......@@ -166,7 +168,6 @@ namespace AccAOI.control
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
this.ClientSize = new System.Drawing.Size(312, 833);
this.Controls.Add(this.btnClearArea);
this.Controls.Add(this.panResult);
this.Controls.Add(this.panParam);
this.Controls.Add(this.panAreaSet);
......
......@@ -97,7 +97,7 @@
this.lblResult.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.lblResult.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblResult.ForeColor = System.Drawing.Color.Red;
this.lblResult.Location = new System.Drawing.Point(12, 114);
this.lblResult.Location = new System.Drawing.Point(12, 94);
this.lblResult.Name = "lblResult";
this.lblResult.Size = new System.Drawing.Size(276, 24);
this.lblResult.TabIndex = 4;
......@@ -109,7 +109,7 @@
this.btnTest.Font = new System.Drawing.Font("宋体", 9F);
this.btnTest.ImageSize = new System.Drawing.Size(0, 0);
this.btnTest.Inside = false;
this.btnTest.Location = new System.Drawing.Point(92, 56);
this.btnTest.Location = new System.Drawing.Point(92, 40);
this.btnTest.Name = "btnTest";
this.btnTest.Size = new System.Drawing.Size(115, 30);
this.btnTest.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
......@@ -122,7 +122,7 @@
this.lblTime.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.lblTime.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblTime.ForeColor = System.Drawing.Color.Green;
this.lblTime.Location = new System.Drawing.Point(12, 149);
this.lblTime.Location = new System.Drawing.Point(12, 129);
this.lblTime.Name = "lblTime";
this.lblTime.Size = new System.Drawing.Size(276, 24);
this.lblTime.TabIndex = 8;
......
......@@ -72,6 +72,8 @@ namespace AccAOI.control
//}
if (checkImg == null)
{
MyMessage.Show("请选择测试图片");
return;
checkImg = FrmAoiSetting.BaseImg;
}
DateTime time = DateTime.Now;
......
......@@ -59,7 +59,7 @@
this.lblResult.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.lblResult.Font = new System.Drawing.Font("微软雅黑", 15.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblResult.ForeColor = System.Drawing.Color.Red;
this.lblResult.Location = new System.Drawing.Point(8, 123);
this.lblResult.Location = new System.Drawing.Point(8, 88);
this.lblResult.Name = "lblResult";
this.lblResult.Size = new System.Drawing.Size(283, 24);
this.lblResult.TabIndex = 4;
......@@ -71,7 +71,7 @@
this.btnTest.Font = new System.Drawing.Font("宋体", 9F);
this.btnTest.ImageSize = new System.Drawing.Size(0, 0);
this.btnTest.Inside = false;
this.btnTest.Location = new System.Drawing.Point(92, 71);
this.btnTest.Location = new System.Drawing.Point(92, 36);
this.btnTest.Name = "btnTest";
this.btnTest.Size = new System.Drawing.Size(115, 30);
this.btnTest.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
......@@ -84,7 +84,7 @@
this.lblTime.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.lblTime.Font = new System.Drawing.Font("微软雅黑", 10.5F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.lblTime.ForeColor = System.Drawing.Color.Green;
this.lblTime.Location = new System.Drawing.Point(8, 158);
this.lblTime.Location = new System.Drawing.Point(8, 123);
this.lblTime.Name = "lblTime";
this.lblTime.Size = new System.Drawing.Size(283, 24);
this.lblTime.TabIndex = 8;
......
......@@ -69,7 +69,9 @@ namespace AccAOI.control
// file.Dispose();
//}
if (checkImg == null)
{
{
MyMessage.Show("请选择测试图片");
return;
checkImg = FrmAoiSetting.BaseImg;
}
DateTime time = DateTime.Now;
......@@ -90,7 +92,7 @@ namespace AccAOI.control
{
lblResult.ForeColor = Color.Red;
}
lblResult.Text += " (" + result.samePercent + "%)";
lblResult.Text += " (" + result.percentValue + "%)";
if (result.currentRoiImage != null)
{
SetCurrImageType(2);
......
此文件类型无法预览
此文件类型无法预览
此文件类型无法预览
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!