Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张士柳
/
eyemLib
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
图表
网络
创建新的问题
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 53a9dc28
由
张士柳
编写于
2021-04-01 17:29:16 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
无
1 个父辈
a2f38dd2
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
83 行增加
和
37 行删除
eyemLib-Sharp/EyemLib.cs
eyemLib-Sharp/Program.cs
eyemLib/eyemLib.h
eyemLib/eyemMisc.cpp
eyemLib/eyemMisc.h
eyemLib-Sharp/EyemLib.cs
查看文件 @
53a9dc2
...
...
@@ -757,10 +757,10 @@ namespace eyemLib_Sharp
private
static
extern
int
eyemAchvModelByName
(
string
ccTplName
,
IntPtr
hModelID
,
ref
EyemModelID
tpModelID
);
//插入模板
[
DllImport
(
"eyemLib.dll"
,
CharSet
=
CharSet
.
None
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
private
static
extern
int
eyemInsertModel
(
ref
IntPtr
hModelID
,
string
ccTplName
);
private
static
extern
int
eyemInsertModel
(
IntPtr
hModelID
,
string
ccTplName
);
//通过名称移除模板
[
DllImport
(
"eyemLib.dll"
,
CharSet
=
CharSet
.
None
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
private
static
extern
int
eyemRemoveModelByName
(
ref
IntPtr
hModelID
,
string
ccTplName
);
private
static
extern
int
eyemRemoveModelByName
(
IntPtr
hModelID
,
string
ccTplName
);
//释放模板内存
[
DllImport
(
"eyemLib.dll"
,
CharSet
=
CharSet
.
None
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
private
static
extern
int
eyemReleaseModel
(
ref
IntPtr
hModelID
);
...
...
@@ -772,7 +772,7 @@ namespace eyemLib_Sharp
private
static
extern
bool
eyemDetectAndDecodeFree
(
IntPtr
hObject
);
//背景变化跟踪
[
DllImport
(
"eyemLib.dll"
,
CharSet
=
CharSet
.
None
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
private
static
extern
int
eyemTrackFeature
(
EyemImage
tpRefImg
,
EyemImage
tpNextImg
,
IntPtr
tpArray
,
int
iArraySize
,
IntPtr
ipResults
);
private
static
extern
int
eyemTrackFeature
(
EyemImage
tpRefImg
,
EyemImage
tpNextImg
,
IntPtr
tpArray
,
int
iArraySize
,
IntPtr
ipResults
,
out
EyemImage
tpDstImg
);
//插件机
[
DllImport
(
"eyemLib.dll"
,
CharSet
=
CharSet
.
None
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
private
static
extern
int
eyemAOIForTSAV
(
EyemImage
tpRefImg
,
EyemImage
tpNextImg
,
IntPtr
tpArray
,
int
iArraySize
);
...
...
@@ -975,8 +975,8 @@ namespace eyemLib_Sharp
tpRoi2
.
iWidth
=
28
;
tpRoi2
.
iHeight
=
9
;
//
double matchDeg = 0.80;
//
flag = eyemCreateTemplateModel(tpDstImg, tpRoi2, matchDeg, "D:\\模板文件\\" + file.Replace(".png", ".tpl"));
double
matchDeg
=
0.80
;
flag
=
eyemCreateTemplateModel
(
tpDstImg
,
tpRoi2
,
matchDeg
,
"D:\\模板文件\\"
+
file
.
Replace
(
".png"
,
".tpl"
));
//加载模板到内存
IntPtr
hModelID
=
IntPtr
.
Zero
;
...
...
@@ -987,7 +987,7 @@ namespace eyemLib_Sharp
flag
=
eyemMatchTemplateModel
(
tpDstImg
,
hModelID
,
ref
selectModel
);
//插入模板
flag
=
eyemInsertModel
(
ref
hModelID
,
"D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl"
);
flag
=
eyemInsertModel
(
hModelID
,
"D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl"
);
//根据名称获取模板
EyemModelID
tpModelID
=
new
EyemModelID
();
...
...
@@ -1015,7 +1015,7 @@ namespace eyemLib_Sharp
//eyemCountObjectIrregularPartsE(image, tpRoi, file.Replace(".png", ""), "D:\\模板文件\\" + /*file.Replace(".png", ".tpl")*/"74d571ed-9fd4-4959-85dd-3195261e4b48.tpl", ref pNumObj, out tpDstImg);
//移除模板
flag
=
eyemRemoveModelByName
(
ref
hModelID
,
"D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl"
);
flag
=
eyemRemoveModelByName
(
hModelID
,
"D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl"
);
//Bitmap bitmap = eyemCvtToBitmap(tpDstImg);
...
...
@@ -1073,7 +1073,7 @@ namespace eyemLib_Sharp
flag
=
eyemAchvTemplateImage
(
image
,
tpRoi
,
out
tpDstImg
);
//测试插入模板
//eyemInsertModel(
ref
hModelID, "D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl");
//eyemInsertModel(hModelID, "D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl");
////测试获取模板
//EyemModelID tpModelID0 = new EyemModelID();
...
...
@@ -1094,6 +1094,8 @@ namespace eyemLib_Sharp
Bitmap
bitmap
=
eyemCvtToBitmap
(
tpModeImg
);
bitmap
.
Dispose
();
//if (bitmap != null)
//{
// bitmap.Save(System.Windows.Forms.Application.StartupPath + "\\ResOut\\" + file);
...
...
@@ -1106,14 +1108,48 @@ namespace eyemLib_Sharp
eyemCountObjectIrregularPartsE
(
image
,
tpRoi
,
file
.
Replace
(
".png"
,
""
),
selectModel
.
Split
(
new
char
[]
{
','
},
StringSplitOptions
.
RemoveEmptyEntries
)[
0
],
hModelID
,
ref
pNumObj
,
out
tpDstImg
);
//测试移除模板
//eyemRemoveModelByName(
ref
hModelID, "D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl");
//eyemRemoveModelByName(hModelID, "D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl");
//free image
eyemImageFree
(
ref
tpDstImg
);
eyemImageFree
(
ref
image
);
sw
.
Stop
();
Console
.
WriteLine
(
"耗时:"
+
sw
.
ElapsedMilliseconds
.
ToString
()
+
",结果:"
+
pNumObj
);
Console
.
WriteLine
(
"耗时:"
+
sw
.
ElapsedMilliseconds
.
ToString
()
+
",结果:"
+
pNumObj
+
",所用模板:"
+
str
);
}
public
static
void
eyemReadProcssedImage
(
string
fileName
)
{
EyemImage
image
;
EyemImage
tpDstImg
=
new
EyemImage
();
int
flag
=
eyemImageRead
(
fileName
,
-
1
,
out
image
);
if
(
flag
!=
0
)
{
Console
.
WriteLine
(
"读图失败!"
);
return
;
}
EyemRect
tpRoi
=
new
EyemRect
();
tpRoi
.
iXs
=
200
;
tpRoi
.
iYs
=
200
;
tpRoi
.
iWidth
=
image
.
iWidth
-
400
;
tpRoi
.
iHeight
=
image
.
iHeight
-
400
;
//
string
file
=
fileName
.
Split
(
new
string
[]
{
"\\"
},
StringSplitOptions
.
RemoveEmptyEntries
)[
2
];
//获取用于制作模板的图像
flag
=
eyemAchvTemplateImage
(
image
,
tpRoi
,
out
tpDstImg
);
Bitmap
bitmap
=
eyemCvtToBitmap
(
tpDstImg
);
if
(
bitmap
!=
null
)
{
bitmap
.
Save
(
"D:\\ResOut\\"
+
file
);
}
//建议释放掉
bitmap
.
Dispose
();
}
public
static
int
eyemInitModelE
(
out
IntPtr
hModelID
)
...
...
@@ -1158,9 +1194,11 @@ namespace eyemLib_Sharp
//类似于实时采集的图像
for
(
int
i
=
1
;
i
<
ipNum
;
i
++)
{
EyemImage
tpDstImg
;
//存放结果
int
[]
iArrRes
=
new
int
[
tpRois
.
Count
];
int
iRet
=
eyemAOIForTSAV
(
tpImages
[
0
],
tpImages
[
i
],
hGlobal
,
tpRois
.
Count
);
//int iRet = eyemAOIForTSAV(tpImages[0], tpImages[i], hGlobal, tpRois.Count);
int
iRet
=
eyemTrackFeature
(
tpImages
[
0
],
tpImages
[
i
],
hGlobal
,
tpRois
.
Count
,
Marshal
.
UnsafeAddrOfPinnedArrayElement
(
iArrRes
,
0
),
out
tpDstImg
);
//过滤出有效信号(连续存在数帧以上才算,防止误触发),或者直接用iArrRes的值作为信号
//toSingleFilter(iArrRes, ref bitSingle);
//for (int j = 0; j < bitSingle.Length; j++)
...
...
@@ -1172,6 +1210,7 @@ namespace eyemLib_Sharp
// Console.WriteLine("检测到:" + j + "处有信号");
// }
//}
eyemImageFree
(
ref
tpDstImg
);
System
.
Threading
.
Thread
.
Sleep
(
80
);
}
//释放资源
...
...
eyemLib-Sharp/Program.cs
查看文件 @
53a9dc2
...
...
@@ -28,31 +28,38 @@ namespace eyemLib_Sharp
// EyemLib.eyemReadImageTool(item);
//}
//for (int i = 0; i < 1; i++)
//{
// EyemLib.eyemTestVideoCapture("D:\\插件完成检测\\视频\\WeChat2.mp4");
//}
IntPtr
hModelID
;
EyemLib
.
eyemInitModelE
(
out
hModelID
);
for
(
int
i
=
0
;
i
<
5000
;
i
++)
for
(
int
i
=
0
;
i
<
1
;
i
++)
{
//for (int j = 0; j < fileNames.Length; j++)
//{
// EyemLib.eyemReadImageToolE(fileNames[j], hModelID);
//}
//并行测试
ParallelOptions
po
=
new
ParallelOptions
();
po
.
MaxDegreeOfParallelism
=
3
;
Parallel
.
ForEach
(
fileNames
,
po
,
fn
=>
{
EyemLib
.
eyemReadImageToolE
(
fn
,
hModelID
);
});
EyemLib
.
eyemTestVideoCapture
(
"D:\\插件完成检测\\视频\\cap5.mp4"
);
}
EyemLib
.
eyemReleaseModelE
(
ref
hModelID
);
//IntPtr hModelID;
//EyemLib.eyemInitModelE(out hModelID);
//int sum = 0;
//for (int i = 0; i < 5000; i++)
//{
// //for (int j = 0; j < fileNames.Length; j++)
// //{
// // EyemLib.eyemReadImageToolE(fileNames[j], hModelID);
// //}
// sum++;
// //并行测试
// ParallelOptions po = new ParallelOptions();
// po.MaxDegreeOfParallelism = 3;
// Parallel.ForEach(fileNames, po, fn =>
// {
// EyemLib.eyemReadImageToolE(fn, hModelID);
// });
// if (sum > 50)
// {
// sum = 0;
// Console.Clear();
// }
//}
//EyemLib.eyemReleaseModelE(ref hModelID);
Console
.
Write
(
"请按任意键继续。。。"
);
Console
.
ReadKey
();
...
...
eyemLib/eyemLib.h
查看文件 @
53a9dc2
...
...
@@ -853,10 +853,10 @@ extern "C" {
EXPORTS
int
eyemMatchTemplateModel
(
EyemImage
tpImage
,
IntPtr
hModelID
,
LPSTR
*
lpszTplName
);
EXPORTS
int
eyemInitModel
(
const
char
*
ccTplName
,
IntPtr
*
hModelID
);
EXPORTS
int
eyemAchvModelByName
(
const
char
*
ccTplName
,
IntPtr
hModelID
,
EyemModelID
&
tpModelID
);
EXPORTS
int
eyemInsertModel
(
IntPtr
&
hModelID
,
const
char
*
ccTplName
);
EXPORTS
int
eyemRemoveModelByName
(
IntPtr
&
hModelID
,
const
char
*
ccTplName
);
EXPORTS
int
eyemInsertModel
(
IntPtr
hModelID
,
const
char
*
ccTplName
);
EXPORTS
int
eyemRemoveModelByName
(
IntPtr
hModelID
,
const
char
*
ccTplName
);
EXPORTS
int
eyemReleaseModel
(
IntPtr
&
hModelID
);
EXPORTS
int
eyemTrackFeature
(
EyemImage
tpPrevImg
,
EyemImage
tpNextImg
,
EyemRect3
*
tpRois
,
int
iRoiNum
,
int
*
ipResults
);
EXPORTS
int
eyemTrackFeature
(
EyemImage
tpPrevImg
,
EyemImage
tpNextImg
,
EyemRect3
*
tpRois
,
int
iRoiNum
,
int
*
ipResults
,
EyemImage
*
tpDstImg
);
EXPORTS
int
eyemAOIForTSAV
(
EyemImage
tpRefImg
,
EyemImage
tpNextImg
,
EyemRect3
*
tpRois
,
int
iRoiNum
);
#ifdef __cplusplus
...
...
eyemLib/eyemMisc.cpp
查看文件 @
53a9dc2
此文件的差异被折叠,
点击展开。
eyemLib/eyemMisc.h
查看文件 @
53a9dc2
...
...
@@ -14,7 +14,7 @@
constexpr
double
c
=
PI
/
180
.;
std
::
mutex
mtx
;
std
::
mutex
mtx
_misc
;
#endif
/* __EYEM_MISC_H */
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论