Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
GeneralClassLibrary
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit fee2767d
由
LN
编写于
2020-03-16 10:23:51 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
二维码学习功能修改
1 个父辈
12cebded
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
241 行增加
和
294 行删除
CodeLibraryProject/CodeLibrary/CodeLibrary.csproj
CodeLibraryProject/CodeLibrary/FrmCodeDecode.Designer.cs
CodeLibraryProject/CodeLibrary/FrmCodeDecode.cs
CodeLibraryProject/CodeLibrary/FrmCodeLearn.Designer.cs
CodeLibraryProject/CodeLibrary/FrmCodeLearn.cs
CodeLibraryProject/CodeLibrary/HDCodeHelper.cs
CodeLibraryProject/CodeLibrary/ZXingCodeHelper.cs
CodeLibraryProject/CodeLibrary/camera/Basler.cs
CodeLibraryProject/编译好的DLL/CodeLibrary.dll
dll/CodeLibrary.dll
dll/zxing.dll
CodeLibraryProject/CodeLibrary/CodeLibrary.csproj
查看文件 @
fee2767
...
@@ -9,7 +9,7 @@
...
@@ -9,7 +9,7 @@
<AppDesignerFolder>Properties</AppDesignerFolder>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>CodeLibrary</RootNamespace>
<RootNamespace>CodeLibrary</RootNamespace>
<AssemblyName>CodeLibrary</AssemblyName>
<AssemblyName>CodeLibrary</AssemblyName>
<TargetFrameworkVersion>v4.
0
</TargetFrameworkVersion>
<TargetFrameworkVersion>v4.
5
</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
<TargetFrameworkProfile />
</PropertyGroup>
</PropertyGroup>
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
<ErrorReport>prompt</ErrorReport>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<WarningLevel>4</WarningLevel>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<DebugType>pdbonly</DebugType>
...
@@ -30,6 +31,7 @@
...
@@ -30,6 +31,7 @@
<DefineConstants>TRACE</DefineConstants>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
</PropertyGroup>
<ItemGroup>
<ItemGroup>
<Reference Include="Basler.Pylon, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e389355f398382ab, processorArchitecture=x86">
<Reference Include="Basler.Pylon, Version=1.0.0.0, Culture=neutral, PublicKeyToken=e389355f398382ab, processorArchitecture=x86">
...
@@ -55,6 +57,9 @@
...
@@ -55,6 +57,9 @@
<Reference Include="System.Data" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml" />
<Reference Include="zxing">
<HintPath>..\dll\zxing.dll</HintPath>
</Reference>
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile Include="camera\Basler.cs" />
<Compile Include="camera\Basler.cs" />
...
@@ -84,6 +89,7 @@
...
@@ -84,6 +89,7 @@
<Compile Include="ImageHelper.cs" />
<Compile Include="ImageHelper.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="CodeResourceControl.cs" />
<Compile Include="CodeResourceControl.cs" />
<Compile Include="ZXingCodeHelper.cs" />
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<EmbeddedResource Include="FrmBase.resx">
<EmbeddedResource Include="FrmBase.resx">
...
...
CodeLibraryProject/CodeLibrary/FrmCodeDecode.Designer.cs
查看文件 @
fee2767
...
@@ -33,8 +33,6 @@
...
@@ -33,8 +33,6 @@
this
.
btnSelImage
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnSelImage
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
pictureBox1
=
new
System
.
Windows
.
Forms
.
PictureBox
();
this
.
pictureBox1
=
new
System
.
Windows
.
Forms
.
PictureBox
();
this
.
txtResult
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
txtResult
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
btnErZhi
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnGray
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
hWindowControl1
=
new
HalconDotNet
.
HWindowControl
();
this
.
hWindowControl1
=
new
HalconDotNet
.
HWindowControl
();
this
.
btnbarCode
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnbarCode
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnLearn
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnLearn
=
new
System
.
Windows
.
Forms
.
Button
();
...
@@ -49,13 +47,11 @@
...
@@ -49,13 +47,11 @@
this
.
label2
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label2
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
cmbCodeType
=
new
System
.
Windows
.
Forms
.
ComboBox
();
this
.
cmbCodeType
=
new
System
.
Windows
.
Forms
.
ComboBox
();
this
.
label3
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label3
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
btnAn
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
chbUseParam
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
chbUseParam
=
new
System
.
Windows
.
Forms
.
CheckBox
();
this
.
txtParamPath
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
txtParamPath
=
new
System
.
Windows
.
Forms
.
TextBox
();
this
.
label4
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
label4
=
new
System
.
Windows
.
Forms
.
Label
();
this
.
btnLight
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
button1
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnScanTest
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
btnScanTest
=
new
System
.
Windows
.
Forms
.
Button
();
this
.
chbZxing
=
new
System
.
Windows
.
Forms
.
CheckBox
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox1
)).
BeginInit
();
((
System
.
ComponentModel
.
ISupportInitialize
)(
this
.
pictureBox1
)).
BeginInit
();
this
.
SuspendLayout
();
this
.
SuspendLayout
();
//
//
...
@@ -70,7 +66,7 @@
...
@@ -70,7 +66,7 @@
// btnSelImage
// btnSelImage
//
//
this
.
btnSelImage
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnSelImage
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnSelImage
.
Location
=
new
System
.
Drawing
.
Point
(
10
,
1
2
);
this
.
btnSelImage
.
Location
=
new
System
.
Drawing
.
Point
(
10
,
1
0
);
this
.
btnSelImage
.
Name
=
"btnSelImage"
;
this
.
btnSelImage
.
Name
=
"btnSelImage"
;
this
.
btnSelImage
.
Size
=
new
System
.
Drawing
.
Size
(
141
,
33
);
this
.
btnSelImage
.
Size
=
new
System
.
Drawing
.
Size
(
141
,
33
);
this
.
btnSelImage
.
TabIndex
=
1
;
this
.
btnSelImage
.
TabIndex
=
1
;
...
@@ -99,30 +95,6 @@
...
@@ -99,30 +95,6 @@
this
.
txtResult
.
Size
=
new
System
.
Drawing
.
Size
(
450
,
290
);
this
.
txtResult
.
Size
=
new
System
.
Drawing
.
Size
(
450
,
290
);
this
.
txtResult
.
TabIndex
=
3
;
this
.
txtResult
.
TabIndex
=
3
;
//
//
// btnErZhi
//
this
.
btnErZhi
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnErZhi
.
Location
=
new
System
.
Drawing
.
Point
(
557
,
12
);
this
.
btnErZhi
.
Name
=
"btnErZhi"
;
this
.
btnErZhi
.
Size
=
new
System
.
Drawing
.
Size
(
59
,
33
);
this
.
btnErZhi
.
TabIndex
=
5
;
this
.
btnErZhi
.
Text
=
"二值化"
;
this
.
btnErZhi
.
UseVisualStyleBackColor
=
true
;
this
.
btnErZhi
.
Visible
=
false
;
this
.
btnErZhi
.
Click
+=
new
System
.
EventHandler
(
this
.
btnErZhi_Click
);
//
// btnGray
//
this
.
btnGray
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnGray
.
Location
=
new
System
.
Drawing
.
Point
(
557
,
50
);
this
.
btnGray
.
Name
=
"btnGray"
;
this
.
btnGray
.
Size
=
new
System
.
Drawing
.
Size
(
59
,
33
);
this
.
btnGray
.
TabIndex
=
6
;
this
.
btnGray
.
Text
=
"图像转灰"
;
this
.
btnGray
.
UseVisualStyleBackColor
=
true
;
this
.
btnGray
.
Visible
=
false
;
this
.
btnGray
.
Click
+=
new
System
.
EventHandler
(
this
.
btnGray_Click
);
//
// hWindowControl1
// hWindowControl1
//
//
this
.
hWindowControl1
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Bottom
)
this
.
hWindowControl1
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Bottom
)
...
@@ -140,7 +112,7 @@
...
@@ -140,7 +112,7 @@
// btnbarCode
// btnbarCode
//
//
this
.
btnbarCode
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnbarCode
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnbarCode
.
Location
=
new
System
.
Drawing
.
Point
(
896
,
50
);
this
.
btnbarCode
.
Location
=
new
System
.
Drawing
.
Point
(
896
,
49
);
this
.
btnbarCode
.
Name
=
"btnbarCode"
;
this
.
btnbarCode
.
Name
=
"btnbarCode"
;
this
.
btnbarCode
.
Size
=
new
System
.
Drawing
.
Size
(
167
,
33
);
this
.
btnbarCode
.
Size
=
new
System
.
Drawing
.
Size
(
167
,
33
);
this
.
btnbarCode
.
TabIndex
=
9
;
this
.
btnbarCode
.
TabIndex
=
9
;
...
@@ -152,7 +124,7 @@
...
@@ -152,7 +124,7 @@
//
//
this
.
btnLearn
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
btnLearn
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
btnLearn
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnLearn
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnLearn
.
Location
=
new
System
.
Drawing
.
Point
(
1249
,
1
2
);
this
.
btnLearn
.
Location
=
new
System
.
Drawing
.
Point
(
1249
,
1
0
);
this
.
btnLearn
.
Name
=
"btnLearn"
;
this
.
btnLearn
.
Name
=
"btnLearn"
;
this
.
btnLearn
.
Size
=
new
System
.
Drawing
.
Size
(
109
,
33
);
this
.
btnLearn
.
Size
=
new
System
.
Drawing
.
Size
(
109
,
33
);
this
.
btnLearn
.
TabIndex
=
10
;
this
.
btnLearn
.
TabIndex
=
10
;
...
@@ -163,7 +135,7 @@
...
@@ -163,7 +135,7 @@
// btnDCode
// btnDCode
//
//
this
.
btnDCode
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnDCode
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnDCode
.
Location
=
new
System
.
Drawing
.
Point
(
896
,
1
2
);
this
.
btnDCode
.
Location
=
new
System
.
Drawing
.
Point
(
896
,
1
0
);
this
.
btnDCode
.
Name
=
"btnDCode"
;
this
.
btnDCode
.
Name
=
"btnDCode"
;
this
.
btnDCode
.
Size
=
new
System
.
Drawing
.
Size
(
167
,
33
);
this
.
btnDCode
.
Size
=
new
System
.
Drawing
.
Size
(
167
,
33
);
this
.
btnDCode
.
TabIndex
=
11
;
this
.
btnDCode
.
TabIndex
=
11
;
...
@@ -174,7 +146,7 @@
...
@@ -174,7 +146,7 @@
// btnClearLog
// btnClearLog
//
//
this
.
btnClearLog
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnClearLog
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnClearLog
.
Location
=
new
System
.
Drawing
.
Point
(
711
,
50
);
this
.
btnClearLog
.
Location
=
new
System
.
Drawing
.
Point
(
711
,
49
);
this
.
btnClearLog
.
Name
=
"btnClearLog"
;
this
.
btnClearLog
.
Name
=
"btnClearLog"
;
this
.
btnClearLog
.
Size
=
new
System
.
Drawing
.
Size
(
116
,
33
);
this
.
btnClearLog
.
Size
=
new
System
.
Drawing
.
Size
(
116
,
33
);
this
.
btnClearLog
.
TabIndex
=
12
;
this
.
btnClearLog
.
TabIndex
=
12
;
...
@@ -209,7 +181,7 @@
...
@@ -209,7 +181,7 @@
"18"
,
"18"
,
"19"
,
"19"
,
"20"
});
"20"
});
this
.
cmbCount
.
Location
=
new
System
.
Drawing
.
Point
(
334
,
16
);
this
.
cmbCount
.
Location
=
new
System
.
Drawing
.
Point
(
334
,
53
);
this
.
cmbCount
.
Name
=
"cmbCount"
;
this
.
cmbCount
.
Name
=
"cmbCount"
;
this
.
cmbCount
.
Size
=
new
System
.
Drawing
.
Size
(
66
,
25
);
this
.
cmbCount
.
Size
=
new
System
.
Drawing
.
Size
(
66
,
25
);
this
.
cmbCount
.
TabIndex
=
16
;
this
.
cmbCount
.
TabIndex
=
16
;
...
@@ -217,7 +189,7 @@
...
@@ -217,7 +189,7 @@
// lblCount
// lblCount
//
//
this
.
lblCount
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblCount
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblCount
.
Location
=
new
System
.
Drawing
.
Point
(
157
,
20
);
this
.
lblCount
.
Location
=
new
System
.
Drawing
.
Point
(
157
,
57
);
this
.
lblCount
.
Name
=
"lblCount"
;
this
.
lblCount
.
Name
=
"lblCount"
;
this
.
lblCount
.
Size
=
new
System
.
Drawing
.
Size
(
171
,
17
);
this
.
lblCount
.
Size
=
new
System
.
Drawing
.
Size
(
171
,
17
);
this
.
lblCount
.
TabIndex
=
15
;
this
.
lblCount
.
TabIndex
=
15
;
...
@@ -227,7 +199,7 @@
...
@@ -227,7 +199,7 @@
// btnCameraImage
// btnCameraImage
//
//
this
.
btnCameraImage
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnCameraImage
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnCameraImage
.
Location
=
new
System
.
Drawing
.
Point
(
10
,
50
);
this
.
btnCameraImage
.
Location
=
new
System
.
Drawing
.
Point
(
10
,
49
);
this
.
btnCameraImage
.
Name
=
"btnCameraImage"
;
this
.
btnCameraImage
.
Name
=
"btnCameraImage"
;
this
.
btnCameraImage
.
Size
=
new
System
.
Drawing
.
Size
(
141
,
33
);
this
.
btnCameraImage
.
Size
=
new
System
.
Drawing
.
Size
(
141
,
33
);
this
.
btnCameraImage
.
TabIndex
=
17
;
this
.
btnCameraImage
.
TabIndex
=
17
;
...
@@ -239,7 +211,7 @@
...
@@ -239,7 +211,7 @@
//
//
this
.
btnExit
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
btnExit
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
btnExit
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnExit
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnExit
.
Location
=
new
System
.
Drawing
.
Point
(
1249
,
50
);
this
.
btnExit
.
Location
=
new
System
.
Drawing
.
Point
(
1249
,
49
);
this
.
btnExit
.
Name
=
"btnExit"
;
this
.
btnExit
.
Name
=
"btnExit"
;
this
.
btnExit
.
Size
=
new
System
.
Drawing
.
Size
(
109
,
33
);
this
.
btnExit
.
Size
=
new
System
.
Drawing
.
Size
(
109
,
33
);
this
.
btnExit
.
TabIndex
=
18
;
this
.
btnExit
.
TabIndex
=
18
;
...
@@ -263,7 +235,7 @@
...
@@ -263,7 +235,7 @@
this
.
cmbCamera
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
cmbCamera
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
cmbCamera
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
cmbCamera
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
cmbCamera
.
FormattingEnabled
=
true
;
this
.
cmbCamera
.
FormattingEnabled
=
true
;
this
.
cmbCamera
.
Location
=
new
System
.
Drawing
.
Point
(
334
,
5
4
);
this
.
cmbCamera
.
Location
=
new
System
.
Drawing
.
Point
(
334
,
1
4
);
this
.
cmbCamera
.
Name
=
"cmbCamera"
;
this
.
cmbCamera
.
Name
=
"cmbCamera"
;
this
.
cmbCamera
.
Size
=
new
System
.
Drawing
.
Size
(
326
,
25
);
this
.
cmbCamera
.
Size
=
new
System
.
Drawing
.
Size
(
326
,
25
);
this
.
cmbCamera
.
TabIndex
=
21
;
this
.
cmbCamera
.
TabIndex
=
21
;
...
@@ -271,7 +243,7 @@
...
@@ -271,7 +243,7 @@
// label2
// label2
//
//
this
.
label2
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label2
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label2
.
Location
=
new
System
.
Drawing
.
Point
(
157
,
5
8
);
this
.
label2
.
Location
=
new
System
.
Drawing
.
Point
(
157
,
1
8
);
this
.
label2
.
Name
=
"label2"
;
this
.
label2
.
Name
=
"label2"
;
this
.
label2
.
Size
=
new
System
.
Drawing
.
Size
(
171
,
17
);
this
.
label2
.
Size
=
new
System
.
Drawing
.
Size
(
171
,
17
);
this
.
label2
.
TabIndex
=
20
;
this
.
label2
.
TabIndex
=
20
;
...
@@ -283,7 +255,7 @@
...
@@ -283,7 +255,7 @@
this
.
cmbCodeType
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
cmbCodeType
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
cmbCodeType
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
cmbCodeType
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
cmbCodeType
.
FormattingEnabled
=
true
;
this
.
cmbCodeType
.
FormattingEnabled
=
true
;
this
.
cmbCodeType
.
Location
=
new
System
.
Drawing
.
Point
(
506
,
16
);
this
.
cmbCodeType
.
Location
=
new
System
.
Drawing
.
Point
(
506
,
53
);
this
.
cmbCodeType
.
Name
=
"cmbCodeType"
;
this
.
cmbCodeType
.
Name
=
"cmbCodeType"
;
this
.
cmbCodeType
.
Size
=
new
System
.
Drawing
.
Size
(
154
,
25
);
this
.
cmbCodeType
.
Size
=
new
System
.
Drawing
.
Size
(
154
,
25
);
this
.
cmbCodeType
.
TabIndex
=
23
;
this
.
cmbCodeType
.
TabIndex
=
23
;
...
@@ -292,32 +264,20 @@
...
@@ -292,32 +264,20 @@
// label3
// label3
//
//
this
.
label3
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label3
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label3
.
Location
=
new
System
.
Drawing
.
Point
(
378
,
20
);
this
.
label3
.
Location
=
new
System
.
Drawing
.
Point
(
378
,
57
);
this
.
label3
.
Name
=
"label3"
;
this
.
label3
.
Name
=
"label3"
;
this
.
label3
.
Size
=
new
System
.
Drawing
.
Size
(
122
,
17
);
this
.
label3
.
Size
=
new
System
.
Drawing
.
Size
(
122
,
17
);
this
.
label3
.
TabIndex
=
22
;
this
.
label3
.
TabIndex
=
22
;
this
.
label3
.
Text
=
"条码类型:"
;
this
.
label3
.
Text
=
"条码类型:"
;
this
.
label3
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleRight
;
this
.
label3
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleRight
;
//
//
// btnAn
//
this
.
btnAn
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnAn
.
Location
=
new
System
.
Drawing
.
Point
(
645
,
50
);
this
.
btnAn
.
Name
=
"btnAn"
;
this
.
btnAn
.
Size
=
new
System
.
Drawing
.
Size
(
59
,
33
);
this
.
btnAn
.
TabIndex
=
25
;
this
.
btnAn
.
Text
=
"变暗"
;
this
.
btnAn
.
UseVisualStyleBackColor
=
true
;
this
.
btnAn
.
Visible
=
false
;
this
.
btnAn
.
Click
+=
new
System
.
EventHandler
(
this
.
btnAn_Click
);
//
// chbUseParam
// chbUseParam
//
//
this
.
chbUseParam
.
AutoSize
=
true
;
this
.
chbUseParam
.
AutoSize
=
true
;
this
.
chbUseParam
.
Checked
=
true
;
this
.
chbUseParam
.
Checked
=
true
;
this
.
chbUseParam
.
CheckState
=
System
.
Windows
.
Forms
.
CheckState
.
Checked
;
this
.
chbUseParam
.
CheckState
=
System
.
Windows
.
Forms
.
CheckState
.
Checked
;
this
.
chbUseParam
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
chbUseParam
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
chbUseParam
.
Location
=
new
System
.
Drawing
.
Point
(
711
,
1
8
);
this
.
chbUseParam
.
Location
=
new
System
.
Drawing
.
Point
(
711
,
1
6
);
this
.
chbUseParam
.
Name
=
"chbUseParam"
;
this
.
chbUseParam
.
Name
=
"chbUseParam"
;
this
.
chbUseParam
.
Size
=
new
System
.
Drawing
.
Size
(
75
,
21
);
this
.
chbUseParam
.
Size
=
new
System
.
Drawing
.
Size
(
75
,
21
);
this
.
chbUseParam
.
TabIndex
=
26
;
this
.
chbUseParam
.
TabIndex
=
26
;
...
@@ -344,34 +304,10 @@
...
@@ -344,34 +304,10 @@
this
.
label4
.
Text
=
"参数路径"
;
this
.
label4
.
Text
=
"参数路径"
;
this
.
label4
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleRight
;
this
.
label4
.
TextAlign
=
System
.
Drawing
.
ContentAlignment
.
MiddleRight
;
//
//
// btnLight
//
this
.
btnLight
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnLight
.
Location
=
new
System
.
Drawing
.
Point
(
645
,
12
);
this
.
btnLight
.
Name
=
"btnLight"
;
this
.
btnLight
.
Size
=
new
System
.
Drawing
.
Size
(
59
,
33
);
this
.
btnLight
.
TabIndex
=
24
;
this
.
btnLight
.
Text
=
"提亮"
;
this
.
btnLight
.
UseVisualStyleBackColor
=
true
;
this
.
btnLight
.
Visible
=
false
;
this
.
btnLight
.
Click
+=
new
System
.
EventHandler
(
this
.
btnLigth_Click
);
//
// button1
//
this
.
button1
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
button1
.
Location
=
new
System
.
Drawing
.
Point
(
723
,
12
);
this
.
button1
.
Name
=
"button1"
;
this
.
button1
.
Size
=
new
System
.
Drawing
.
Size
(
167
,
33
);
this
.
button1
.
TabIndex
=
29
;
this
.
button1
.
Text
=
"循环测试"
;
this
.
button1
.
UseVisualStyleBackColor
=
true
;
this
.
button1
.
Visible
=
false
;
this
.
button1
.
Click
+=
new
System
.
EventHandler
(
this
.
button1_Click
);
//
// btnScanTest
// btnScanTest
//
//
this
.
btnScanTest
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnScanTest
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnScanTest
.
Location
=
new
System
.
Drawing
.
Point
(
1069
,
1
2
);
this
.
btnScanTest
.
Location
=
new
System
.
Drawing
.
Point
(
1069
,
1
0
);
this
.
btnScanTest
.
Name
=
"btnScanTest"
;
this
.
btnScanTest
.
Name
=
"btnScanTest"
;
this
.
btnScanTest
.
Size
=
new
System
.
Drawing
.
Size
(
167
,
33
);
this
.
btnScanTest
.
Size
=
new
System
.
Drawing
.
Size
(
167
,
33
);
this
.
btnScanTest
.
TabIndex
=
30
;
this
.
btnScanTest
.
TabIndex
=
30
;
...
@@ -379,18 +315,27 @@
...
@@ -379,18 +315,27 @@
this
.
btnScanTest
.
UseVisualStyleBackColor
=
true
;
this
.
btnScanTest
.
UseVisualStyleBackColor
=
true
;
this
.
btnScanTest
.
Click
+=
new
System
.
EventHandler
(
this
.
btnScanTest_Click
);
this
.
btnScanTest
.
Click
+=
new
System
.
EventHandler
(
this
.
btnScanTest_Click
);
//
//
// chbZxing
//
this
.
chbZxing
.
AutoSize
=
true
;
this
.
chbZxing
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
chbZxing
.
Location
=
new
System
.
Drawing
.
Point
(
820
,
16
);
this
.
chbZxing
.
Name
=
"chbZxing"
;
this
.
chbZxing
.
Size
=
new
System
.
Drawing
.
Size
(
60
,
21
);
this
.
chbZxing
.
TabIndex
=
31
;
this
.
chbZxing
.
Text
=
"ZXing"
;
this
.
chbZxing
.
UseVisualStyleBackColor
=
true
;
//
// FrmCodeDecode
// FrmCodeDecode
//
//
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleDimensions
=
new
System
.
Drawing
.
SizeF
(
6F
,
12F
);
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
AutoScaleMode
=
System
.
Windows
.
Forms
.
AutoScaleMode
.
Font
;
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1375
,
729
);
this
.
ClientSize
=
new
System
.
Drawing
.
Size
(
1375
,
729
);
this
.
Controls
.
Add
(
this
.
chbZxing
);
this
.
Controls
.
Add
(
this
.
btnScanTest
);
this
.
Controls
.
Add
(
this
.
btnScanTest
);
this
.
Controls
.
Add
(
this
.
button1
);
this
.
Controls
.
Add
(
this
.
txtParamPath
);
this
.
Controls
.
Add
(
this
.
txtParamPath
);
this
.
Controls
.
Add
(
this
.
label4
);
this
.
Controls
.
Add
(
this
.
label4
);
this
.
Controls
.
Add
(
this
.
chbUseParam
);
this
.
Controls
.
Add
(
this
.
chbUseParam
);
this
.
Controls
.
Add
(
this
.
btnAn
);
this
.
Controls
.
Add
(
this
.
btnLight
);
this
.
Controls
.
Add
(
this
.
cmbCodeType
);
this
.
Controls
.
Add
(
this
.
cmbCodeType
);
this
.
Controls
.
Add
(
this
.
cmbCamera
);
this
.
Controls
.
Add
(
this
.
cmbCamera
);
this
.
Controls
.
Add
(
this
.
label2
);
this
.
Controls
.
Add
(
this
.
label2
);
...
@@ -403,8 +348,6 @@
...
@@ -403,8 +348,6 @@
this
.
Controls
.
Add
(
this
.
btnLearn
);
this
.
Controls
.
Add
(
this
.
btnLearn
);
this
.
Controls
.
Add
(
this
.
btnbarCode
);
this
.
Controls
.
Add
(
this
.
btnbarCode
);
this
.
Controls
.
Add
(
this
.
hWindowControl1
);
this
.
Controls
.
Add
(
this
.
hWindowControl1
);
this
.
Controls
.
Add
(
this
.
btnGray
);
this
.
Controls
.
Add
(
this
.
btnErZhi
);
this
.
Controls
.
Add
(
this
.
txtResult
);
this
.
Controls
.
Add
(
this
.
txtResult
);
this
.
Controls
.
Add
(
this
.
pictureBox1
);
this
.
Controls
.
Add
(
this
.
pictureBox1
);
this
.
Controls
.
Add
(
this
.
btnSelImage
);
this
.
Controls
.
Add
(
this
.
btnSelImage
);
...
@@ -430,8 +373,6 @@
...
@@ -430,8 +373,6 @@
private
System
.
Windows
.
Forms
.
Button
btnSelImage
;
private
System
.
Windows
.
Forms
.
Button
btnSelImage
;
private
System
.
Windows
.
Forms
.
PictureBox
pictureBox1
;
private
System
.
Windows
.
Forms
.
PictureBox
pictureBox1
;
private
System
.
Windows
.
Forms
.
TextBox
txtResult
;
private
System
.
Windows
.
Forms
.
TextBox
txtResult
;
private
System
.
Windows
.
Forms
.
Button
btnErZhi
;
private
System
.
Windows
.
Forms
.
Button
btnGray
;
private
HalconDotNet
.
HWindowControl
hWindowControl1
;
private
HalconDotNet
.
HWindowControl
hWindowControl1
;
private
System
.
Windows
.
Forms
.
Button
btnbarCode
;
private
System
.
Windows
.
Forms
.
Button
btnbarCode
;
private
System
.
Windows
.
Forms
.
Button
btnLearn
;
private
System
.
Windows
.
Forms
.
Button
btnLearn
;
...
@@ -446,13 +387,11 @@
...
@@ -446,13 +387,11 @@
private
System
.
Windows
.
Forms
.
Label
label2
;
private
System
.
Windows
.
Forms
.
Label
label2
;
private
System
.
Windows
.
Forms
.
ComboBox
cmbCodeType
;
private
System
.
Windows
.
Forms
.
ComboBox
cmbCodeType
;
private
System
.
Windows
.
Forms
.
Label
label3
;
private
System
.
Windows
.
Forms
.
Label
label3
;
private
System
.
Windows
.
Forms
.
Button
btnAn
;
private
System
.
Windows
.
Forms
.
CheckBox
chbUseParam
;
private
System
.
Windows
.
Forms
.
CheckBox
chbUseParam
;
private
System
.
Windows
.
Forms
.
TextBox
txtParamPath
;
private
System
.
Windows
.
Forms
.
TextBox
txtParamPath
;
private
System
.
Windows
.
Forms
.
Label
label4
;
private
System
.
Windows
.
Forms
.
Label
label4
;
private
System
.
Windows
.
Forms
.
Button
btnLight
;
private
System
.
Windows
.
Forms
.
Button
button1
;
private
System
.
Windows
.
Forms
.
Button
btnScanTest
;
private
System
.
Windows
.
Forms
.
Button
btnScanTest
;
private
System
.
Windows
.
Forms
.
CheckBox
chbZxing
;
}
}
}
}
CodeLibraryProject/CodeLibrary/FrmCodeDecode.cs
查看文件 @
fee2767
...
@@ -71,9 +71,7 @@ namespace CodeLibrary
...
@@ -71,9 +71,7 @@ namespace CodeLibrary
}
}
}
}
private
void
LoadCamera
()
private
void
LoadCamera
()
{
{
// string[] camerName = BaslerCamera.Instance.CameraName;
// baslerNameList.AddRange(camerName);
cmbCamera
.
Items
.
Clear
();
cmbCamera
.
Items
.
Clear
();
Camera
.
Type
=
CameraType
.
HIK
;
Camera
.
Type
=
CameraType
.
HIK
;
Camera
.
_cam
.
Load
();
Camera
.
_cam
.
Load
();
...
@@ -81,13 +79,7 @@ namespace CodeLibrary
...
@@ -81,13 +79,7 @@ namespace CodeLibrary
{
{
cmbCamera
.
Items
.
Add
(
str
);
cmbCamera
.
Items
.
Add
(
str
);
}
}
//camerName = HIKCamera.Instance.CameraName;
//hikNameList.AddRange(camerName);
//foreach (string str in camerName)
//{
// cmbCamera.Items.Add(str);
//}
if
(
cmbCamera
.
Items
.
Count
>
0
)
if
(
cmbCamera
.
Items
.
Count
>
0
)
{
{
cmbCamera
.
SelectedIndex
=
0
;
cmbCamera
.
SelectedIndex
=
0
;
...
@@ -115,6 +107,10 @@ namespace CodeLibrary
...
@@ -115,6 +107,10 @@ namespace CodeLibrary
//读取图片内容
//读取图片内容
Image
img
=
(
Image
)
Image
.
FromFile
(
filename
).
Clone
();
Image
img
=
(
Image
)
Image
.
FromFile
(
filename
).
Clone
();
pictureBox1
.
Image
=
img
;
pictureBox1
.
Image
=
img
;
Bitmap
bitmap
=
new
Bitmap
(
pictureBox1
.
Image
);
HObject
hoimg
=
HDCodeHelper
.
Bitmap2HObjectBpp24
(
bitmap
);
HDCodeLearnHelper
.
DefaultImage
=
hoimg
;
ShowImage
(
hoimg
);
}
}
private
void
btnErZhi_Click
(
object
sender
,
EventArgs
e
)
private
void
btnErZhi_Click
(
object
sender
,
EventArgs
e
)
...
@@ -158,8 +154,8 @@ namespace CodeLibrary
...
@@ -158,8 +154,8 @@ namespace CodeLibrary
}
}
private
void
btnbarCode_Click
(
object
sender
,
EventArgs
e
)
private
void
btnbarCode_Click
(
object
sender
,
EventArgs
e
)
{
{
if
(
pictureBox1
.
Image
==
null
)
if
(
HDCodeLearnHelper
.
Default
Image
==
null
)
{
{
MessageBox
.
Show
(
selImage
,
title
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
MessageBox
.
Show
(
selImage
,
title
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
return
;
return
;
...
@@ -168,14 +164,20 @@ namespace CodeLibrary
...
@@ -168,14 +164,20 @@ namespace CodeLibrary
txtResult
.
Text
=
""
;
txtResult
.
Text
=
""
;
stopwatch
.
Restart
();
stopwatch
.
Restart
();
HDCodeHelper
.
HalconWindow
=
this
.
hWindowControl1
.
HalconWindow
;
HDCodeHelper
.
HalconWindow
=
this
.
hWindowControl1
.
HalconWindow
;
Bitmap
map
=
new
Bitmap
(
pictureBox1
.
Image
);
//if (chbZxing.Checked)
if
(
chbZxing
.
Checked
)
//{
{
// zxingDecode(map, "barcode");
if
(
pictureBox1
.
Image
==
null
)
//}
{
//else
MessageBox
.
Show
(
selImage
,
title
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
return
;
}
Bitmap
map
=
new
Bitmap
(
pictureBox1
.
Image
);
zxingDecode
(
map
,
"barcode"
);
}
else
{
{
List
<
CodeInfo
>
result
=
HDCodeHelper
.
DecodeBarCode
(
map
);
List
<
CodeInfo
>
result
=
HDCodeHelper
.
DecodeBarCode
(
HDCodeLearnHelper
.
DefaultImage
);
ShowCode
(
result
);
ShowCode
(
result
);
txtResult
.
Text
+=
"\r\n elapsed time:"
+
stopwatch
.
Elapsed
.
ToString
();
txtResult
.
Text
+=
"\r\n elapsed time:"
+
stopwatch
.
Elapsed
.
ToString
();
}
}
...
@@ -198,66 +200,64 @@ namespace CodeLibrary
...
@@ -198,66 +200,64 @@ namespace CodeLibrary
}
}
private
void
btnDCode_Click
(
object
sender
,
EventArgs
e
)
private
void
btnDCode_Click
(
object
sender
,
EventArgs
e
)
{
{
if
(
pictureBox1
.
Image
==
null
)
{
MessageBox
.
Show
(
selImage
,
title
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
return
;
}
int
count
=
cmbCount
.
SelectedIndex
;
int
count
=
cmbCount
.
SelectedIndex
;
txtResult
.
Text
=
""
;
txtResult
.
Text
=
""
;
stopwatch
.
Restart
();
stopwatch
.
Restart
();
Bitmap
map
=
new
Bitmap
(
pictureBox1
.
Image
);
//
Bitmap map = new Bitmap(pictureBox1.Image);
HObject
ho_image
=
HDCodeHelper
.
Bitmap2HObjectBpp24
(
map
);
//
HObject ho_image = HDCodeHelper.Bitmap2HObjectBpp24(map);
txtResult
.
Text
+=
"\r\n elapsed time:"
+
stopwatch
.
Elapsed
.
ToString
();
txtResult
.
Text
+=
"\r\n elapsed time:"
+
stopwatch
.
Elapsed
.
ToString
();
hWindowControl1
.
HalconWindow
.
SetPart
(
0
,
0
,
map
.
Height
,
map
.
Width
);
//
hWindowControl1.HalconWindow.SetPart(0, 0, map.Height, map.Width);
HOperatorSet
.
DispObj
(
ho_image
,
hWindowControl1
.
HalconWindow
);
//
HOperatorSet.DispObj(ho_image, hWindowControl1.HalconWindow);
ShowImage
(
ho_image
);
//
ShowImage(ho_image);
HDCodeHelper
.
HalconWindow
=
this
.
hWindowControl1
.
HalconWindow
;
HDCodeHelper
.
HalconWindow
=
this
.
hWindowControl1
.
HalconWindow
;
string
codeParamPath
=
HDCodeHelper
.
GetCodeParamFilePath
(
cmbCodeType
.
Text
);
string
codeParamPath
=
HDCodeHelper
.
GetCodeParamFilePath
(
cmbCodeType
.
Text
);
if
(
chbUseParam
.
Checked
.
Equals
(
false
))
if
(
chbUseParam
.
Checked
.
Equals
(
false
))
{
{
codeParamPath
=
""
;
codeParamPath
=
""
;
}
}
//if (chbZxing.Checked)
if
(
chbZxing
.
Checked
)
//{
// zxingDecode(map, cmbCodeType.Text);
//}
//else
{
{
if
(
pictureBox1
.
Image
==
null
)
{
MessageBox
.
Show
(
selImage
,
title
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
return
;
}
Bitmap
map
=
new
Bitmap
(
pictureBox1
.
Image
);
zxingDecode
(
map
,
cmbCodeType
.
Text
);
}
else
{
if
(
HDCodeLearnHelper
.
DefaultImage
==
null
)
{
MessageBox
.
Show
(
selImage
,
title
,
MessageBoxButtons
.
OK
,
MessageBoxIcon
.
Error
);
return
;
}
List
<
CodeInfo
>
codeList
=
new
List
<
CodeInfo
>();
List
<
CodeInfo
>
codeList
=
new
List
<
CodeInfo
>();
if
(
cmbCodeType
.
Text
.
ToLower
().
Equals
(
"barcode"
))
if
(
cmbCodeType
.
Text
.
ToLower
().
Equals
(
"barcode"
))
{
{
codeList
=
HDCodeHelper
.
DecodeBarCode
(
ho_i
mage
);
codeList
=
HDCodeHelper
.
DecodeBarCode
(
HDCodeLearnHelper
.
DefaultI
mage
);
}
}
else
else
{
{
codeList
=
HDCodeHelper
.
DecodeCode
(
ho_image
,
count
,
codeParamPath
,
cmbCodeType
.
Text
);
codeList
=
HDCodeHelper
.
DecodeCode
(
HDCodeLearnHelper
.
DefaultImage
,
count
,
codeParamPath
,
cmbCodeType
.
Text
);
}
//if (codeList.Count <= 0)
//{
// zxingDecode(map, cmbCodeType.Text);
//}
//else
{
ShowCode
(
codeList
);
txtResult
.
Text
+=
"\r\n elapsed time:"
+
stopwatch
.
Elapsed
.
ToString
();
}
}
ShowCode
(
codeList
);
txtResult
.
Text
+=
"\r\n elapsed time:"
+
stopwatch
.
Elapsed
.
ToString
();
}
}
}
}
private
void
zxingDecode
(
Bitmap
map
,
string
type
)
private
void
zxingDecode
(
Bitmap
map
,
string
type
)
{
{
//
List<string> results = ZXingCodeHelper.DeCodes(map, type);
List
<
string
>
results
=
ZXingCodeHelper
.
DeCodes
(
map
,
type
);
//
txtResult.Text = " zxing decode:";
txtResult
.
Text
=
" zxing decode:"
;
//
foreach (string code in results)
foreach
(
string
code
in
results
)
//
{
{
//
txtResult.Text += "\r\n" + "\r\n" + code;
txtResult
.
Text
+=
"\r\n"
+
"\r\n"
+
code
;
//
}
}
//
txtResult.Text += "\r\n \r\n elapsed time:" + stopwatch.Elapsed.ToString();
txtResult
.
Text
+=
"\r\n \r\n elapsed time:"
+
stopwatch
.
Elapsed
.
ToString
();
}
}
private
void
btnClearLog_Click
(
object
sender
,
EventArgs
e
)
private
void
btnClearLog_Click
(
object
sender
,
EventArgs
e
)
...
@@ -265,7 +265,7 @@ namespace CodeLibrary
...
@@ -265,7 +265,7 @@ namespace CodeLibrary
HDLogUtil
.
ClearLog
();
HDLogUtil
.
ClearLog
();
txtResult
.
Text
=
""
;
txtResult
.
Text
=
""
;
}
}
private
Bitmap
GetCameraBitmap
()
private
HObject
GetCameraBitmap
()
{
{
try
try
{
{
...
@@ -276,27 +276,11 @@ namespace CodeLibrary
...
@@ -276,27 +276,11 @@ namespace CodeLibrary
MessageBox
.
Show
(
selCamera
);
MessageBox
.
Show
(
selCamera
);
return
null
;
return
null
;
}
}
//if (baslerNameList.Contains(camerName))
HObject
map
=
Camera
.
_cam
.
CaptureOnImage
(
camerName
);
//{
// BaslerCamera.Instance.Open(camerName);
// BaslerCamera.Instance.GrabOne();
// Bitmap bitmap = BaslerCamera.Instance.Image;
// BaslerCamera.Instance.Close();
// return bitmap;
//}
//else
//{
// HIKCamera.Instance.Open(camerName);
// HIKCamera.Instance.GrabOne();
// Bitmap bitmap = HIKCamera.Instance.Image;
// HIKCamera.Instance.Close();
// return bitmap;
//}
Bitmap
map
=
Camera
.
_cam
.
GrabOneImage
(
camerName
);
if
(
map
==
null
)
if
(
map
==
null
)
{
{
Camera
.
_cam
.
Close
(
camerName
);
Camera
.
_cam
.
Close
(
camerName
);
map
=
Camera
.
_cam
.
GrabOne
Image
(
camerName
);
map
=
Camera
.
_cam
.
CaptureOn
Image
(
camerName
);
}
}
return
map
;
return
map
;
}
}
...
@@ -310,14 +294,38 @@ namespace CodeLibrary
...
@@ -310,14 +294,38 @@ namespace CodeLibrary
{
{
try
try
{
{
Bitmap
bitmap
=
GetCameraBitmap
();
if
(!
chbZxing
.
Checked
)
if
(
bitmap
!=
null
)
{
HObject
bitmap
=
GetCameraBitmap
();
if
(
bitmap
!=
null
)
{
HDLogUtil
.
info
(
"从相机【"
+
cmbCamera
.
Text
+
"】获取到一张图片"
);
ClearPicImg
();
//pictureBox1.Image = (Image)bitmap.Clone();
//HObject hoImage = HDCodeHelper.Bitmap2HObjectBpp24(bitmap);
HDCodeLearnHelper
.
DefaultImage
=
bitmap
;
ShowImage
(
bitmap
);
}
}
else
{
{
HDLogUtil
.
info
(
"从相机【"
+
cmbCamera
.
Text
+
"】获取到一张图片"
);
int
index
=
cmbCamera
.
SelectedIndex
;
ClearPicImg
();
string
camerName
=
cmbCamera
.
Text
;
pictureBox1
.
Image
=
(
Image
)
bitmap
.
Clone
();
if
(
index
<
0
)
//HObject hoImage = HDCodeHelper.Bitmap2HObjectBpp24(bitmap);
{
//HDCodeLearnHelper.DefaultImage = hoImage;
MessageBox
.
Show
(
selCamera
);
return
;
}
Bitmap
bitmap
=
Camera
.
_cam
.
GrabOneImage
(
camerName
);
if
(
bitmap
!=
null
)
{
HDLogUtil
.
info
(
"从相机【"
+
cmbCamera
.
Text
+
"】获取到一张图片"
);
ClearPicImg
();
pictureBox1
.
Image
=
(
Image
)
bitmap
.
Clone
();
////HObject hoImage = HDCodeHelper.Bitmap2HObjectBpp24(bitmap);
//HDCodeLearnHelper.DefaultImage = bitmap;
//ShowImage(bitmap);
}
}
}
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
...
@@ -432,56 +440,9 @@ namespace CodeLibrary
...
@@ -432,56 +440,9 @@ namespace CodeLibrary
{
{
Camera
.
_cam
.
CloseAll
();
Camera
.
_cam
.
CloseAll
();
}
}
//private void btnScanTest_Click(object sender, EventArgs e)
//{
// Image img = (Image)Image.FromFile(@"E:\GigE-MV-CE200-10GC (00E06252332)\16-05-15-984.bmp").Clone();
// using (Bitmap bitmap = new Bitmap(img))
// //using (Bitmap bitmap = GetCameraBitmap())
// {
// if (bitmap != null)
// {
// System.Threading.Thread.Sleep(1);
// //转换托盘大概100-150ms,不打印日志
// HalconDotNet.HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bitmap);
// // LogUtil.info(" 相机【" + cameraName + "】转换图片完成,开始扫码");
// List<CodeInfo> cc = new List<CodeInfo>();
// string str = "";
// List<string> codeTypeList = new List<string>(HDCodeLearnHelper.codeTypeList);
// string r = "";
// int count = cmbCount.SelectedIndex;
// foreach (string codeType in codeTypeList)
// {
// //判断是否是一维码
// if (codeType.ToLower().Equals("barcode"))
// {
// cc = HDCodeHelper.DecodeBarCode(ho_Image);
// }
// else
// {
// string codeParamPath = HDCodeHelper.GetCodeParamFilePath(codeType);
// cc = HDCodeHelper.DecodeCode(ho_Image, count, codeParamPath, codeType);
// }
// foreach (CodeInfo c in cc)
// {
// r += (c.CodeStr) + "##";
// }
// }
// MessageBox.Show(r);
// // ShowCode(cc);
// ho_Image.Dispose();
// bitmap.Dispose();
// }
// }
//}
private
void
btnScanTest_Click
(
object
sender
,
EventArgs
e
)
private
void
btnScanTest_Click
(
object
sender
,
EventArgs
e
)
{
{
//using (Bitmap bitmap = GetCameraBitmap())
//{
// if (bitmap != null)
// { int index = cmbCamera.SelectedIndex;
string
camerName
=
cmbCamera
.
Text
;
string
camerName
=
cmbCamera
.
Text
;
if
(
cmbCamera
.
SelectedIndex
<
0
)
if
(
cmbCamera
.
SelectedIndex
<
0
)
{
{
...
@@ -489,10 +450,7 @@ namespace CodeLibrary
...
@@ -489,10 +450,7 @@ namespace CodeLibrary
return
;
return
;
}
}
HDLogUtil
.
info
(
"获取图片完成,开始转换图片,并扫码"
);
HDLogUtil
.
info
(
"获取图片完成,开始转换图片,并扫码"
);
//System.Threading.Thread.Sleep(1);
////转换托盘大概100-150ms,不打印日志
//Bitmap bit = new Bitmap(bitmap);
//HalconDotNet.HObject ho_Image = HDCodeHelper.Bitmap2HObjectBpp24(bit);
HObject
ho_Image
=
Camera
.
_cam
.
CaptureOnImage
(
camerName
);
HObject
ho_Image
=
Camera
.
_cam
.
CaptureOnImage
(
camerName
);
HDLogUtil
.
info
(
" 相机【"
+
camerName
+
"】转换图片完成,开始扫码"
);
HDLogUtil
.
info
(
" 相机【"
+
camerName
+
"】转换图片完成,开始扫码"
);
List
<
CodeInfo
>
cc
=
new
List
<
CodeInfo
>();
List
<
CodeInfo
>
cc
=
new
List
<
CodeInfo
>();
...
@@ -517,13 +475,8 @@ namespace CodeLibrary
...
@@ -517,13 +475,8 @@ namespace CodeLibrary
r
+=
(
c
.
CodeStr
)
+
"##"
;
r
+=
(
c
.
CodeStr
)
+
"##"
;
}
}
}
}
MessageBox
.
Show
(
r
);
MessageBox
.
Show
(
r
);
// ShowCode(cc);
ho_Image
.
Dispose
();
ho_Image
.
Dispose
();
//bitmap.Dispose();
// }
//}
}
}
private
void
btnCopyN_Click
(
object
sender
,
EventArgs
e
)
private
void
btnCopyN_Click
(
object
sender
,
EventArgs
e
)
...
...
CodeLibraryProject/CodeLibrary/FrmCodeLearn.Designer.cs
查看文件 @
fee2767
...
@@ -66,9 +66,9 @@
...
@@ -66,9 +66,9 @@
//
//
this
.
btnStop
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
btnStop
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
btnStop
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnStop
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnStop
.
Location
=
new
System
.
Drawing
.
Point
(
949
,
51
);
this
.
btnStop
.
Location
=
new
System
.
Drawing
.
Point
(
949
,
49
);
this
.
btnStop
.
Name
=
"btnStop"
;
this
.
btnStop
.
Name
=
"btnStop"
;
this
.
btnStop
.
Size
=
new
System
.
Drawing
.
Size
(
144
,
3
5
);
this
.
btnStop
.
Size
=
new
System
.
Drawing
.
Size
(
144
,
3
2
);
this
.
btnStop
.
TabIndex
=
3
;
this
.
btnStop
.
TabIndex
=
3
;
this
.
btnStop
.
Text
=
"结束学习"
;
this
.
btnStop
.
Text
=
"结束学习"
;
this
.
btnStop
.
UseVisualStyleBackColor
=
true
;
this
.
btnStop
.
UseVisualStyleBackColor
=
true
;
...
@@ -78,9 +78,9 @@
...
@@ -78,9 +78,9 @@
//
//
this
.
btnOpen
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
btnOpen
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
btnOpen
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnOpen
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnOpen
.
Location
=
new
System
.
Drawing
.
Point
(
949
,
1
3
);
this
.
btnOpen
.
Location
=
new
System
.
Drawing
.
Point
(
949
,
1
2
);
this
.
btnOpen
.
Name
=
"btnOpen"
;
this
.
btnOpen
.
Name
=
"btnOpen"
;
this
.
btnOpen
.
Size
=
new
System
.
Drawing
.
Size
(
144
,
3
5
);
this
.
btnOpen
.
Size
=
new
System
.
Drawing
.
Size
(
144
,
3
2
);
this
.
btnOpen
.
TabIndex
=
1
;
this
.
btnOpen
.
TabIndex
=
1
;
this
.
btnOpen
.
Text
=
"开始学习"
;
this
.
btnOpen
.
Text
=
"开始学习"
;
this
.
btnOpen
.
UseVisualStyleBackColor
=
true
;
this
.
btnOpen
.
UseVisualStyleBackColor
=
true
;
...
@@ -104,9 +104,9 @@
...
@@ -104,9 +104,9 @@
//
//
this
.
btnExit
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
btnExit
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
btnExit
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnExit
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnExit
.
Location
=
new
System
.
Drawing
.
Point
(
1096
,
51
);
this
.
btnExit
.
Location
=
new
System
.
Drawing
.
Point
(
1096
,
49
);
this
.
btnExit
.
Name
=
"btnExit"
;
this
.
btnExit
.
Name
=
"btnExit"
;
this
.
btnExit
.
Size
=
new
System
.
Drawing
.
Size
(
110
,
3
5
);
this
.
btnExit
.
Size
=
new
System
.
Drawing
.
Size
(
110
,
3
2
);
this
.
btnExit
.
TabIndex
=
6
;
this
.
btnExit
.
TabIndex
=
6
;
this
.
btnExit
.
Text
=
"退出"
;
this
.
btnExit
.
Text
=
"退出"
;
this
.
btnExit
.
UseVisualStyleBackColor
=
true
;
this
.
btnExit
.
UseVisualStyleBackColor
=
true
;
...
@@ -115,7 +115,7 @@
...
@@ -115,7 +115,7 @@
// label1
// label1
//
//
this
.
label1
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label1
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label1
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
1
9
);
this
.
label1
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
1
8
);
this
.
label1
.
Name
=
"label1"
;
this
.
label1
.
Name
=
"label1"
;
this
.
label1
.
Size
=
new
System
.
Drawing
.
Size
(
110
,
20
);
this
.
label1
.
Size
=
new
System
.
Drawing
.
Size
(
110
,
20
);
this
.
label1
.
TabIndex
=
7
;
this
.
label1
.
TabIndex
=
7
;
...
@@ -138,16 +138,16 @@
...
@@ -138,16 +138,16 @@
this
.
cmbCodeType
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
cmbCodeType
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
cmbCodeType
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
cmbCodeType
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
cmbCodeType
.
FormattingEnabled
=
true
;
this
.
cmbCodeType
.
FormattingEnabled
=
true
;
this
.
cmbCodeType
.
Location
=
new
System
.
Drawing
.
Point
(
1
31
,
53
);
this
.
cmbCodeType
.
Location
=
new
System
.
Drawing
.
Point
(
1
17
,
53
);
this
.
cmbCodeType
.
Name
=
"cmbCodeType"
;
this
.
cmbCodeType
.
Name
=
"cmbCodeType"
;
this
.
cmbCodeType
.
Size
=
new
System
.
Drawing
.
Size
(
1
86
,
25
);
this
.
cmbCodeType
.
Size
=
new
System
.
Drawing
.
Size
(
1
63
,
25
);
this
.
cmbCodeType
.
TabIndex
=
10
;
this
.
cmbCodeType
.
TabIndex
=
10
;
this
.
cmbCodeType
.
SelectedIndexChanged
+=
new
System
.
EventHandler
(
this
.
cmbCodeType_SelectedIndexChanged
);
this
.
cmbCodeType
.
SelectedIndexChanged
+=
new
System
.
EventHandler
(
this
.
cmbCodeType_SelectedIndexChanged
);
//
//
// label2
// label2
//
//
this
.
label2
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label2
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
label2
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
5
7
);
this
.
label2
.
Location
=
new
System
.
Drawing
.
Point
(
3
,
5
5
);
this
.
label2
.
Name
=
"label2"
;
this
.
label2
.
Name
=
"label2"
;
this
.
label2
.
Size
=
new
System
.
Drawing
.
Size
(
110
,
20
);
this
.
label2
.
Size
=
new
System
.
Drawing
.
Size
(
110
,
20
);
this
.
label2
.
TabIndex
=
9
;
this
.
label2
.
TabIndex
=
9
;
...
@@ -177,7 +177,7 @@
...
@@ -177,7 +177,7 @@
// lblCount
// lblCount
//
//
this
.
lblCount
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblCount
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
lblCount
.
Location
=
new
System
.
Drawing
.
Point
(
323
,
58
);
this
.
lblCount
.
Location
=
new
System
.
Drawing
.
Point
(
286
,
55
);
this
.
lblCount
.
Name
=
"lblCount"
;
this
.
lblCount
.
Name
=
"lblCount"
;
this
.
lblCount
.
Size
=
new
System
.
Drawing
.
Size
(
112
,
20
);
this
.
lblCount
.
Size
=
new
System
.
Drawing
.
Size
(
112
,
20
);
this
.
lblCount
.
TabIndex
=
13
;
this
.
lblCount
.
TabIndex
=
13
;
...
@@ -210,7 +210,7 @@
...
@@ -210,7 +210,7 @@
"18"
,
"18"
,
"19"
,
"19"
,
"20"
});
"20"
});
this
.
cmbCount
.
Location
=
new
System
.
Drawing
.
Point
(
4
41
,
54
);
this
.
cmbCount
.
Location
=
new
System
.
Drawing
.
Point
(
4
04
,
53
);
this
.
cmbCount
.
Name
=
"cmbCount"
;
this
.
cmbCount
.
Name
=
"cmbCount"
;
this
.
cmbCount
.
Size
=
new
System
.
Drawing
.
Size
(
64
,
25
);
this
.
cmbCount
.
Size
=
new
System
.
Drawing
.
Size
(
64
,
25
);
this
.
cmbCount
.
TabIndex
=
14
;
this
.
cmbCount
.
TabIndex
=
14
;
...
@@ -228,9 +228,9 @@
...
@@ -228,9 +228,9 @@
//
//
this
.
btnClearLog
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
btnClearLog
.
Anchor
=
((
System
.
Windows
.
Forms
.
AnchorStyles
)((
System
.
Windows
.
Forms
.
AnchorStyles
.
Top
|
System
.
Windows
.
Forms
.
AnchorStyles
.
Right
)));
this
.
btnClearLog
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnClearLog
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnClearLog
.
Location
=
new
System
.
Drawing
.
Point
(
1096
,
1
3
);
this
.
btnClearLog
.
Location
=
new
System
.
Drawing
.
Point
(
1096
,
1
2
);
this
.
btnClearLog
.
Name
=
"btnClearLog"
;
this
.
btnClearLog
.
Name
=
"btnClearLog"
;
this
.
btnClearLog
.
Size
=
new
System
.
Drawing
.
Size
(
110
,
3
5
);
this
.
btnClearLog
.
Size
=
new
System
.
Drawing
.
Size
(
110
,
3
2
);
this
.
btnClearLog
.
TabIndex
=
16
;
this
.
btnClearLog
.
TabIndex
=
16
;
this
.
btnClearLog
.
Text
=
"清理日志"
;
this
.
btnClearLog
.
Text
=
"清理日志"
;
this
.
btnClearLog
.
UseVisualStyleBackColor
=
true
;
this
.
btnClearLog
.
UseVisualStyleBackColor
=
true
;
...
@@ -242,7 +242,7 @@
...
@@ -242,7 +242,7 @@
this
.
chbTest
.
Checked
=
true
;
this
.
chbTest
.
Checked
=
true
;
this
.
chbTest
.
CheckState
=
System
.
Windows
.
Forms
.
CheckState
.
Checked
;
this
.
chbTest
.
CheckState
=
System
.
Windows
.
Forms
.
CheckState
.
Checked
;
this
.
chbTest
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
chbTest
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
chbTest
.
Location
=
new
System
.
Drawing
.
Point
(
53
1
,
56
);
this
.
chbTest
.
Location
=
new
System
.
Drawing
.
Point
(
53
2
,
55
);
this
.
chbTest
.
Name
=
"chbTest"
;
this
.
chbTest
.
Name
=
"chbTest"
;
this
.
chbTest
.
Size
=
new
System
.
Drawing
.
Size
(
147
,
21
);
this
.
chbTest
.
Size
=
new
System
.
Drawing
.
Size
(
147
,
21
);
this
.
chbTest
.
TabIndex
=
17
;
this
.
chbTest
.
TabIndex
=
17
;
...
@@ -253,7 +253,7 @@
...
@@ -253,7 +253,7 @@
// btnSelImage
// btnSelImage
//
//
this
.
btnSelImage
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnSelImage
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnSelImage
.
Location
=
new
System
.
Drawing
.
Point
(
783
,
1
5
);
this
.
btnSelImage
.
Location
=
new
System
.
Drawing
.
Point
(
783
,
1
2
);
this
.
btnSelImage
.
Name
=
"btnSelImage"
;
this
.
btnSelImage
.
Name
=
"btnSelImage"
;
this
.
btnSelImage
.
Size
=
new
System
.
Drawing
.
Size
(
160
,
32
);
this
.
btnSelImage
.
Size
=
new
System
.
Drawing
.
Size
(
160
,
32
);
this
.
btnSelImage
.
TabIndex
=
19
;
this
.
btnSelImage
.
TabIndex
=
19
;
...
@@ -286,7 +286,7 @@
...
@@ -286,7 +286,7 @@
//
//
this
.
chbUseCamera
.
AutoSize
=
true
;
this
.
chbUseCamera
.
AutoSize
=
true
;
this
.
chbUseCamera
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
chbUseCamera
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
chbUseCamera
.
Location
=
new
System
.
Drawing
.
Point
(
53
1
,
18
);
this
.
chbUseCamera
.
Location
=
new
System
.
Drawing
.
Point
(
53
2
,
18
);
this
.
chbUseCamera
.
Name
=
"chbUseCamera"
;
this
.
chbUseCamera
.
Name
=
"chbUseCamera"
;
this
.
chbUseCamera
.
Size
=
new
System
.
Drawing
.
Size
(
123
,
21
);
this
.
chbUseCamera
.
Size
=
new
System
.
Drawing
.
Size
(
123
,
21
);
this
.
chbUseCamera
.
TabIndex
=
21
;
this
.
chbUseCamera
.
TabIndex
=
21
;
...
@@ -297,7 +297,7 @@
...
@@ -297,7 +297,7 @@
// btnDelOld
// btnDelOld
//
//
this
.
btnDelOld
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnDelOld
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
btnDelOld
.
Location
=
new
System
.
Drawing
.
Point
(
783
,
53
);
this
.
btnDelOld
.
Location
=
new
System
.
Drawing
.
Point
(
783
,
49
);
this
.
btnDelOld
.
Name
=
"btnDelOld"
;
this
.
btnDelOld
.
Name
=
"btnDelOld"
;
this
.
btnDelOld
.
Size
=
new
System
.
Drawing
.
Size
(
160
,
32
);
this
.
btnDelOld
.
Size
=
new
System
.
Drawing
.
Size
(
160
,
32
);
this
.
btnDelOld
.
TabIndex
=
22
;
this
.
btnDelOld
.
TabIndex
=
22
;
...
@@ -320,12 +320,13 @@
...
@@ -320,12 +320,13 @@
//
//
this
.
chbHalcon
.
AutoSize
=
true
;
this
.
chbHalcon
.
AutoSize
=
true
;
this
.
chbHalcon
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
chbHalcon
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
chbHalcon
.
Location
=
new
System
.
Drawing
.
Point
(
3
44
,
19
);
this
.
chbHalcon
.
Location
=
new
System
.
Drawing
.
Point
(
3
74
,
18
);
this
.
chbHalcon
.
Name
=
"chbHalcon"
;
this
.
chbHalcon
.
Name
=
"chbHalcon"
;
this
.
chbHalcon
.
Size
=
new
System
.
Drawing
.
Size
(
115
,
21
);
this
.
chbHalcon
.
Size
=
new
System
.
Drawing
.
Size
(
115
,
21
);
this
.
chbHalcon
.
TabIndex
=
24
;
this
.
chbHalcon
.
TabIndex
=
24
;
this
.
chbHalcon
.
Text
=
"Halcon获取图片"
;
this
.
chbHalcon
.
Text
=
"Halcon获取图片"
;
this
.
chbHalcon
.
UseVisualStyleBackColor
=
true
;
this
.
chbHalcon
.
UseVisualStyleBackColor
=
true
;
this
.
chbHalcon
.
Visible
=
false
;
this
.
chbHalcon
.
CheckedChanged
+=
new
System
.
EventHandler
(
this
.
chbHalcon_CheckedChanged
);
this
.
chbHalcon
.
CheckedChanged
+=
new
System
.
EventHandler
(
this
.
chbHalcon_CheckedChanged
);
//
//
// cmbCamera
// cmbCamera
...
@@ -333,9 +334,9 @@
...
@@ -333,9 +334,9 @@
this
.
cmbCamera
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
cmbCamera
.
DropDownStyle
=
System
.
Windows
.
Forms
.
ComboBoxStyle
.
DropDownList
;
this
.
cmbCamera
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
cmbCamera
.
Font
=
new
System
.
Drawing
.
Font
(
"微软雅黑"
,
9F
,
System
.
Drawing
.
FontStyle
.
Regular
,
System
.
Drawing
.
GraphicsUnit
.
Point
,
((
byte
)(
134
)));
this
.
cmbCamera
.
FormattingEnabled
=
true
;
this
.
cmbCamera
.
FormattingEnabled
=
true
;
this
.
cmbCamera
.
Location
=
new
System
.
Drawing
.
Point
(
1
31
,
17
);
this
.
cmbCamera
.
Location
=
new
System
.
Drawing
.
Point
(
1
17
,
16
);
this
.
cmbCamera
.
Name
=
"cmbCamera"
;
this
.
cmbCamera
.
Name
=
"cmbCamera"
;
this
.
cmbCamera
.
Size
=
new
System
.
Drawing
.
Size
(
186
,
25
);
this
.
cmbCamera
.
Size
=
new
System
.
Drawing
.
Size
(
351
,
25
);
this
.
cmbCamera
.
TabIndex
=
25
;
this
.
cmbCamera
.
TabIndex
=
25
;
//
//
// FrmCodeLearn
// FrmCodeLearn
...
...
CodeLibraryProject/CodeLibrary/FrmCodeLearn.cs
查看文件 @
fee2767
...
@@ -27,32 +27,19 @@ namespace CodeLibrary
...
@@ -27,32 +27,19 @@ namespace CodeLibrary
private
string
title
=
CodeResourceControl
.
GetString
(
CodeResourceControl
.
title
,
"提示"
);
private
string
title
=
CodeResourceControl
.
GetString
(
CodeResourceControl
.
title
,
"提示"
);
private
string
imageIsNull
=
CodeResourceControl
.
GetString
(
CodeResourceControl
.
imageIsNull
,
"获取二维码图片为空"
);
private
string
imageIsNull
=
CodeResourceControl
.
GetString
(
CodeResourceControl
.
imageIsNull
,
"获取二维码图片为空"
);
private
string
sureDelete
=
CodeResourceControl
.
GetString
(
CodeResourceControl
.
sureDelete
,
"确定删除文件:"
);
private
string
sureDelete
=
CodeResourceControl
.
GetString
(
CodeResourceControl
.
sureDelete
,
"确定删除文件:"
);
private
Bitmap
GetCameraBitmap
()
private
HObject
GetCameraImg
()
{
{
Bitmap
bitmap
=
null
;
HObject
ho_image
=
null
;
//Bitmap bitmap = null;
int
index
=
cmbCamera
.
SelectedIndex
;
int
index
=
cmbCamera
.
SelectedIndex
;
string
camerName
=
cmbCamera
.
Text
;
string
camerName
=
cmbCamera
.
Text
;
if
(
index
<
0
)
if
(
index
<
0
)
{
{
MessageBox
.
Show
(
selCamera
);
MessageBox
.
Show
(
selCamera
);
return
null
;
return
null
;
}
}
//if (baslerNameList.Contains(camerName))
ho_image
=
Camera
.
_cam
.
CaptureOnImage
(
camerName
);
//{
return
ho_image
;
// BaslerCamera.Instance.Open(camerName);
// BaslerCamera.Instance.GrabOne();
// bitmap = BaslerCamera.Instance.Image;
// BaslerCamera.Instance.Close();
//}
//else
//{
// HIKCamera.Instance.Open(camerName);
// HIKCamera.Instance.GrabOne();
// bitmap = HIKCamera.Instance.Image;
// HIKCamera.Instance.Close();
//}
bitmap
=
Camera
.
_cam
.
GrabOneImage
(
camerName
);
return
bitmap
;
}
}
private
void
btnOpen_Click
(
object
sender
,
EventArgs
e
)
private
void
btnOpen_Click
(
object
sender
,
EventArgs
e
)
{
{
...
@@ -73,14 +60,16 @@ namespace CodeLibrary
...
@@ -73,14 +60,16 @@ namespace CodeLibrary
}
}
else
else
{
{
Bitmap
bitmap
=
GetCameraBitmap
();
// Bitmap bitmap = GetCameraBitmap();
if
(
bitmap
!=
null
)
HObject
ho_Image
=
GetCameraImg
();
if
(
ho_Image
!=
null
)
{
{
HDLogUtil
.
info
(
"从相机【"
+
cmbCamera
.
Text
+
"】获取到一张图片"
);
HDLogUtil
.
info
(
"从相机【"
+
cmbCamera
.
Text
+
"】获取到一张图片"
);
ClearPicImg
();
ClearPicImg
();
pictureBox1
.
Image
=
(
Image
)
bitmap
.
Clone
();
//pictureBox1.Image = (Image)bitmap.Clone();
HObject
hoImage
=
HDCodeHelper
.
Bitmap2HObjectBpp24
(
bitmap
);
//HObject hoImage = HDCodeHelper.Bitmap2HObjectBpp24(bitmap);
HDCodeLearnHelper
.
DefaultImage
=
hoImage
;
HDCodeLearnHelper
.
DefaultImage
=
ho_Image
;
ShowImage
(
ho_Image
);
}
}
else
else
{
{
...
@@ -99,6 +88,7 @@ namespace CodeLibrary
...
@@ -99,6 +88,7 @@ namespace CodeLibrary
Bitmap
bitmap
=
new
Bitmap
(
pictureBox1
.
Image
);
Bitmap
bitmap
=
new
Bitmap
(
pictureBox1
.
Image
);
HObject
Image
=
HDCodeHelper
.
Bitmap2HObjectBpp24
(
bitmap
);
HObject
Image
=
HDCodeHelper
.
Bitmap2HObjectBpp24
(
bitmap
);
HDCodeLearnHelper
.
DefaultImage
=
Image
;
HDCodeLearnHelper
.
DefaultImage
=
Image
;
ShowImage
(
Image
);
}
}
Task
.
Factory
.
StartNew
(
delegate
()
Task
.
Factory
.
StartNew
(
delegate
()
{
{
...
@@ -107,21 +97,12 @@ namespace CodeLibrary
...
@@ -107,21 +97,12 @@ namespace CodeLibrary
FormStatus
(
true
);
FormStatus
(
true
);
}
}
private
void
LoadCamera
()
private
void
LoadCamera
()
{
{
//string[] camerName = BaslerCamera.Instance.CameraName;
//baslerNameList.AddRange(camerName);
cmbCamera
.
Items
.
Clear
();
cmbCamera
.
Items
.
Clear
();
foreach
(
string
str
in
Camera
.
_cam
.
Name
)
foreach
(
string
str
in
Camera
.
_cam
.
Name
)
{
{
cmbCamera
.
Items
.
Add
(
str
);
cmbCamera
.
Items
.
Add
(
str
);
}
}
//camerName = HIKCamera.Instance.CameraName;
//hikNameList.AddRange(camerName);
//foreach (string str in camerName)
//{
// cmbCamera.Items.Add(str);
//}
if
(
cmbCamera
.
Items
.
Count
>
0
)
if
(
cmbCamera
.
Items
.
Count
>
0
)
{
{
cmbCamera
.
SelectedIndex
=
0
;
cmbCamera
.
SelectedIndex
=
0
;
...
@@ -306,5 +287,15 @@ namespace CodeLibrary
...
@@ -306,5 +287,15 @@ namespace CodeLibrary
cmbCamera
.
Visible
=
true
;
cmbCamera
.
Visible
=
true
;
}
}
}
}
public
void
ShowImage
(
HObject
ho_Image
)
{
HTuple
width
,
height
;
HOperatorSet
.
GetImageSize
(
ho_Image
,
out
width
,
out
height
);
int
dWidth
=
(
int
)
width
.
D
;
int
dHeight
=
(
int
)
height
.
D
;
this
.
hWindowControl1
.
HalconWindow
.
SetPart
(
0
,
0
,
dHeight
,
dWidth
);
HOperatorSet
.
DispObj
(
ho_Image
,
hWindowControl1
.
HalconWindow
);
}
}
}
}
}
CodeLibraryProject/CodeLibrary/HDCodeHelper.cs
查看文件 @
fee2767
...
@@ -78,9 +78,9 @@ namespace CodeLibrary
...
@@ -78,9 +78,9 @@ namespace CodeLibrary
}
}
return
codeList
;
return
codeList
;
}
}
public
static
List
<
CodeInfo
>
DecodeCode
(
HObject
ho_Image
,
string
symbolType
,
string
hv_model_path
,
int
codeCount
,
int
timeOut
=
20
00
)
public
static
List
<
CodeInfo
>
DecodeCode
(
HObject
ho_Image
,
string
symbolType
,
string
hv_model_path
,
int
codeCount
,
int
timeOut
=
15
00
)
{
{
HDLogUtil
.
info
(
" DecodeCode["
+
symbolType
+
"]["
+
hv_model_path
+
"]["
+
codeCount
+
"] 开始"
);
HDLogUtil
.
debug
(
" DecodeCode["
+
symbolType
+
"]["
+
hv_model_path
+
"]["
+
codeCount
+
"] 开始"
);
List
<
CodeInfo
>
codeList
=
new
List
<
CodeInfo
>();
List
<
CodeInfo
>
codeList
=
new
List
<
CodeInfo
>();
try
try
{
{
...
@@ -141,13 +141,13 @@ namespace CodeLibrary
...
@@ -141,13 +141,13 @@ namespace CodeLibrary
}
}
}
}
}
}
HDLogUtil
.
info
(
" DecodeCode["
+
symbolType
+
"]["
+
hv_model_path
+
"]["
+
codeCount
+
"] 结束,返回数量:"
+
codeList
.
Count
);
HDLogUtil
.
debug
(
" DecodeCode["
+
symbolType
+
"]["
+
hv_model_path
+
"]["
+
codeCount
+
"] 结束,返回数量:"
+
codeList
.
Count
);
return
codeList
;
return
codeList
;
}
}
catch
(
Exception
ex
)
catch
(
Exception
ex
)
{
{
HDLogUtil
.
error
(
"DecodeCode出错:"
+
ex
.
ToString
());
HDLogUtil
.
error
(
"DecodeCode出错:"
+
ex
.
ToString
());
HDLogUtil
.
info
(
" DecodeCode["
+
symbolType
+
"]["
+
hv_model_path
+
"]["
+
codeCount
+
"] 结束,返回数量:"
+
codeList
.
Count
);
HDLogUtil
.
debug
(
" DecodeCode["
+
symbolType
+
"]["
+
hv_model_path
+
"]["
+
codeCount
+
"] 结束,返回数量:"
+
codeList
.
Count
);
return
codeList
;
return
codeList
;
}
}
...
...
CodeLibraryProject/CodeLibrary/ZXingCodeHelper.cs
查看文件 @
fee2767
...
@@ -204,3 +204,4 @@ namespace CodeLibrary
...
@@ -204,3 +204,4 @@ namespace CodeLibrary
}
}
}
}
CodeLibraryProject/CodeLibrary/camera/Basler.cs
查看文件 @
fee2767
...
@@ -4,6 +4,7 @@ using System.Drawing;
...
@@ -4,6 +4,7 @@ using System.Drawing;
using
System.Drawing.Imaging
;
using
System.Drawing.Imaging
;
using
System.Collections.Generic
;
using
System.Collections.Generic
;
using
HalconDotNet
;
using
HalconDotNet
;
using
System.Runtime.InteropServices
;
namespace
CodeLibrary
namespace
CodeLibrary
{
{
...
@@ -68,7 +69,7 @@ namespace CodeLibrary
...
@@ -68,7 +69,7 @@ namespace CodeLibrary
}
}
}
}
}
}
public
override
Bitmap
GrabOne
(
int
index
)
public
override
Bitmap
GrabOne
(
int
index
)
{
{
...
@@ -168,7 +169,7 @@ namespace CodeLibrary
...
@@ -168,7 +169,7 @@ namespace CodeLibrary
//cameraCur.CameraOpened += OnCameraOpened;
//cameraCur.CameraOpened += OnCameraOpened;
//cameraCur.CameraClosed += OnCameraClosed;
//cameraCur.CameraClosed += OnCameraClosed;
//cameraCur.StreamGrabber.GrabStarted += OnGrabStarted;
//cameraCur.StreamGrabber.GrabStarted += OnGrabStarted;
// cameraCurr[index].StreamGrabber.ImageGrabbed += OnImageGrabbed;
// cameraCurr[index].StreamGrabber.ImageGrabbed += OnImageGrabbed;
//cameraCur.StreamGrabber.GrabStopped += OnGrabStopped;
//cameraCur.StreamGrabber.GrabStopped += OnGrabStopped;
cameraCurr
[
index
].
Open
();
cameraCurr
[
index
].
Open
();
_width
[
index
]
=
Convert
.
ToInt32
(
cameraCurr
[
index
].
Parameters
[
PLCamera
.
Width
].
GetValue
());
_width
[
index
]
=
Convert
.
ToInt32
(
cameraCurr
[
index
].
Parameters
[
PLCamera
.
Width
].
GetValue
());
...
@@ -210,7 +211,7 @@ namespace CodeLibrary
...
@@ -210,7 +211,7 @@ namespace CodeLibrary
}
}
return
rtn
;
return
rtn
;
}
}
public
override
Bitmap
GrabOneImage
(
string
name
)
public
override
Bitmap
GrabOneImage
(
string
name
)
{
{
...
@@ -229,6 +230,61 @@ namespace CodeLibrary
...
@@ -229,6 +230,61 @@ namespace CodeLibrary
}
}
public
override
HObject
CaptureOnImage
(
string
name
)
public
override
HObject
CaptureOnImage
(
string
name
)
{
{
int
index
=
cameraName
.
FindIndex
(
s
=>
s
==
name
);
if
(
index
==
-
1
)
{
_errInfo
=
name
+
"Not find"
;
return
null
;
}
if
(
cameraCurr
[
index
]
!=
null
)
{
}
else
{
Open
(
index
);
}
try
{
if
(
cameraCurr
[
index
]
!=
null
)
{
cameraCurr
[
index
].
Parameters
[
PLCamera
.
AcquisitionMode
].
SetValue
(
PLCamera
.
AcquisitionMode
.
SingleFrame
);
//cameraCur.StreamGrabber.Start();
//IGrabResult grabResult = cameraCur.StreamGrabber.RetrieveResult(5000, TimeoutHandling.ThrowException);
IGrabResult
grabResult
=
cameraCurr
[
index
].
StreamGrabber
.
GrabOne
(
5000
);
if
(!
grabResult
.
IsValid
||
!
grabResult
.
GrabSucceeded
)
{
_errInfo
=
grabResult
.
ErrorDescription
;
return
null
;
}
//相机像素数据
byte
[]
buffer
=
grabResult
.
PixelData
as
byte
[];
//锁定像素数据
GCHandle
hand
=
GCHandle
.
Alloc
(
buffer
,
GCHandleType
.
Pinned
);
//获取像素数据的指针
IntPtr
pr
=
hand
.
AddrOfPinnedObject
();
HalconDotNet
.
HObject
image
;
//转成灰度图HOjbect
HalconDotNet
.
HOperatorSet
.
GenImage1
(
out
image
,
new
HalconDotNet
.
HTuple
(
"byte"
),
grabResult
.
Width
,
grabResult
.
Height
,
pr
);
//释放内存
if
(
hand
.
IsAllocated
)
hand
.
Free
();
_errInfo
=
"OK"
;
return
image
;
}
}
catch
(
Exception
ex
)
{
_errInfo
=
ex
.
Message
;
return
null
;
}
finally
{
// cameraCurr[index].MV_CC_StopGrabbing_NET();
}
return
null
;
return
null
;
}
}
}
}
...
...
CodeLibraryProject/编译好的DLL/CodeLibrary.dll
查看文件 @
fee2767
此文件类型无法预览
dll/CodeLibrary.dll
查看文件 @
fee2767
此文件类型无法预览
dll/zxing.dll
0 → 100644
查看文件 @
fee2767
此文件类型无法预览
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论