Commit 183115cd LN

路径修改

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