Commit cb72a705 LN

1

1 个父辈 e5aaae14
......@@ -29,8 +29,9 @@ namespace AOI
/// </summary>
public Dictionary<string, AoiMethod> methodMap = new Dictionary<string, AoiMethod>();
public List<ResultBean> CheckAll(Image image, out Image resultImg)
public List<ResultBean> CheckAll(Image scr, out Image resultImg)
{
Image image = (Image)scr.Clone();
//如果设置了校准方法,先校准图片
var markMethodMap = methodMap.Where(kv=>kv.Value is AoiMarkMethod);
foreach (var item in markMethodMap)
......@@ -62,10 +63,10 @@ namespace AOI
{
foreach(ResultBean resultBean in resultBeans)
{
Pen pen = new Pen(Color.Green);
Pen pen = new Pen(Color.YellowGreen,5);
if (!resultBean.result)
{
pen = new Pen(Color.Red);
pen = new Pen(Color.Red,5);
}
g.DrawPath(pen,resultBean.roiPath);
}
......
......@@ -80,7 +80,12 @@ namespace AOI
{
bool needCut = true;
cutImg = GetRoiImage(srcImg, needCut);
if (cutImg == null)
{
dstCutImg = null;
blobList = new List<CvBlob>();
return 0;
}
Mat srcMat = ImageUtil.ToMat(cutImg);
Mat threshMat = new Mat();
Cv2.CvtColor(srcMat, threshMat, ColorConversionCodes.RGB2GRAY);
......
......@@ -41,6 +41,7 @@ namespace AccAOI
this.comType = new Asa.Theme.FlatCombo();
this.panAoi = new System.Windows.Forms.Panel();
this.imageBox1 = new Cyotek.Windows.Forms.ImageBox();
this.btnExcute = new Asa.Theme.FlatButton();
this.SuspendLayout();
//
// aoiList
......@@ -50,9 +51,9 @@ namespace AccAOI
this.aoiList.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.aoiList.Index = -1;
this.aoiList.Inside = false;
this.aoiList.Location = new System.Drawing.Point(9, 202);
this.aoiList.Location = new System.Drawing.Point(9, 223);
this.aoiList.Name = "aoiList";
this.aoiList.Size = new System.Drawing.Size(287, 430);
this.aoiList.Size = new System.Drawing.Size(287, 409);
this.aoiList.TabIndex = 2;
this.aoiList.IndexChanged += new System.EventHandler(this.aoiList_IndexChanged);
//
......@@ -167,10 +168,23 @@ namespace AccAOI
this.imageBox1.TabIndex = 4;
this.imageBox1.SelectionRegionChanged += new System.EventHandler(this.imageBox1_SelectionRegionChanged);
//
// btnExcute
//
this.btnExcute.ImageSize = new System.Drawing.Size(0, 0);
this.btnExcute.Inside = false;
this.btnExcute.Location = new System.Drawing.Point(153, 187);
this.btnExcute.Name = "btnExcute";
this.btnExcute.Size = new System.Drawing.Size(109, 30);
this.btnExcute.StateColor = System.Drawing.Color.FromArgb(((int)(((byte)(30)))), ((int)(((byte)(30)))), ((int)(((byte)(30)))));
this.btnExcute.TabIndex = 16;
this.btnExcute.Text = "执行";
this.btnExcute.Click += new System.EventHandler(this.btnExcute_Click);
//
// FrmAoiSetting
//
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
this.ClientSize = new System.Drawing.Size(1271, 641);
this.Controls.Add(this.btnExcute);
this.Controls.Add(this.panAoi);
this.Controls.Add(this.comType);
this.Controls.Add(this.btnGetCameraImg);
......@@ -204,5 +218,6 @@ namespace AccAOI
private Asa.Theme.FlatButton btnGetCameraImg;
private Asa.Theme.FlatCombo comType;
private System.Windows.Forms.Panel panAoi;
private Asa.Theme.FlatButton btnExcute;
}
}
\ No newline at end of file
......@@ -17,6 +17,7 @@ namespace AccAOI
private control.ABaseControl aoiControl = null;
public static Image Img = null;
private AoiProject Project = null;
private bool CanSel = true;
public FrmAoiSetting()
{
InitializeComponent();
......@@ -159,6 +160,11 @@ namespace AccAOI
}
private void ShowAoi(AoiMethod method)
{
CanSel = false;
imageBox1.SelectNone();
imageBox1.Image = Img;
CanSel = true;
if (aoiControl == null)
{
if(method is AoiBlobMethod)
......@@ -189,8 +195,8 @@ namespace AccAOI
{
currPath = method.RoiPath;
imageBox1.SelectionRegion = method.RoiPath;
Image threshImage = CutImage(imageBox1.Image, currPath);
cutImage = threshImage;
//Image threshImage = CutImage(imageBox1.Image, currPath);
//cutImage = threshImage;
aoiControl.SetCurrPath(currPath,false);
}
......@@ -269,6 +275,10 @@ namespace AccAOI
{
try
{
if (!CanSel)
{
return;
}
if (imageBox1.Image == null || Img == null || aoiControl == null)
{
return;
......@@ -287,7 +297,7 @@ namespace AccAOI
// currPath.AddEllipse(region);
//}
currPath = imageBox1.SelectionRegion;
Image threshImage = CutImage(imageBox1.Image, currPath);
Image threshImage = CutImage(Img , currPath);
cutImage = threshImage;
aoiControl.SetCurrPath( currPath);
......@@ -327,5 +337,27 @@ namespace AccAOI
return null;
}
private void btnExcute_Click(object sender, EventArgs e)
{
SaveCurrAoi();
CanSel = false;
if (Img == null)
{
return;
}
if (this.Project == null)
{
return;
}
Image outImage = null;
List<ResultBean> result = Project.CheckAll(Img, out outImage);
if (outImage != null)
{
this.imageBox1.SelectNone();
this.imageBox1.Image = outImage;
}
CanSel = true;
}
}
}
......@@ -89,7 +89,7 @@ namespace AccAOI.control
{
// this.BImageBox.CleearArea();
this.aoiImage.Image = null;
BImageBox.SelectNone();
}
private void btnImgType_Click(object sender, EventArgs e)
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!