Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
AccAOI
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 183115cd
由
LN
编写于
2023-12-25 16:26:45 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
路径修改
1 个父辈
f6c02730
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
44 行增加
和
17 行删除
AOI/eyemlib/AoiEyemTemplateMethod.cs
AOI/eyemlib/AoiEyemTemplateMethod.cs
查看文件 @
183115c
...
...
@@ -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!
Cancel
请
注册
或
登录
后发表评论