Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
GeneralClassLibrary
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 43f333cc
由
刘韬
编写于
2021-01-22 09:17:51 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
优化eyemDecode
1 个父辈
1cbbaf0f
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
33 行增加
和
47 行删除
CodeLibraryProject/CodeLibrary/CodeLibrary.csproj
CodeLibraryProject/CodeLibrary/camera/HIK.cs
CodeLibraryProject/CodeLibrary/eyemDecode.cs
CodeLibraryProject/CodeTest/CodeTest.csproj
dll/MvCameraControl.Net.XML
dll/MvCameraControl.Net.dll
CodeLibraryProject/CodeLibrary/CodeLibrary.csproj
查看文件 @
43f333c
...
...
@@ -41,11 +41,13 @@
<Reference Include="halcondotnet">
<HintPath>..\dll\halcondotnet.dll</HintPath>
</Reference>
<Reference Include="log4net">
<HintPath>..\dll\log4net.dll</HintPath>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\增广夹爪\log4net.dll</HintPath>
</Reference>
<Reference Include="MvCameraControl.Net">
<HintPath>..\dll\MvCameraControl.Net.dll</HintPath>
<Reference Include="MvCameraControl.Net, Version=2.4.1.2, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\dll\MvCameraControl.Net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
...
...
CodeLibraryProject/CodeLibrary/camera/HIK.cs
查看文件 @
43f333c
...
...
@@ -407,43 +407,7 @@ namespace CodeLibrary
pal
.
Entries
[
i
]
=
Color
.
FromArgb
(
i
,
i
,
i
);
}
bmp
.
Palette
=
pal
;
/*
var width = FrameInfo.stFrameInfo.nWidth;
var height = FrameInfo.stFrameInfo.nHeight;
const int Alpha = 255;
IntPtr[] ptr = new IntPtr[2];
bmp = new Bitmap(width, height, PixelFormat.Format8bppIndexed);
ColorPalette pal = bmp.Palette;
for (int i = 0; i <= 255; i++)
{
pal.Entries[i] = Color.FromArgb(Alpha, i, i, i);
}
bmp.Palette = pal;
Rectangle rect = new Rectangle(0, 0, width, height);
BitmapData bitmapData = bmp.LockBits(rect, ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
int PixelSize = Bitmap.GetPixelFormatSize(bitmapData.PixelFormat) / 8;
ptr[0] = bitmapData.Scan0;
ptr[1] = FrameInfo.pBufAddr;
//Marshal.Copy()
if (width % 4 == 0)
{
HDLogUtil.info("CopyMemory1");
CopyMemory((IntPtr)ptr[0], (IntPtr)ptr[1], width * height * PixelSize);
}
else
{
HDLogUtil.info("CopyMemory2");
for (int i = 0; i < height - 1; i++)
{
ptr[1] += width;
CopyMemory((IntPtr)ptr[0], (IntPtr)ptr[1], width * PixelSize);
ptr[0] += bitmapData.Stride;
}
}
bmp.UnlockBits(bitmapData);
HDLogUtil.debug("UnlockBits");
//bmp.Save(@"D:\image\"+DateTime.Now.Ticks.ToString() + "test.bmp");
*/
}
catch
(
Exception
ex
)
{
...
...
@@ -485,8 +449,6 @@ namespace CodeLibrary
}
return
hoImage
;
}
[
DllImport
(
"Kernel32.dll"
)]
private
static
extern
void
CopyMemory
(
IntPtr
dest
,
IntPtr
source
,
int
size
);
[
DllImport
(
"kernel32.dll"
,
CharSet
=
CharSet
.
Auto
)]
public
static
extern
void
OutputDebugString
(
string
message
);
...
...
CodeLibraryProject/CodeLibrary/eyemDecode.cs
查看文件 @
43f333c
...
...
@@ -57,7 +57,7 @@ namespace CodeLibrary
DataCodeHandle
hObject
=
null
;
try
{
int
result
=
eyemDetectAndDecode
(
eyemImage
,
eyemRect
,
""
,
codeType
,
out
hObject
,
out
tpResults
,
out
ipNum
,
false
,
1
1
,
5
,
128
,
215
);
int
result
=
eyemDetectAndDecode
(
eyemImage
,
eyemRect
,
""
,
codeType
,
out
hObject
,
out
tpResults
,
out
ipNum
,
false
,
1
9
,
5
,
128
,
215
);
HDLogUtil
.
info
(
$
"eyemDetectAndDecode:{result},ipNum:{ipNum}"
);
if
(
result
!=
0
||
ipNum
==
0
)
return
codelist
;
...
...
@@ -97,8 +97,30 @@ namespace CodeLibrary
}
}
[
DllImport
(
"eyemLib.dll"
,
CharSet
=
CharSet
.
None
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
private
static
extern
int
eyemDetectAndDecode
(
EyemImage
tpImage
,
EyemRect
tpRoi
,
string
fileName
,
string
strCodeType
,
out
DataCodeHandle
hObject
,
out
EyemBarCode
*
tpResults
,
out
int
ipNum
,
bool
bUseNiBlack
,
int
iBlockSize
,
int
iRangeC
,
int
iSymbolMin
,
int
iSymbolMax
,
double
dScaleUpAndDown
=
1
,
double
dToleErr
=
0.5
,
double
dMinorStep
=
1.0
);
private
static
extern
int
eyemDetectAndDecode
(
EyemImage
tpImage
,
EyemRect
tpRoi
,
string
fileName
,
string
strCodeType
,
out
DataCodeHandle
hObject
,
out
EyemBarCode
*
tpResults
,
out
int
ipNum
,
bool
bUseNiBlack
,
int
iBlockSize
,
int
iRangeC
,
int
iSymbolMin
,
int
iSymbolMax
,
double
dScaleUpAndDown
=
0.5
,
double
dToleErr
=
0.5
,
double
dMinorStep
=
1.0
);
/*
* 参数说明
tpImage 输入图像,可使用”eyemImageRead“接口读取图片(需与“eyemImageFree”配合使用),也可直接创建EyemImage对象。
tpRoi 感兴趣区域,尺寸不能小于iSymbolMax。
fileName 文件名,可不填。
strCodeType 所要识别条码类型,“QRCode|DataMatrix|CODE_128”等等。
hObject 结果释放句柄,配合eyemDetectAndDecodeFree使用
tpResults 识别结果
ipNum 结果数量
bUseNiBlack 使用NiBlack二值化,默认值 false。
iBlockSize 定位块大小(奇数),略大于最大定位块(只二维码),佳世达一般设置为11。
iRangeC 搜索范围,范围越大识别越好时间也相应越长,佳世达一般设置为5。
iSymbolMin 最小二维码尺寸,默认128。
iSymbolMax 最大二维码尺寸,佳世达一般设置为215。
dScaleUpAndDown 缩放,<1表示缩小,>1表示放大,=1表示不缩放
dToleErr 最大允许误差默认50%,越小越严格但可能会识别不到。
dMinorStep 步进,默认1.0。
//返回值
-3 图像不存在
-1 内存不足
0 正常
-100 未识别到条码或参数设置不正确
*/
/// <summary>
/// 读取图像
/// </summary>
...
...
CodeLibraryProject/CodeTest/CodeTest.csproj
查看文件 @
43f333c
...
...
@@ -48,7 +48,7 @@
</Reference>
<Reference Include="log4net, Version=2.0.8.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\
dll
\log4net.dll</HintPath>
<HintPath>..\
..\..\增广夹爪
\log4net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
...
...
dll/MvCameraControl.Net.XML
0 → 100644
查看文件 @
43f333c
此文件的差异被折叠,
点击展开。
dll/MvCameraControl.Net.dll
0 → 100644
查看文件 @
43f333c
此文件类型无法预览
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论