Commit 183115cd LN

路径修改

1 个父辈 f6c02730
......@@ -54,35 +54,50 @@ namespace AOI
}
if (!resultBean.result)
{
string p = getSaveImagePath(AoiProject.FilePath, this.RoiPath);
string aoipath = AoiProject.FilePath;
string xypath= Path.GetFileNameWithoutExtension(aoipath);
if (Directory.Exists(xypath))
PointF[] points = this.RoiPath.PathData.Points;
//if (Directory.Exists(xypath))
//{
// string pst = null;
// PointF[] points = this.RoiPath.PathData.Points;
// if (points.Length >= 4)
// {
// for (int i = 0; i < points.Length; i++)
// {
// pst += (int)points[i].X + "-" + (int)points[i].Y + "_";
// }
// string path = Path.Combine(xypath,pst);
if (Directory.Exists(p))
{
string pst = null;
PointF[] points = this.RoiPath.PathData.Points;
if (points.Length >= 4)
string[] files = Directory.GetFiles(p);
foreach (string file in files)
{
for (int i = 0; i < points.Length; i++)
{
pst += (int)points[i].X + "-" + (int)points[i].Y + "_";
}
string path = Path.Combine(xypath,pst);
if (Directory.Exists(xypath))
try
{
string[] files = Directory.GetFiles(xypath);
foreach (string file in files)
if (file.EndsWith(".jpg") || file.EndsWith(".png") || file.EndsWith(".bmp") || file.EndsWith(".gif"))
{
if (file.EndsWith(".jpg") || file.EndsWith(".png") || file.EndsWith(".bmp") || file.EndsWith(".gif"))
Bitmap bmp = new Bitmap(file);
RectangleF rects = new RectangleF(points[0], new System.Drawing.Size(bmp.Width, bmp.Height));
(percent, angle) = GetTemplateMatchPercent(bmp, imageToCheck, rects, out cutImg);
if (percent >= SamePercent && angle <= AnglePercent)
{
Bitmap bmp = new Bitmap(file);
RectangleF rects = new RectangleF(points[0],new System.Drawing.Size(bmp.Width,bmp.Height));
(percent, angle) = GetTemplateMatchPercent(bmp, imageToCheck, rects, out cutImg);
result = true;
break;
}
}
}
catch(Exception ex)
{
Console.WriteLine( MethodName+" 补充检测["+ file + "]出错:" + ex.ToString());
}
}
}
}
//}
//}
}
resultBean.currentRoiImage = cutImg;
resultBean.result = result;
......@@ -90,7 +105,19 @@ namespace AOI
resultBean.checkData = angle;
return resultBean;
}
private string getSaveImagePath(string aoiFileName, GraphicsPath gPath)
{
string path = Path.GetDirectoryName(aoiFileName);
string fileName = Path.GetFileNameWithoutExtension(aoiFileName);
System.Drawing.PointF[] pts = gPath.PathPoints;
string pPath = "";
for (int i = 0; i < pts.Length; i++)
{
pPath += (int)pts[i].X + "-" + (int)pts[i].Y + "_";
}
return Path.Combine(path, fileName + @"\" + pPath + @"\");
}
/// <summary>
/// 获取模板相似度
/// </summary>
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!