Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
刘韬
/
HalconScanCodeServer
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 35dcc71a
由
刘韬
编写于
2023-09-12 14:11:15 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
优化超时时间设定和日志输出
1 个父辈
350ea013
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
56 行增加
和
6 行删除
ScanCodeServer/HDCodeHelper.cs
ScanCodeServer/Program.cs
ScanCodeServer/Setting.cs
ScanCodeServer/WebWork.cs
ScanCodeServer/eyemDecode2.cs
ScanCodeServer/HDCodeHelper.cs
查看文件 @
35dcc71
using
HalconDotNet
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Drawing
;
using
System.Drawing.Imaging
;
using
System.IO
;
...
...
@@ -86,7 +87,9 @@ namespace ScanCodeServer
}
public
static
List
<
CodeInfo
>
DecodeCode
(
HObject
ho_Image
,
string
symbolType
,
string
hv_model_path
,
int
codeCount
,
int
timeOut
=
1500
)
{
Common
.
log
.
Debug
(
" DecodeCode["
+
symbolType
+
"]["
+
hv_model_path
+
"]["
+
codeCount
+
"] 开始"
);
Common
.
log
.
Debug
(
"开始 DecodeCode["
+
symbolType
+
"]["
+
codeCount
+
"]["
+
hv_model_path
+
"]"
);
Stopwatch
sw
=
new
Stopwatch
();
sw
.
Start
();
List
<
CodeInfo
>
codeList
=
new
List
<
CodeInfo
>();
try
{
...
...
@@ -150,7 +153,9 @@ namespace ScanCodeServer
}
}
}
Common
.
log
.
Debug
(
" DecodeCode["
+
symbolType
+
"]["
+
hv_model_path
+
"]["
+
codeCount
+
"] 结束,返回数量:"
+
codeList
.
Count
);
sw
.
Stop
();
Common
.
log
.
Debug
(
"结束 DecodeCode["
+
symbolType
+
"]["
+
codeCount
+
"]["
+
(
sw
.
ElapsedMilliseconds
/
1000f
).
ToString
(
"0.00"
)+
"]返回数量:"
+
codeList
.
Count
);
if
(
hv_Area
!=
null
)
{
hv_Area
.
UnPinTuple
();
...
...
@@ -311,6 +316,9 @@ namespace ScanCodeServer
}
public
static
List
<
CodeInfo
>
DecodeBarCode
(
HObject
ho_Image
)
{
Common
.
log
.
Debug
(
"开始 DecodeCode[barcode]"
);
Stopwatch
sw
=
new
Stopwatch
();
sw
.
Start
();
List
<
CodeInfo
>
codeList
=
new
List
<
CodeInfo
>();
try
{
...
...
@@ -368,6 +376,10 @@ namespace ScanCodeServer
}
}
}
sw
.
Stop
();
Common
.
log
.
Debug
(
"结束 DecodeCode[barcode]["
+
(
sw
.
ElapsedMilliseconds
/
1000f
).
ToString
(
"0.00"
)
+
"]返回数量:"
+
codeList
.
Count
);
HOperatorSet
.
ClearBarCodeModel
(
hv_BarCodeHandle
);
if
(
hv_Area
!=
null
)
{
...
...
ScanCodeServer/Program.cs
查看文件 @
35dcc71
...
...
@@ -22,7 +22,12 @@ namespace ScanCodeServer
return
;
}
Config
.
LoadMyConfig
(
new
Setting
().
GetType
());
var
prop
=
System
.
Diagnostics
.
Process
.
GetCurrentProcess
();
prop
.
PriorityClass
=
Setting
.
ProcessPriorityClass
;
Application
.
EnableVisualStyles
();
Application
.
SetCompatibleTextRenderingDefault
(
false
);
Application
.
Run
(
new
Form1
());
...
...
ScanCodeServer/Setting.cs
查看文件 @
35dcc71
using
ConfigHelper
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Linq
;
using
System.Text
;
using
System.Threading.Tasks
;
...
...
@@ -14,5 +15,17 @@ namespace ScanCodeServer
[
MyConfigComment
(
"emphasize"
)]
public
static
MyConfig
<
bool
>
HOperatorSet_enable_emphasize
=
true
;
[
MyConfigComment
(
"scale_image_range"
)]
public
static
MyConfig
<
bool
>
HOperatorSet_enable_scale_image
=
false
;
[
MyConfigComment
(
"scale_image_mult"
)]
public
static
MyConfig
<
int
>
scale_image_mult
=
2
;
[
MyConfigComment
(
"scale_image_add"
)]
public
static
MyConfig
<
int
>
scale_image_add
=
5
;
[
MyConfigComment
(
"进程优先级"
)]
public
static
MyConfig
<
ProcessPriorityClass
>
ProcessPriorityClass
=
System
.
Diagnostics
.
ProcessPriorityClass
.
High
;
}
}
ScanCodeServer/WebWork.cs
查看文件 @
35dcc71
...
...
@@ -10,6 +10,7 @@ using System.Text;
using
System.Drawing
;
using
System.Threading.Tasks
;
using
System.Text.RegularExpressions
;
using
System.Diagnostics
;
namespace
ScanCodeServer
{
...
...
@@ -51,11 +52,18 @@ namespace ScanCodeServer
string
[]
codeTypeList
=
remoteDecodeParam
.
codeTypeList
;
int
codeCount
=
remoteDecodeParam
.
codeCount
;
int
timeout
=
remoteDecodeParam
.
timeout
;
Common
.
log
.
Info
(
$
"参数:codeTypeList:{string.Join("
,
",codeTypeList)}, codeCount:{codeCount}, timeout:{timeout}"
);
Common
.
log
.
Info
(
$
"<===========================>"
);
Common
.
log
.
Info
(
$
"开始扫码参数:codeTypeList:{string.Join("
,
",codeTypeList)}, codeCount:{codeCount}, timeout:{timeout},emphasize:{Setting.HOperatorSet_enable_emphasize},scale_image:{Setting.HOperatorSet_enable_scale_image}"
);
Stopwatch
sw
=
new
Stopwatch
();
sw
.
Start
();
Result
res
=
new
Result
();
if
(
Setting
.
HOperatorSet_enable_emphasize
)
HOperatorSet
.
Emphasize
(
ho_Image
,
out
ho_Image
,
3
,
3
,
1
);
if
(
Setting
.
HOperatorSet_enable_scale_image
)
HOperatorSet
.
ScaleImage
(
ho_Image
,
out
ho_Image
,
new
HTuple
(
Setting
.
scale_image_mult
),
new
HTuple
(
Setting
.
scale_image_add
));
List
<
string
>
code
=
new
List
<
string
>();
Task
[]
t
=
new
Task
[
codeTypeList
.
Length
];
int
ti
=
0
;
...
...
@@ -116,10 +124,14 @@ namespace ScanCodeServer
});
ti
++;
}
Task
.
WaitAll
(
t
,
1000
*
10
);
var
r
=
Task
.
WaitAll
(
t
,
timeout
+
1000
*
5
);
sw
.
Stop
();
ho_Image
.
Dispose
();
if
(
bitmap
!=
null
)
bitmap
.
Dispose
();
Common
.
log
.
Info
(
$
"结束扫码:task finish:{r}, codeCount:{sw.ElapsedMilliseconds/1000f:0.00}"
);
using
(
MemoryStream
respStream
=
new
MemoryStream
())
{
XmlSerializer
xff
=
new
XmlSerializer
(
typeof
(
List
<
CodeInfo
>));
...
...
ScanCodeServer/eyemDecode2.cs
查看文件 @
35dcc71
using
Microsoft.Win32.SafeHandles
;
using
System
;
using
System.Collections.Generic
;
using
System.Diagnostics
;
using
System.Drawing
;
using
System.Drawing.Imaging
;
using
System.IO
;
...
...
@@ -38,7 +39,9 @@ namespace ScanCodeServer
public
static
List
<
CodeInfo
>
Decoder
(
ref
Bitmap
bmap
,
string
file
=
null
)
{
List
<
CodeInfo
>
codelist
=
new
List
<
CodeInfo
>();
Common
.
log
.
Info
(
"开始 DecodeCode[eyem]"
);
Stopwatch
sw
=
new
Stopwatch
();
sw
.
Start
();
try
{
//创建图像引用
...
...
@@ -79,7 +82,10 @@ namespace ScanCodeServer
// eyemImageFree(ref tpDstImg);
//hObject.Dispose();
//int result = eyemDetectAndDecode(eyemImage, eyemRect, "", codeType, out hObject, out tpResults, out ipNum, false, iBlockSize, iRangeC, iSymbolMin, iSymbolMax);
Common
.
log
.
Info
(
$
"eyemDetectAndDecode:{result},ipNum:{ipNum}"
);
//Common.log.Info($"eyemDetectAndDecode:{result},ipNum:{ipNum}");
sw
.
Stop
();
Common
.
log
.
Info
(
"结束 DecodeCode[eyem]["
+
(
sw
.
ElapsedMilliseconds
/
1000f
).
ToString
(
"0.00"
)
+
$
"]返回数量:result:{result},ipNum:{ipNum}"
);
if
(
result
!=
0
||
ipNum
==
0
)
return
codelist
;
...
...
@@ -89,6 +95,8 @@ namespace ScanCodeServer
ci
.
CodeType
=
Marshal
.
PtrToStringAnsi
(
tpResults
[
i
].
hType
);
codelist
.
Add
(
ci
);
}
}
catch
(
Exception
ex
)
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论