Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
AccAOI
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit bb6a7e9a
由
LN
编写于
2019-08-21 10:50:11 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
模板匹配和Mark点增加相似度显示
1 个父辈
c5138f5c
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
84 行增加
和
130 行删除
AOI/ResultBean.cs
AOI/mark/AoiMarkMethod.cs
AOI/match/AoiTemplateMethod.cs
AccAOI/control/AioMarkControl.Designer.cs
AccAOI/control/AioMarkControl.cs
AccAOI/control/AioTempMatchControl.Designer.cs
AccAOI/control/AioTempMatchControl.cs
AOI/ResultBean.cs
查看文件 @
bb6a7e9
...
...
@@ -36,6 +36,10 @@ namespace AOI
public
Image
currentRoiImage
;
public
GraphicsPath
roiPath
;
/// <summary>
/// 实际相似度
/// </summary>
public
double
samePercent
;
}
}
AOI/mark/AoiMarkMethod.cs
查看文件 @
bb6a7e9
...
...
@@ -71,17 +71,20 @@ namespace AOI
{
ResultBean
resultBean
=
new
ResultBean
(
MethodName
);
resultBean
.
standardRoiImage
=
standardImage
;
Image
resultImage
=
FixImage
(
standardImage
,
imageToCheck
);
double
sameValue
=
0
;
Image
resultImage
=
FixImage
(
standardImage
,
imageToCheck
,
out
sameValue
);
if
(
resultImage
!=
null
)
{
resultBean
.
result
=
true
;
resultBean
.
currentRoiImage
=
resultImage
;
resultBean
.
samePercent
=
sameValue
;
}
return
resultBean
;
}
public
Mat
Fix
(
Image
standardImage
,
Image
imageToCheck
)
public
Mat
Fix
(
Image
standardImage
,
Image
imageToCheck
,
out
double
sameValue
)
{
sameValue
=
0
;
bool
needCut
=
true
;
//标准图中的Mart区域
Image
markImage
=
GetRoiImage
(
standardImage
,
RoiPath
,
needCut
);
...
...
@@ -117,7 +120,7 @@ namespace AOI
Cv2
.
Rectangle
(
searchMat
,
maxLocation
,
new
OpenCvSharp
.
Point
(
maxLocation
.
X
+
markMat
.
Cols
,
maxLocation
.
Y
+
markMat
.
Rows
),
Scalar
.
Red
,
2
);
Console
.
WriteLine
(
maxLocation
+
"="
+
maxVal
);
sameValue
=
Math
.
Round
(
maxVal
*
100
,
3
);
if
(
maxVal
*
100
>
SamePercent
)
{
//大于相似度,开始平移图像
...
...
@@ -148,11 +151,11 @@ namespace AOI
}
public
Image
FixImage
(
Image
standardImage
,
Image
imageToCheck
)
public
Image
FixImage
(
Image
standardImage
,
Image
imageToCheck
,
out
double
sameValue
)
{
//Fix(standardImage, imageToCheck);
var
affine
=
Fix
(
standardImage
,
imageToCheck
);
var
affine
=
Fix
(
standardImage
,
imageToCheck
,
out
sameValue
);
if
(
affine
!=
null
)
{
var
matToCheck
=
ImageUtil
.
ToMat
(
imageToCheck
);
...
...
AOI/match/AoiTemplateMethod.cs
查看文件 @
bb6a7e9
...
...
@@ -40,6 +40,7 @@ namespace AOI
}
resultBean
.
currentRoiImage
=
cutImg
;
resultBean
.
result
=
result
;
resultBean
.
samePercent
=
Math
.
Round
(
percent
,
3
);
return
resultBean
;
}
...
...
AccAOI/control/AioMarkControl.Designer.cs
查看文件 @
bb6a7e9
...
...
@@ -33,8 +33,6 @@
this
.
flatLabel2
=
new
Asa
.
Theme
.
FlatLabel
();
this
.
lblResult
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
btnTest
=
new
Asa
.
Theme
.
FlatButton
();
this
.
btnOpenImage
=
new
Asa
.
Theme
.
FlatButton
();
this
.
txtImage
=
new
Asa
.
Theme
.
FlatText
();
this
.
lblTime
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
trackBarSamePercent
=
new
System
.
Windows
.
Forms
.
TrackBar
();
this
.
flatLabel3
=
new
Asa
.
Theme
.
FlatLabel
();
...
...
@@ -56,8 +54,6 @@
// panResult
//
this
.
panResult
.
Controls
.
Add
(
this
.
lblTime
);
this
.
panResult
.
Controls
.
Add
(
this
.
txtImage
);
this
.
panResult
.
Controls
.
Add
(
this
.
btnOpenImage
);
this
.
panResult
.
Controls
.
Add
(
this
.
btnTest
);
this
.
panResult
.
Controls
.
Add
(
this
.
lblResult
);
this
.
panResult
.
Size
=
new
System
.
Drawing
.
Size
(
298
,
333
);
...
...
@@ -101,9 +97,9 @@
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
(
29
,
123
);
this
.
lblResult
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
114
);
this
.
lblResult
.
Name
=
"lblResult"
;
this
.
lblResult
.
Size
=
new
System
.
Drawing
.
Size
(
2
31
,
24
);
this
.
lblResult
.
Size
=
new
System
.
Drawing
.
Size
(
2
76
,
24
);
this
.
lblResult
.
TabIndex
=
4
;
this
.
lblResult
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleCenter
;
//
...
...
@@ -113,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
(
145
,
79
);
this
.
btnTest
.
Location
=
new
System
.
Drawing
.
Point
(
92
,
56
);
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
)))));
...
...
@@ -121,38 +117,14 @@
this
.
btnTest
.
Text
=
"测试结果"
;
this
.
btnTest
.
Click
+=
new
System
.
EventHandler
(
this
.
btnTest_Click
);
//
// btnOpenImage
//
this
.
btnOpenImage
.
BackColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))));
this
.
btnOpenImage
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
9F
);
this
.
btnOpenImage
.
ImageSize
=
new
System
.
Drawing
.
Size
(
0
,
0
);
this
.
btnOpenImage
.
Inside
=
false
;
this
.
btnOpenImage
.
Location
=
new
System
.
Drawing
.
Point
(
24
,
79
);
this
.
btnOpenImage
.
Name
=
"btnOpenImage"
;
this
.
btnOpenImage
.
Size
=
new
System
.
Drawing
.
Size
(
115
,
30
);
this
.
btnOpenImage
.
StateColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))));
this
.
btnOpenImage
.
TabIndex
=
6
;
this
.
btnOpenImage
.
Text
=
"打开本地图片"
;
this
.
btnOpenImage
.
Click
+=
new
System
.
EventHandler
(
this
.
btnOpenImage_Click
);
//
// txtImage
//
this
.
txtImage
.
BackColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))));
this
.
txtImage
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
9F
);
this
.
txtImage
.
Inside
=
false
;
this
.
txtImage
.
Location
=
new
System
.
Drawing
.
Point
(
8
,
33
);
this
.
txtImage
.
Name
=
"txtImage"
;
this
.
txtImage
.
Size
=
new
System
.
Drawing
.
Size
(
281
,
30
);
this
.
txtImage
.
TabIndex
=
7
;
//
// lblTime
//
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
(
29
,
158
);
this
.
lblTime
.
Location
=
new
System
.
Drawing
.
Point
(
12
,
149
);
this
.
lblTime
.
Name
=
"lblTime"
;
this
.
lblTime
.
Size
=
new
System
.
Drawing
.
Size
(
2
31
,
24
);
this
.
lblTime
.
Size
=
new
System
.
Drawing
.
Size
(
2
76
,
24
);
this
.
lblTime
.
TabIndex
=
8
;
this
.
lblTime
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleCenter
;
//
...
...
@@ -215,8 +187,6 @@
private
Asa
.
Theme
.
FlatLabel
flatLabel1
;
private
System
.
Windows
.
Forms
.
Label
lblResult
;
private
Asa
.
Theme
.
FlatButton
btnTest
;
private
Asa
.
Theme
.
FlatText
txtImage
;
private
Asa
.
Theme
.
FlatButton
btnOpenImage
;
private
System
.
Windows
.
Forms
.
Label
lblTime
;
private
System
.
Windows
.
Forms
.
TrackBar
trackBarSamePercent
;
private
Asa
.
Theme
.
FlatLabel
flatLabel3
;
...
...
AccAOI/control/AioMarkControl.cs
查看文件 @
bb6a7e9
...
...
@@ -60,35 +60,36 @@ namespace AccAOI.control
if
(
this
.
AoiInfo
is
AoiMarkMethod
)
{
string
fileName
=
txtImage
.
Text
.
ToString
();
Image
checkImg
=
null
;
if
(
File
.
Exists
(
fileName
))
{
//读取图片内容
// checkImg = (Image)Image.FromFile(fileName).Clone();
Image
file
=
(
Image
)
Image
.
FromFile
(
fileName
);
checkImg
=
new
Bitmap
(
file
);
file
.
Dispose
();
}
//
string fileName = txtImage.Text.ToString();
Image
checkImg
=
FrmAoiSetting
.
TestImage
;
//
if (File.Exists(fileName))
//
{
//
//读取图片内容
//
// checkImg = (Image)Image.FromFile(fileName).Clone();
//
Image file = (Image)Image.FromFile(fileName);
//
checkImg = new Bitmap(file);
//
file.Dispose();
//
}
if
(
checkImg
==
null
)
{
checkImg
=
FrmAoiSetting
.
BaseImg
;
}
DateTime
time
=
DateTime
.
Now
;
AoiMarkMethod
mark
=
(
AoiMarkMethod
)
AoiInfo
;
Image
result
=
mark
.
FixImage
(
FrmAoiSetting
.
BaseImg
,
checkImg
);
double
sameValue
=
0
;
Image
result
=
mark
.
FixImage
(
FrmAoiSetting
.
BaseImg
,
checkImg
,
out
sameValue
);
TimeSpan
span
=
DateTime
.
Now
-
time
;
if
(
result
==
null
)
{
this
.
aoiImage
.
Image
=
null
;
lblResult
.
ForeColor
=
Color
.
Red
;
lblResult
.
Text
=
AOIResourceCulture
.
GetValue
(
"Mark区域无效"
);
lblResult
.
Text
=
AOIResourceCulture
.
GetValue
(
"Mark区域无效"
)
+
" ("
+
sameValue
+
"%)"
;
}
else
{
SetCurrImageType
(
2
);
lblResult
.
ForeColor
=
Color
.
Green
;
lblResult
.
Text
=
"OK"
;
lblResult
.
Text
=
"OK"
+
" ("
+
sameValue
+
"%)"
;
this
.
aoiImage
.
Image
=
result
;
}
lblTime
.
Text
=
"times :"
+
Math
.
Round
(
span
.
TotalSeconds
,
1
)+
"s"
;
...
...
@@ -147,23 +148,23 @@ namespace AccAOI.control
}
private
void
btnOpenImage_Click
(
object
sender
,
EventArgs
e
)
{
System
.
Windows
.
Forms
.
OpenFileDialog
openDialog
=
new
System
.
Windows
.
Forms
.
OpenFileDialog
();
openDialog
.
Title
=
AOIResourceCulture
.
GetValue
(
"打开本地图片"
);
openDialog
.
Filter
=
"All Supported Images (*.bmp;*.dib;*.rle;*.gif;*.jpg;*.png)|*.bmp;*.dib;*.rle;*.gif;*.jpg;*.png|Bitmaps (*.bmp;*.dib;*.rle)|*.bmp;*.dib;*.rle|Graphics Interchange Format (*.gif)|*.gif|Joint Photographic Experts (*.jpg)|*.jpg|Portable Network Graphics (*.png)|*.png|All Files (*.*)|*.*"
;
openDialog
.
DefaultExt
=
"png"
;
//openDialog.DefaultExt = "png";
System
.
Windows
.
Forms
.
DialogResult
result
=
openDialog
.
ShowDialog
();
if
(
result
==
System
.
Windows
.
Forms
.
DialogResult
.
Cancel
)
{
return
;
}
string
fileName
=
openDialog
.
FileName
;
//
private void btnOpenImage_Click(object sender, EventArgs e)
//
{
//
System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog();
//
openDialog.Title = AOIResourceCulture.GetValue("打开本地图片");
//
openDialog.Filter = "All Supported Images (*.bmp;*.dib;*.rle;*.gif;*.jpg;*.png)|*.bmp;*.dib;*.rle;*.gif;*.jpg;*.png|Bitmaps (*.bmp;*.dib;*.rle)|*.bmp;*.dib;*.rle|Graphics Interchange Format (*.gif)|*.gif|Joint Photographic Experts (*.jpg)|*.jpg|Portable Network Graphics (*.png)|*.png|All Files (*.*)|*.*";
//
openDialog.DefaultExt = "png";
//
//openDialog.DefaultExt = "png";
//
System.Windows.Forms.DialogResult result = openDialog.ShowDialog();
//
if (result == System.Windows.Forms.DialogResult.Cancel)
//
{
//
return;
//
}
//
string fileName = openDialog.FileName;
txtImage
.
Text
=
fileName
;
//
txtImage.Text = fileName;
}
//
}
private
void
trackBarSamePercent_ValueChanged
(
object
sender
,
EventArgs
e
)
{
...
...
AccAOI/control/AioTempMatchControl.Designer.cs
查看文件 @
bb6a7e9
...
...
@@ -30,8 +30,6 @@
{
this
.
lblResult
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
btnTest
=
new
Asa
.
Theme
.
FlatButton
();
this
.
btnOpenImage
=
new
Asa
.
Theme
.
FlatButton
();
this
.
txtImage
=
new
Asa
.
Theme
.
FlatText
();
this
.
lblTime
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
trackBarSamePercent
=
new
System
.
Windows
.
Forms
.
TrackBar
();
this
.
flatLabel3
=
new
Asa
.
Theme
.
FlatLabel
();
...
...
@@ -51,8 +49,6 @@
// panResult
//
this
.
panResult
.
Controls
.
Add
(
this
.
lblTime
);
this
.
panResult
.
Controls
.
Add
(
this
.
txtImage
);
this
.
panResult
.
Controls
.
Add
(
this
.
btnOpenImage
);
this
.
panResult
.
Controls
.
Add
(
this
.
btnTest
);
this
.
panResult
.
Controls
.
Add
(
this
.
lblResult
);
this
.
panResult
.
Location
=
new
System
.
Drawing
.
Point
(
4
,
413
);
...
...
@@ -63,9 +59,9 @@
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
(
29
,
123
);
this
.
lblResult
.
Location
=
new
System
.
Drawing
.
Point
(
8
,
123
);
this
.
lblResult
.
Name
=
"lblResult"
;
this
.
lblResult
.
Size
=
new
System
.
Drawing
.
Size
(
2
31
,
24
);
this
.
lblResult
.
Size
=
new
System
.
Drawing
.
Size
(
2
83
,
24
);
this
.
lblResult
.
TabIndex
=
4
;
this
.
lblResult
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleCenter
;
//
...
...
@@ -75,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
(
145
,
79
);
this
.
btnTest
.
Location
=
new
System
.
Drawing
.
Point
(
92
,
71
);
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
)))));
...
...
@@ -83,38 +79,14 @@
this
.
btnTest
.
Text
=
"测试结果"
;
this
.
btnTest
.
Click
+=
new
System
.
EventHandler
(
this
.
btnTest_Click
);
//
// btnOpenImage
//
this
.
btnOpenImage
.
BackColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))));
this
.
btnOpenImage
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
9F
);
this
.
btnOpenImage
.
ImageSize
=
new
System
.
Drawing
.
Size
(
0
,
0
);
this
.
btnOpenImage
.
Inside
=
false
;
this
.
btnOpenImage
.
Location
=
new
System
.
Drawing
.
Point
(
24
,
79
);
this
.
btnOpenImage
.
Name
=
"btnOpenImage"
;
this
.
btnOpenImage
.
Size
=
new
System
.
Drawing
.
Size
(
115
,
30
);
this
.
btnOpenImage
.
StateColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))));
this
.
btnOpenImage
.
TabIndex
=
6
;
this
.
btnOpenImage
.
Text
=
"打开本地图片"
;
this
.
btnOpenImage
.
Click
+=
new
System
.
EventHandler
(
this
.
btnOpenImage_Click
);
//
// txtImage
//
this
.
txtImage
.
BackColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))));
this
.
txtImage
.
Font
=
new
System
.
Drawing
.
Font
(
"宋体"
,
9F
);
this
.
txtImage
.
Inside
=
false
;
this
.
txtImage
.
Location
=
new
System
.
Drawing
.
Point
(
8
,
33
);
this
.
txtImage
.
Name
=
"txtImage"
;
this
.
txtImage
.
Size
=
new
System
.
Drawing
.
Size
(
281
,
30
);
this
.
txtImage
.
TabIndex
=
7
;
//
// lblTime
//
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
(
29
,
158
);
this
.
lblTime
.
Location
=
new
System
.
Drawing
.
Point
(
8
,
158
);
this
.
lblTime
.
Name
=
"lblTime"
;
this
.
lblTime
.
Size
=
new
System
.
Drawing
.
Size
(
2
31
,
24
);
this
.
lblTime
.
Size
=
new
System
.
Drawing
.
Size
(
2
83
,
24
);
this
.
lblTime
.
TabIndex
=
8
;
this
.
lblTime
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleCenter
;
//
...
...
@@ -173,8 +145,6 @@
#
endregion
private
System
.
Windows
.
Forms
.
Label
lblResult
;
private
Asa
.
Theme
.
FlatButton
btnTest
;
private
Asa
.
Theme
.
FlatText
txtImage
;
private
Asa
.
Theme
.
FlatButton
btnOpenImage
;
private
System
.
Windows
.
Forms
.
Label
lblTime
;
private
System
.
Windows
.
Forms
.
TrackBar
trackBarSamePercent
;
private
Asa
.
Theme
.
FlatLabel
flatLabel3
;
...
...
AccAOI/control/AioTempMatchControl.cs
查看文件 @
bb6a7e9
...
...
@@ -58,16 +58,16 @@ namespace AccAOI.control
if
(
this
.
AoiInfo
is
AoiTemplateMethod
)
{
string
fileName
=
txtImage
.
Text
.
ToString
();
Image
checkImg
=
null
;
if
(
File
.
Exists
(
fileName
))
{
//读取图片内容
//checkImg = (Image)Image.FromFile(fileName).Clone();
Image
file
=
(
Image
)
Image
.
FromFile
(
fileName
);
checkImg
=
new
Bitmap
(
file
);
file
.
Dispose
();
}
//
string fileName = txtImage.Text.ToString();
Image
checkImg
=
FrmAoiSetting
.
TestImage
;
//
if (File.Exists(fileName))
//
{
//
//读取图片内容
//
//checkImg = (Image)Image.FromFile(fileName).Clone();
//
Image file = (Image)Image.FromFile(fileName);
//
checkImg = new Bitmap(file);
//
file.Dispose();
//
}
if
(
checkImg
==
null
)
{
checkImg
=
FrmAoiSetting
.
BaseImg
;
...
...
@@ -80,12 +80,17 @@ namespace AccAOI.control
{
this
.
aoiImage
.
Image
=
null
;
lblResult
.
ForeColor
=
Color
.
Red
;
lblResult
.
Text
=
AOIResourceCulture
.
GetValue
(
"匹配失败"
);
lblResult
.
Text
=
AOIResourceCulture
.
GetValue
(
"匹配失败"
)
+
" (0%)"
;
}
else
{
lblResult
.
ForeColor
=
Color
.
Green
;
lblResult
.
Text
=
result
.
result
?
"OK"
:
"NG"
;
//lblResult.Text =result.result? "OK" :"NG" ;
if
(!
result
.
result
)
{
lblResult
.
ForeColor
=
Color
.
Red
;
}
lblResult
.
Text
+=
" ("
+
result
.
samePercent
+
"%)"
;
if
(
result
.
currentRoiImage
!=
null
)
{
SetCurrImageType
(
2
);
...
...
@@ -147,23 +152,23 @@ namespace AccAOI.control
}
private
void
btnOpenImage_Click
(
object
sender
,
EventArgs
e
)
{
System
.
Windows
.
Forms
.
OpenFileDialog
openDialog
=
new
System
.
Windows
.
Forms
.
OpenFileDialog
();
openDialog
.
Title
=
AOIResourceCulture
.
GetValue
(
"打开本地图片"
);
openDialog
.
Filter
=
"All Supported Images (*.bmp;*.dib;*.rle;*.gif;*.jpg;*.png)|*.bmp;*.dib;*.rle;*.gif;*.jpg;*.png|Bitmaps (*.bmp;*.dib;*.rle)|*.bmp;*.dib;*.rle|Graphics Interchange Format (*.gif)|*.gif|Joint Photographic Experts (*.jpg)|*.jpg|Portable Network Graphics (*.png)|*.png|All Files (*.*)|*.*"
;
openDialog
.
DefaultExt
=
"png"
;
//openDialog.DefaultExt = "png";
System
.
Windows
.
Forms
.
DialogResult
result
=
openDialog
.
ShowDialog
();
if
(
result
==
System
.
Windows
.
Forms
.
DialogResult
.
Cancel
)
{
return
;
}
string
fileName
=
openDialog
.
FileName
;
//
private void btnOpenImage_Click(object sender, EventArgs e)
//
{
//
System.Windows.Forms.OpenFileDialog openDialog = new System.Windows.Forms.OpenFileDialog();
//
openDialog.Title = AOIResourceCulture.GetValue("打开本地图片");
//
openDialog.Filter = "All Supported Images (*.bmp;*.dib;*.rle;*.gif;*.jpg;*.png)|*.bmp;*.dib;*.rle;*.gif;*.jpg;*.png|Bitmaps (*.bmp;*.dib;*.rle)|*.bmp;*.dib;*.rle|Graphics Interchange Format (*.gif)|*.gif|Joint Photographic Experts (*.jpg)|*.jpg|Portable Network Graphics (*.png)|*.png|All Files (*.*)|*.*";
//
openDialog.DefaultExt = "png";
//
//openDialog.DefaultExt = "png";
//
System.Windows.Forms.DialogResult result = openDialog.ShowDialog();
//
if (result == System.Windows.Forms.DialogResult.Cancel)
//
{
//
return;
//
}
//
string fileName = openDialog.FileName;
txtImage
.
Text
=
fileName
;
//
txtImage.Text = fileName;
}
//
}
private
void
trackBarSamePercent_ValueChanged
(
object
sender
,
EventArgs
e
)
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论