Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
AccAOI
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 1cc8c708
由
LN
编写于
2019-08-06 14:45:19 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
BUG修改
1 个父辈
560f3eda
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
61 行增加
和
17 行删除
AccAOI/AccAOI.csproj
AccAOI/FrmAoiSetting.Designer.cs
AccAOI/FrmAoiSetting.cs
AccAOI/camera/CameraManager.cs
AccAOI/AccAOI.csproj
查看文件 @
1cc8c70
...
...
@@ -21,6 +21,7 @@
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
...
...
AccAOI/FrmAoiSetting.Designer.cs
查看文件 @
1cc8c70
...
...
@@ -105,7 +105,7 @@ namespace AccAOI
//
this
.
btnOpenImage
.
ImageSize
=
new
System
.
Drawing
.
Size
(
0
,
0
);
this
.
btnOpenImage
.
Inside
=
false
;
this
.
btnOpenImage
.
Location
=
new
System
.
Drawing
.
Point
(
1
091
,
40
);
this
.
btnOpenImage
.
Location
=
new
System
.
Drawing
.
Point
(
1
155
,
40
);
this
.
btnOpenImage
.
Name
=
"btnOpenImage"
;
this
.
btnOpenImage
.
Size
=
new
System
.
Drawing
.
Size
(
109
,
30
);
this
.
btnOpenImage
.
StateColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))));
...
...
@@ -129,14 +129,14 @@ namespace AccAOI
this
.
cmbCameraList
.
Inside
=
false
;
this
.
cmbCameraList
.
Location
=
new
System
.
Drawing
.
Point
(
730
,
40
);
this
.
cmbCameraList
.
Name
=
"cmbCameraList"
;
this
.
cmbCameraList
.
Size
=
new
System
.
Drawing
.
Size
(
2
17
,
30
);
this
.
cmbCameraList
.
Size
=
new
System
.
Drawing
.
Size
(
2
81
,
30
);
this
.
cmbCameraList
.
TabIndex
=
12
;
//
// btnGetCameraImg
//
this
.
btnGetCameraImg
.
ImageSize
=
new
System
.
Drawing
.
Size
(
0
,
0
);
this
.
btnGetCameraImg
.
Inside
=
false
;
this
.
btnGetCameraImg
.
Location
=
new
System
.
Drawing
.
Point
(
967
,
40
);
this
.
btnGetCameraImg
.
Location
=
new
System
.
Drawing
.
Point
(
1031
,
40
);
this
.
btnGetCameraImg
.
Name
=
"btnGetCameraImg"
;
this
.
btnGetCameraImg
.
Size
=
new
System
.
Drawing
.
Size
(
109
,
30
);
this
.
btnGetCameraImg
.
StateColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))));
...
...
@@ -174,7 +174,7 @@ namespace AccAOI
this
.
imageBox1
.
Name
=
"imageBox1"
;
this
.
imageBox1
.
SelectionColor
=
System
.
Drawing
.
Color
.
Blue
;
this
.
imageBox1
.
SelectionMode
=
Acc
.
ImageBox
.
ImageBoxSelectionMode
.
Rectangle
;
this
.
imageBox1
.
Size
=
new
System
.
Drawing
.
Size
(
637
,
517
);
this
.
imageBox1
.
Size
=
new
System
.
Drawing
.
Size
(
728
,
517
);
this
.
imageBox1
.
TabIndex
=
4
;
this
.
imageBox1
.
SelectionRegionChanged
+=
new
System
.
EventHandler
(
this
.
imageBox1_SelectionRegionChanged
);
//
...
...
@@ -206,7 +206,7 @@ namespace AccAOI
//
this
.
btnImageChange
.
ImageSize
=
new
System
.
Drawing
.
Size
(
0
,
0
);
this
.
btnImageChange
.
Inside
=
false
;
this
.
btnImageChange
.
Location
=
new
System
.
Drawing
.
Point
(
838
,
76
);
this
.
btnImageChange
.
Location
=
new
System
.
Drawing
.
Point
(
902
,
76
);
this
.
btnImageChange
.
Name
=
"btnImageChange"
;
this
.
btnImageChange
.
Size
=
new
System
.
Drawing
.
Size
(
109
,
30
);
this
.
btnImageChange
.
StateColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))));
...
...
@@ -218,7 +218,7 @@ namespace AccAOI
//
this
.
flatButton1
.
ImageSize
=
new
System
.
Drawing
.
Size
(
0
,
0
);
this
.
flatButton1
.
Inside
=
false
;
this
.
flatButton1
.
Location
=
new
System
.
Drawing
.
Point
(
967
,
76
);
this
.
flatButton1
.
Location
=
new
System
.
Drawing
.
Point
(
1031
,
76
);
this
.
flatButton1
.
Name
=
"flatButton1"
;
this
.
flatButton1
.
Size
=
new
System
.
Drawing
.
Size
(
109
,
30
);
this
.
flatButton1
.
StateColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))));
...
...
@@ -230,7 +230,7 @@ namespace AccAOI
//
this
.
flatButton2
.
ImageSize
=
new
System
.
Drawing
.
Size
(
0
,
0
);
this
.
flatButton2
.
Inside
=
false
;
this
.
flatButton2
.
Location
=
new
System
.
Drawing
.
Point
(
1
091
,
76
);
this
.
flatButton2
.
Location
=
new
System
.
Drawing
.
Point
(
1
155
,
76
);
this
.
flatButton2
.
Name
=
"flatButton2"
;
this
.
flatButton2
.
Size
=
new
System
.
Drawing
.
Size
(
109
,
30
);
this
.
flatButton2
.
StateColor
=
System
.
Drawing
.
Color
.
FromArgb
(((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))),
((
int
)(((
byte
)(
30
)))));
...
...
@@ -248,7 +248,7 @@ namespace AccAOI
this
.
testImageBox1
.
Location
=
new
System
.
Drawing
.
Point
(
668
,
101
);
this
.
testImageBox1
.
Name
=
"testImageBox1"
;
this
.
testImageBox1
.
SelectionColor
=
System
.
Drawing
.
Color
.
Blue
;
this
.
testImageBox1
.
Size
=
new
System
.
Drawing
.
Size
(
561
,
421
);
this
.
testImageBox1
.
Size
=
new
System
.
Drawing
.
Size
(
652
,
421
);
this
.
testImageBox1
.
TabIndex
=
21
;
this
.
testImageBox1
.
Visible
=
false
;
//
...
...
@@ -256,8 +256,8 @@ namespace AccAOI
//
this
.
lblCurrImage
.
AutoSize
=
true
;
this
.
lblCurrImage
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
12F
,
System
.
Drawing
.
FontStyle
.
Bold
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblCurrImage
.
ForeColor
=
System
.
Drawing
.
Color
.
Green
;
this
.
lblCurrImage
.
Location
=
new
System
.
Drawing
.
Point
(
6
28
,
87
);
this
.
lblCurrImage
.
ForeColor
=
System
.
Drawing
.
Color
.
Lawn
Green
;
this
.
lblCurrImage
.
Location
=
new
System
.
Drawing
.
Point
(
6
55
,
84
);
this
.
lblCurrImage
.
Name
=
"lblCurrImage"
;
this
.
lblCurrImage
.
Size
=
new
System
.
Drawing
.
Size
(
74
,
22
);
this
.
lblCurrImage
.
TabIndex
=
22
;
...
...
@@ -266,7 +266,7 @@ namespace AccAOI
// FrmAoiSetting
//
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
None
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1
271
,
641
);
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1
362
,
641
);
this
.
Controls
.
Add
(
this
.
lblCurrImage
);
this
.
Controls
.
Add
(
this
.
testImageBox1
);
this
.
Controls
.
Add
(
this
.
flatButton1
);
...
...
AccAOI/FrmAoiSetting.cs
查看文件 @
1cc8c70
...
...
@@ -6,6 +6,7 @@ using System.ComponentModel;
using
System.Data
;
using
System.Drawing
;
using
System.Drawing.Drawing2D
;
using
System.Drawing.Imaging
;
using
System.IO
;
using
System.Linq
;
using
System.Text
;
...
...
@@ -77,10 +78,31 @@ namespace AccAOI
{
cmbCameraList
.
ItemAdd
(
str
);
}
if
(
CameraManager
.
hikNameList
.
Count
>
0
)
{
cmbCameraList
.
Text
=
CameraManager
.
hikNameList
[
0
];
}
if
(
Project
!=
null
)
{
ShowPorject
();
}
ClearBaseImage
();
}
private
void
ClearBaseImage
()
{
try
{
string
fileName
=
Application
.
StartupPath
+
@"\aimage\"
;
if
(
Directory
.
Exists
(
fileName
))
{
Directory
.
Delete
(
fileName
,
true
);
}
}
catch
(
Exception
EX
)
{
Console
.
Write
(
EX
.
ToString
());
}
}
private
void
btnOpenImage_Click
(
object
sender
,
EventArgs
e
)
...
...
@@ -113,17 +135,32 @@ namespace AccAOI
private
void
btnGetCameraImg_Click
(
object
sender
,
EventArgs
e
)
{
try
{
string
camera
=
cmbCameraList
.
Text
;
if
(
camera
.
Equals
(
""
))
{
MessageBox
.
Show
(
"清先选择相机"
);
return
;
}
Bitmap
img
=
CameraManager
.
GetCamerImage
(
camera
);
}
//将图片保存到本地重新加载
string
fileName
=
Application
.
StartupPath
+
@"\aimage\" + DateTime.Now.ToString("
yyyy
-
MM
-
dd
-
HH
-
mm
-
ss
") + DateTime.Now.Millisecond.ToString().PadLeft(3, '0') ;
string
file
=
@"\test.bmp"
;
using
(
Bitmap
img
=
CameraManager
.
GetCamerImage
(
camera
))
{
if
(
img
!=
null
)
{
string
path
=
Path
.
GetFullPath
(
fileName
);
if
(!
Directory
.
Exists
(
path
))
{
Directory
.
CreateDirectory
(
path
);
}
img
.
Save
(
fileName
+
file
,
ImageFormat
.
Bmp
);
}
}
GC
.
Collect
();
BaseImg
=
(
Image
)
Image
.
FromFile
(
fileName
+
file
).
Clone
();
//读取图片内容
BaseImg
=
(
Image
)
img
.
Clone
();
//
BaseImg = (Image)img.Clone();
if
(
Project
!=
null
)
{
Project
.
standardImage
=
BaseImg
;
...
...
@@ -134,6 +171,11 @@ namespace AccAOI
btnImageChange_Click
(
null
,
null
);
}
}
catch
(
Exception
ex
)
{
Console
.
WriteLine
(
"btnGetCameraImg_Click Error:"
+
ex
.
ToString
());
MessageBox
.
Show
(
ex
.
ToString
());
}
}
private
void
btnOpenPro_Click
(
object
sender
,
EventArgs
e
)
...
...
@@ -349,7 +391,7 @@ namespace AccAOI
{
aoiList
.
Index
=
index
;
ShowAoi
(
Project
.
methodMap
[
key
]);
}
}
index
++;
}
}
if
(
imageBox1
.
Visible
.
Equals
(
false
))
...
...
@@ -436,6 +478,7 @@ namespace AccAOI
this
.
testImageBox1
.
SelectNone
();
this
.
testImageBox1
.
Image
=
outImage
;
}
GC
.
Collect
();
CanSel
=
true
;
}
...
...
@@ -471,7 +514,7 @@ namespace AccAOI
imageBox1
.
Visible
=
true
;
btnImageChange
.
Text
=
"显示测试图片"
;
lblCurrImage
.
Text
=
"基准图:"
;
lblCurrImage
.
ForeColor
=
Color
.
Green
;
lblCurrImage
.
ForeColor
=
Color
.
Lawn
Green
;
}
else
{
...
...
AccAOI/camera/CameraManager.cs
查看文件 @
1cc8c70
...
...
@@ -47,8 +47,8 @@ namespace AccAOI.camera
if
(
HIKCamera
.
Instance
.
Image
!=
null
)
{
bitm
=
(
Bitmap
)
HIKCamera
.
Instance
.
Image
;
//HIKCamera.Instance.Close();
}
HIKCamera
.
Instance
.
Close
();
}
else
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论