Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张士柳
/
eyemLib
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
图表
网络
创建新的问题
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 30d336d2
由
张士柳
编写于
2021-08-12 17:24:09 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
无
1 个父辈
61eb66e4
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
144 行增加
和
45 行删除
eyemLib-Sharp/EyemLib.cs
eyemLib-Sharp/EyemLibDemo.cs
eyemLib/eyemClp2d.cpp
eyemLib/eyemEdge1d.cpp
eyemLib/eyemLib.h
eyemLib/eyemLib.rc
eyemLib/eyemMisc.cpp
eyemLib-Sharp/EyemLib.cs
查看文件 @
30d336d
...
@@ -863,7 +863,7 @@ namespace eyemLib_Sharp
...
@@ -863,7 +863,7 @@ namespace eyemLib_Sharp
/// <param name="nCalipers">卡尺数量</param>
/// <param name="nCalipers">卡尺数量</param>
/// <param name="iSearchDirec">搜索方向(起点到终点方向的垂直方向)</param>
/// <param name="iSearchDirec">搜索方向(起点到终点方向的垂直方向)</param>
/// <param name="dAmpThreshold">最小边缘幅度</param>
/// <param name="dAmpThreshold">最小边缘幅度</param>
/// <param name="ccTransition">灰度值过渡的类型以确定边缘'
first','
all', 'negative', 'positive'</param>
/// <param name="ccTransition">灰度值过渡的类型以确定边缘'all', 'negative', 'positive'</param>
/// <param name="hObject">结果</param>
/// <param name="hObject">结果</param>
/// <returns></returns>
/// <returns></returns>
[
DllImport
(
"eyemLib.dll"
,
CharSet
=
CharSet
.
None
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"eyemLib.dll"
,
CharSet
=
CharSet
.
None
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
...
@@ -1187,7 +1187,7 @@ namespace eyemLib_Sharp
...
@@ -1187,7 +1187,7 @@ namespace eyemLib_Sharp
private
static
extern
int
setSkipProcessID
(
int
pid
);
private
static
extern
int
setSkipProcessID
(
int
pid
);
//圆形mark点定位
//圆形mark点定位
[
DllImport
(
"eyemLib.dll"
,
CharSet
=
CharSet
.
None
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"eyemLib.dll"
,
CharSet
=
CharSet
.
None
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
private
static
extern
int
eyemMarkerTracing
(
EyemImage
tpImage
,
double
dThreshold
,
ref
EyemOcsFXYR
tpCircle
,
bool
bHighAccuracy
=
false
);
private
static
extern
int
eyemMarkerTracing
(
EyemImage
tpImage
,
double
dThreshold
,
ref
EyemOcsFXYR
tpCircle
,
out
EyemImage
tpDstImg
,
bool
bHighAccuracy
=
false
);
//多功能工具
//多功能工具
[
DllImport
(
"eyemLib.dll"
,
CharSet
=
CharSet
.
None
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"eyemLib.dll"
,
CharSet
=
CharSet
.
None
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
private
static
extern
int
eyemMulFuncTool
(
EyemImage
tpImage
,
EyemRect
tpRoi
,
string
funcName
,
double
dThreshold
,
int
iNumToIgnore
,
ref
EyemOcsFXYR
tpCircle
,
out
EyemImage
tpDstImg
);
private
static
extern
int
eyemMulFuncTool
(
EyemImage
tpImage
,
EyemRect
tpRoi
,
string
funcName
,
double
dThreshold
,
int
iNumToIgnore
,
ref
EyemOcsFXYR
tpCircle
,
out
EyemImage
tpDstImg
);
...
@@ -1249,7 +1249,7 @@ namespace eyemLib_Sharp
...
@@ -1249,7 +1249,7 @@ namespace eyemLib_Sharp
{
{
EyemImage
image
;
EyemImage
image
;
EyemImage
tpDstImg
=
new
EyemImage
();
EyemImage
tpDstImg
=
new
EyemImage
();
//
EyemOcsFXYR tpCircle = new EyemOcsFXYR();
EyemOcsFXYR
tpCircle
=
new
EyemOcsFXYR
();
//int flag = eyemImageReadRaw(fileName, 3072, 3072, 2, out ucpImage);
//int flag = eyemImageReadRaw(fileName, 3072, 3072, 2, out ucpImage);
int
flag
=
eyemImageRead
(
fileName
,
-
1
,
out
image
);
int
flag
=
eyemImageRead
(
fileName
,
-
1
,
out
image
);
if
(
flag
!=
0
)
if
(
flag
!=
0
)
...
@@ -1261,6 +1261,8 @@ namespace eyemLib_Sharp
...
@@ -1261,6 +1261,8 @@ namespace eyemLib_Sharp
Stopwatch
sw
=
new
Stopwatch
();
Stopwatch
sw
=
new
Stopwatch
();
sw
.
Restart
();
sw
.
Restart
();
string
file
=
fileName
.
Split
(
new
string
[]
{
"\\"
},
StringSplitOptions
.
RemoveEmptyEntries
)[
2
];
//EyemImage image1 = new EyemImage(); EyemImage image2 = new EyemImage();
//EyemImage image1 = new EyemImage(); EyemImage image2 = new EyemImage();
//flag = eyemMatMalloc(512, 512, 1, "uint8_t", out image1);
//flag = eyemMatMalloc(512, 512, 1, "uint8_t", out image1);
//flag = eyemMatMalloc(512, 512, 1, "uint8_t", out image2);
//flag = eyemMatMalloc(512, 512, 1, "uint8_t", out image2);
...
@@ -1280,7 +1282,16 @@ namespace eyemLib_Sharp
...
@@ -1280,7 +1282,16 @@ namespace eyemLib_Sharp
//flag = eyemLibImpl(image, out tpDstImg);
//flag = eyemLibImpl(image, out tpDstImg);
//flag = eyemMarkerTracing(image, 130, ref tpCircle);
flag
=
eyemMarkerTracing
(
image
,
120
,
ref
tpCircle
,
out
tpDstImg
);
Bitmap
bitmap
=
eyemCvtToBitmap
(
tpDstImg
);
if
(
bitmap
!=
null
)
{
bitmap
.
Save
(
System
.
Windows
.
Forms
.
Application
.
StartupPath
+
"\\ResOut\\"
+
file
);
}
eyemImageFree
(
ref
tpDstImg
);
return
;
#
region
Test
Blob
#
region
Test
Blob
...
@@ -1296,21 +1307,21 @@ namespace eyemLib_Sharp
...
@@ -1296,21 +1307,21 @@ namespace eyemLib_Sharp
#
endregion
#
endregion
#
region
Test
1D
Edge
#
region
Test
1D
Edge
EyemOcsDXY
tpLineSt
=
new
EyemOcsDXY
();
//
EyemOcsDXY tpLineSt = new EyemOcsDXY();
tpLineSt
.
dX
=
671
;
//tpLineSt.dX = 386.5
;
tpLineSt
.
dY
=
718
;
//tpLineSt.dY = 136.5
;
EyemOcsDXY
tpLineEd
=
new
EyemOcsDXY
();
//
EyemOcsDXY tpLineEd = new EyemOcsDXY();
tpLineEd
.
dX
=
858
;
//tpLineEd.dX = 323.5
;
tpLineEd
.
dY
=
716
;
//tpLineEd.dY = 40.5
;
MeasureHandle
hObject
;
//
MeasureHandle hObject;
//eyemEdge1dGenMeasureRect(image, tpLineSt, tpLineEd, 10, "all", 0, 0.9, 30, out hObject);
//
//
eyemEdge1dGenMeasureRect(image, tpLineSt, tpLineEd, 10, "all", 0, 0.9, 30, out hObject);
//eyemEdge1dGenPosRect(image, tpLineSt, tpLineEd, 50, 0, 0.9, 30, out hObject);
//
//
eyemEdge1dGenPosRect(image, tpLineSt, tpLineEd, 50, 0, 0.9, 30, out hObject);
sw
.
Restart
();
//
sw.Restart();
eyemEdge1dFindLine
(
image
,
tpLineSt
,
tpLineEd
,
25
,
35
,
-
1
,
15
,
"negative
"
,
out
hObject
);
//eyemEdge1dFindLine(image, tpLineSt, tpLineEd, 15, 3500, -1, 15, "all
", out hObject);
sw
.
Stop
();
//
sw.Stop();
Console
.
WriteLine
(
"时间:"
+
sw
.
ElapsedMilliseconds
.
ToString
());
//
Console.WriteLine("时间:" + sw.ElapsedMilliseconds.ToString());
return
;
//
return;
//hObject.Dispose();
//hObject.Dispose();
#
endregion
#
endregion
...
@@ -1506,7 +1517,7 @@ namespace eyemLib_Sharp
...
@@ -1506,7 +1517,7 @@ namespace eyemLib_Sharp
//flag = eyemMulFuncTool(image, tpRoi, "__func1", 65, 75, ref tpCircle, out tpDstImg);
//flag = eyemMulFuncTool(image, tpRoi, "__func1", 65, 75, ref tpCircle, out tpDstImg);
int
[]
ipReelNum
=
new
int
[
4
];
int
[]
ipReelNum
=
new
int
[
4
];
string
file
=
fileName
.
Split
(
new
string
[]
{
"\\"
},
StringSplitOptions
.
RemoveEmptyEntries
)[
2
];
//获取用于制作模板的图像
//获取用于制作模板的图像
//flag = eyemAchvTemplateImage(image, tpRoi, out tpDstImg);
//flag = eyemAchvTemplateImage(image, tpRoi, out tpDstImg);
...
@@ -1566,19 +1577,19 @@ namespace eyemLib_Sharp
...
@@ -1566,19 +1577,19 @@ namespace eyemLib_Sharp
//"IP_SMALL_PARTS","IP_LARGE_PARTS","IP_LONG_PARTS","IP_LOWCONTRAST_PARTS"
//"IP_SMALL_PARTS","IP_LARGE_PARTS","IP_LONG_PARTS","IP_LOWCONTRAST_PARTS"
//eyemCountObject(image, tpRoi, file.Replace(".png", ""), ipReelNum, out tpDstImg);
//eyemCountObject(image, tpRoi, file.Replace(".png", ""), ipReelNum, out tpDstImg);
//eyemCountObjectIrregularParts(image, tpRoi, file.Replace(".png", ""), "IP_LARGE_PARTS", ipReelNum, out tpDstImg);
//eyemCountObjectIrregularParts(image, tpRoi, file.Replace(".png", ""), "IP_LARGE_PARTS", ipReelNum, out tpDstImg);
//eyemCountObjectE(image, tpRoi, file
Name
, ipReelNum, out tpDstImg);
//eyemCountObjectE(image, tpRoi, file
.Replace(".png", "")
, ipReelNum, out tpDstImg);
//eyemCountObjectIrregularPartsE(image, tpRoi, file.Replace(".png", ""), tpModels[0], hModelID, ipReelNum, out tpDstImg);
//eyemCountObjectIrregularPartsE(image, tpRoi, file.Replace(".png", ""), tpModels[0], hModelID, ipReelNum, out tpDstImg);
//eyemCountObjectIrregularPartsE(image, tpRoi, file.Replace(".png", ""), "D:\\模板文件\\" + /*file.Replace(".png", ".tpl")*/"74d571ed-9fd4-4959-85dd-3195261e4b48.tpl", ref pNumObj, out tpDstImg);
//eyemCountObjectIrregularPartsE(image, tpRoi, file.Replace(".png", ""), "D:\\模板文件\\" + /*file.Replace(".png", ".tpl")*/"74d571ed-9fd4-4959-85dd-3195261e4b48.tpl", ref pNumObj, out tpDstImg);
//移除模板
//移除模板
//flag = eyemRemoveModelByName(hModelID, "D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl");
//flag = eyemRemoveModelByName(hModelID, "D:\\模板文件及图像\\df871193-6632-48f9-abfe-540c3fc49c3f.tpl");
Bitmap
bitmap
=
eyemCvtToBitmap
(
tpDstImg
);
//
Bitmap bitmap = eyemCvtToBitmap(tpDstImg);
if
(
bitmap
!=
null
)
//
if (bitmap != null)
{
//
{
//bitmap.Save("D:\\ResOut\\" + file);
//
//bitmap.Save("D:\\ResOut\\" + file);
bitmap
.
Save
(
System
.
Windows
.
Forms
.
Application
.
StartupPath
+
"\\ResOut\\"
+
file
);
//
bitmap.Save(System.Windows.Forms.Application.StartupPath + "\\ResOut\\" + file);
}
//
}
//< 解码测试
//< 解码测试
//int ipNum; EyemBarCode* tpResults;
//int ipNum; EyemBarCode* tpResults;
...
...
eyemLib-Sharp/EyemLibDemo.cs
查看文件 @
30d336d
...
@@ -308,8 +308,9 @@ namespace eyemLib_Sharp
...
@@ -308,8 +308,9 @@ namespace eyemLib_Sharp
/// <param name="tpCircle">结果</param>
/// <param name="tpCircle">结果</param>
/// <param name="bHighAccuracy">是否是高精度定位</param>
/// <param name="bHighAccuracy">是否是高精度定位</param>
/// <returns></returns>
/// <returns></returns>
//圆形mark点定位
[
DllImport
(
"eyemLib.dll"
,
CharSet
=
CharSet
.
None
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
[
DllImport
(
"eyemLib.dll"
,
CharSet
=
CharSet
.
None
,
CallingConvention
=
CallingConvention
.
Cdecl
)]
private
static
extern
int
eyemMarkerTracing
(
EyemImage
tpImage
,
double
dThreshold
,
ref
EyemOcsFXYR
tpCircle
,
bool
bHighAccuracy
=
false
);
private
static
extern
int
eyemMarkerTracing
(
EyemImage
tpImage
,
double
dThreshold
,
ref
EyemOcsFXYR
tpCircle
,
out
EyemImage
tpDstImg
,
bool
bHighAccuracy
=
false
);
#
endregion
#
endregion
#
region
通用
#
region
通用
...
@@ -324,7 +325,7 @@ namespace eyemLib_Sharp
...
@@ -324,7 +325,7 @@ namespace eyemLib_Sharp
private
static
extern
void
setLogCallback
(
TCallBack
cb
);
private
static
extern
void
setLogCallback
(
TCallBack
cb
);
#
endregion
#
endregion
//
日志
#
region
日志
public
delegate
void
TCallBack
(
string
msg
);
public
delegate
void
TCallBack
(
string
msg
);
public
static
TCallBack
sld
=
new
TCallBack
(
TLogCallback
);
public
static
TCallBack
sld
=
new
TCallBack
(
TLogCallback
);
...
@@ -353,12 +354,13 @@ namespace eyemLib_Sharp
...
@@ -353,12 +354,13 @@ namespace eyemLib_Sharp
{
{
//算法里输出的一切日志都会在这里
//算法里输出的一切日志都会在这里
}
}
#
endregion
//例程
//例程
public
static
void
eyeyTestTemplateModelMethod
(
string
fileName
)
public
static
void
eyeyTestTemplateModelMethod
(
string
fileName
)
{
{
#
region
//从本地读图
#
region
//从本地读图
//EyemImage image;
//EyemImage image
, tpDstImg
;
//int flag = eyemImageRead(fileName, -1, out image);
//int flag = eyemImageRead(fileName, -1, out image);
//if (flag != 0)
//if (flag != 0)
//{
//{
...
@@ -367,20 +369,22 @@ namespace eyemLib_Sharp
...
@@ -367,20 +369,22 @@ namespace eyemLib_Sharp
//}
//}
//EyemOcsFXYR tpCircle = new EyemOcsFXYR();
//EyemOcsFXYR tpCircle = new EyemOcsFXYR();
//flag = eyemMarkerTracing(image, 1
30, ref tpCircle
);
//flag = eyemMarkerTracing(image, 1
20, ref tpCircle, out tpDstImg
);
////free image
////free image
//eyemImageFree(ref image);
//eyemImageFree(ref image);
//eyemImageFree(ref tpDstImg);
#
endregion
#
endregion
#
region
//从内存读图
#
region
//从内存读图
//image = eyemCvtToEyemImage(
bitmap
);
//image = eyemCvtToEyemImage(
/*Bitmap*/
);
//flag = eyemMarkerTracing(image, 1
30, ref tpCircle
);
//flag = eyemMarkerTracing(image, 1
20, ref tpCircle, out tpDstImg
);
////free image
////free image
//Marshal.FreeHGlobal(image.vpImage);
//Marshal.FreeHGlobal(image.vpImage);
//eyemImageFree(ref tpDstImg);
#
endregion
#
endregion
}
}
...
...
eyemLib/eyemClp2d.cpp
查看文件 @
30d336d
...
@@ -77,6 +77,48 @@ int eyemClp2dIntersectionTwoLines(EyemOcsDABC tpLine1, EyemOcsDABC tpLine2, Eyem
...
@@ -77,6 +77,48 @@ int eyemClp2dIntersectionTwoLines(EyemOcsDABC tpLine1, EyemOcsDABC tpLine2, Eyem
return
FUNC_OK
;
return
FUNC_OK
;
}
}
int
eyemClp2dIntersectionLineSegment
(
EyemOcsDABC
tpLine
,
EyemOcsDXY
tpPtSt
,
EyemOcsDXY
tpPtEd
,
int
*
ipStatus
,
EyemOcsDXY
&
tpPoint
)
{
double
d1
,
d2
;
d1
=
abs
(
tpLine
.
dA
*
tpPtSt
.
dX
+
tpLine
.
dB
*
tpPtSt
.
dY
+
tpLine
.
dC
)
/
sqrt
(
tpLine
.
dA
*
tpLine
.
dA
+
tpLine
.
dB
*
tpLine
.
dB
);
if
(
abs
(
tpLine
.
dB
)
<
FLT_EPSILON
)
{
d1
=
tpPtSt
.
dX
<
-
tpLine
.
dC
/
tpLine
.
dA
?
-
d1
:
d1
;
}
else
{
d1
=
tpPtSt
.
dY
>=
((
-
tpLine
.
dA
/
tpLine
.
dB
)
*
tpPtSt
.
dX
-
tpLine
.
dC
/
tpLine
.
dB
)
?
d1
:
-
d1
;
}
d2
=
abs
(
tpLine
.
dA
*
tpPtEd
.
dX
+
tpLine
.
dB
*
tpPtEd
.
dY
+
tpLine
.
dC
)
/
sqrt
(
tpLine
.
dA
*
tpLine
.
dA
+
tpLine
.
dB
*
tpLine
.
dB
);
if
(
abs
(
tpLine
.
dB
)
<
FLT_EPSILON
)
{
d2
=
tpPtEd
.
dX
<
-
tpLine
.
dC
/
tpLine
.
dA
?
-
d2
:
d2
;
}
else
{
d2
=
tpPtEd
.
dY
>=
((
-
tpLine
.
dA
/
tpLine
.
dB
)
*
tpPtEd
.
dX
-
tpLine
.
dC
/
tpLine
.
dC
)
?
d2
:
-
d2
;
}
//异号或者为0则交点存在
if
(
d1
*
d2
<=
0
)
{
d1
=
abs
(
d1
);
d2
=
abs
(
d2
);
double
k
=
d1
/
(
d1
+
d2
);
if
((
d1
+
d2
!=
0
)
&&
((
tpPtSt
.
dX
+
k
*
(
tpPtEd
.
dX
-
tpPtSt
.
dX
)
!=
tpPtSt
.
dX
)
||
((
tpPtSt
.
dY
+
k
*
(
tpPtEd
.
dY
-
tpPtSt
.
dY
))
!=
tpPtSt
.
dY
)))
{
tpPoint
.
dX
=
tpPtSt
.
dX
+
k
*
(
tpPtEd
.
dX
-
tpPtSt
.
dX
);
tpPoint
.
dY
=
tpPtSt
.
dY
+
k
*
(
tpPtEd
.
dY
-
tpPtSt
.
dY
);
*
ipStatus
=
EYEM_CG_INTERSECTION
;
}
else
if
(
d1
+
d2
==
0
)
{
*
ipStatus
=
EYEM_CG_SEG1_OVERLAP_SGM2
;
}
}
else
{
*
ipStatus
=
EYEM_CG_NOT_INTERSECTION
;
}
return
FUNC_OK
;
}
int
eyemClp2dIntersectionOfTwoSegments
(
EyemOcsDXY
tpPt1St
,
EyemOcsDXY
tpPt1Ed
,
EyemOcsDXY
tpPt2St
,
EyemOcsDXY
tpPt2Ed
,
int
*
ipStatus
,
EyemOcsDXY
&
tpPoint
)
{
return
FUNC_OK
;
}
int
eyemClp2dAngleTwoLines
(
EyemOcsDABC
tpLine1
,
EyemOcsDABC
tpLine2
,
double
&
dpAngle
)
int
eyemClp2dAngleTwoLines
(
EyemOcsDABC
tpLine1
,
EyemOcsDABC
tpLine2
,
double
&
dpAngle
)
{
{
if
(
abs
(
tpLine1
.
dA
*
tpLine2
.
dB
-
tpLine2
.
dA
*
tpLine1
.
dB
)
<
EPS
)
{
if
(
abs
(
tpLine1
.
dA
*
tpLine2
.
dB
-
tpLine2
.
dA
*
tpLine1
.
dB
)
<
EPS
)
{
...
...
eyemLib/eyemEdge1d.cpp
查看文件 @
30d336d
此文件的差异被折叠,
点击展开。
eyemLib/eyemLib.h
查看文件 @
30d336d
...
@@ -462,6 +462,8 @@ extern "C" {
...
@@ -462,6 +462,8 @@ extern "C" {
EXPORTS
int
eyemClp2dVerticalLinePointAndLine
(
EyemOcsDXY
tpPoint
,
EyemOcsDABC
tpLine
,
EyemOcsDABC
&
tpVertical
);
EXPORTS
int
eyemClp2dVerticalLinePointAndLine
(
EyemOcsDXY
tpPoint
,
EyemOcsDABC
tpLine
,
EyemOcsDABC
&
tpVertical
);
EXPORTS
void
eyemClp2dLinePointAndSlope
(
EyemOcsDXY
tpPoint
,
double
dSlope
,
EyemOcsDABC
&
tpLine
);
EXPORTS
void
eyemClp2dLinePointAndSlope
(
EyemOcsDXY
tpPoint
,
double
dSlope
,
EyemOcsDABC
&
tpLine
);
EXPORTS
int
eyemClp2dIntersectionTwoLines
(
EyemOcsDABC
tpLine1
,
EyemOcsDABC
tpLine2
,
EyemOcsDXY
&
tpPoint
);
EXPORTS
int
eyemClp2dIntersectionTwoLines
(
EyemOcsDABC
tpLine1
,
EyemOcsDABC
tpLine2
,
EyemOcsDXY
&
tpPoint
);
EXPORTS
int
eyemClp2dIntersectionLineSegment
(
EyemOcsDABC
tpLine
,
EyemOcsDXY
tpPtSt
,
EyemOcsDXY
tpPtEd
,
int
*
ipStatus
,
EyemOcsDXY
&
tpPoint
);
EXPORTS
int
eyemClp2dIntersectionOfTwoSegments
(
EyemOcsDXY
tpPt1St
,
EyemOcsDXY
tpPt1Ed
,
EyemOcsDXY
tpPt2St
,
EyemOcsDXY
tpPt2Ed
,
int
*
ipStatus
,
EyemOcsDXY
&
tpPoint
);
EXPORTS
int
eyemClp2dAngleTwoLines
(
EyemOcsDABC
tpLine1
,
EyemOcsDABC
tpLine2
,
double
&
dpAngle
);
EXPORTS
int
eyemClp2dAngleTwoLines
(
EyemOcsDABC
tpLine1
,
EyemOcsDABC
tpLine2
,
double
&
dpAngle
);
EXPORTS
int
eyemClp2dCenterLineOfTwoLines
(
EyemOcsDABC
tpLine1
,
EyemOcsDABC
tpLine2
,
EyemOcsDABC
&
tpLineC
);
EXPORTS
int
eyemClp2dCenterLineOfTwoLines
(
EyemOcsDABC
tpLine1
,
EyemOcsDABC
tpLine2
,
EyemOcsDABC
&
tpLineC
);
EXPORTS
int
eyemClp2dDistancePointToLine
(
EyemOcsDXY
tpPoint
,
EyemOcsDABC
tpLine
,
double
&
dpDist
);
EXPORTS
int
eyemClp2dDistancePointToLine
(
EyemOcsDXY
tpPoint
,
EyemOcsDABC
tpLine
,
double
&
dpDist
);
...
@@ -512,8 +514,12 @@ extern "C" {
...
@@ -512,8 +514,12 @@ extern "C" {
// 线交叉状态
// 线交叉状态
enum
{
enum
{
EYEM_CG_NOT_INTERSECTION
,
// 未相交
EYEM_CG_NOT_INTERSECTION
,
// 未相交
EYEM_CG_INTERSECTION
,
// 相交(彼此交叉)
EYEM_CG_INTERSECTION
,
// 相交(彼此交叉)
EYEM_CG_END1_CONTACT_END2
,
// 线 1 的端点和线 2 的端点接触(匹配)
EYEM_CG_END1_CONTACT_SGM2
,
// 与线 1 的端点以外的线接触
EYEM_CG_END2_CONTACT_SGM1
,
// 线 2 的端点与线 1 的端点以外的接触
EYEM_CG_SEG1_OVERLAP_SGM2
// 线 1 和线 2 重叠(如果两条线位于同一直线上)
};
};
...
@@ -645,7 +651,7 @@ extern "C" {
...
@@ -645,7 +651,7 @@ extern "C" {
EXPORTS
int
eyemEdge1dGenPosRect
(
EyemImage
tpImage
,
EyemOcsDXY
tpLineSt
,
EyemOcsDXY
tpLineEd
,
int
iWhRoi
,
int
iTransition
,
double
dSigma
,
double
dAmpThresh
,
IntPtr
*
hObject
);
EXPORTS
int
eyemEdge1dGenPosRect
(
EyemImage
tpImage
,
EyemOcsDXY
tpLineSt
,
EyemOcsDXY
tpLineEd
,
int
iWhRoi
,
int
iTransition
,
double
dSigma
,
double
dAmpThresh
,
IntPtr
*
hObject
);
EXPORTS
int
eyemEdge1dFitLine
(
IntPtr
hObject
,
int
iClippingEndPoints
,
int
iMaxIterations
,
double
dRobustCoef
,
EyemOcsDABC
*
tpLine
);
EXPORTS
int
eyemEdge1dFitLine
(
IntPtr
hObject
,
int
iClippingEndPoints
,
int
iMaxIterations
,
double
dRobustCoef
,
EyemOcsDABC
*
tpLine
);
EXPORTS
int
eyemEdge1dFitCircle
(
IntPtr
hObject
,
int
iClippingEndPoints
,
int
iMaxIterations
,
double
dRobustCoef
,
EyemOcsDXYR
*
tpCircle
);
EXPORTS
int
eyemEdge1dFitCircle
(
IntPtr
hObject
,
int
iClippingEndPoints
,
int
iMaxIterations
,
double
dRobustCoef
,
EyemOcsDXYR
*
tpCircle
);
EXPORTS
int
eyemEdge1dFindLine
(
EyemImage
tpImage
,
EyemOcsDXY
tpLineSt
,
EyemOcsDXY
tpLineEd
,
int
i
WhRoi
,
int
nCalipers
,
int
iSearchDirec
,
double
dAmpThreshold
,
const
char
*
ccTransition
,
IntPtr
*
hObject
);
EXPORTS
int
eyemEdge1dFindLine
(
EyemImage
tpImage
,
EyemOcsDXY
tpLineSt
,
EyemOcsDXY
tpLineEd
,
int
i
CapLength
,
int
iCapWidth
,
int
nCalipers
,
int
iFilterSize
,
int
iSearchDirec
,
double
dAmpThreshold
,
const
char
*
ccTransition
,
IntPtr
*
hObject
);
EXPORTS
bool
eyemEdge1dGenMeasureFree
(
IntPtr
hObject
);
EXPORTS
bool
eyemEdge1dGenMeasureFree
(
IntPtr
hObject
);
#ifdef __cplusplus
#ifdef __cplusplus
...
@@ -857,7 +863,7 @@ extern "C" {
...
@@ -857,7 +863,7 @@ extern "C" {
EXPORTS
int
eyemReleaseModel
(
IntPtr
&
hModelID
);
EXPORTS
int
eyemReleaseModel
(
IntPtr
&
hModelID
);
EXPORTS
int
eyemTrackFeature
(
EyemImage
tpPrevImg
,
EyemImage
tpNextImg
,
EyemRect3
*
tpRois
,
int
iRoiNum
,
int
*
ipResults
,
EyemImage
*
tpDstImg
);
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
);
EXPORTS
int
eyemAOIForTSAV
(
EyemImage
tpRefImg
,
EyemImage
tpNextImg
,
EyemRect3
*
tpRois
,
int
iRoiNum
);
EXPORTS
int
eyemMarkerTracing
(
EyemImage
tpImage
,
double
dThreshold
,
EyemOcsFXYR
*
tpCircle
,
bool
bHighAccuracy
=
false
);
EXPORTS
int
eyemMarkerTracing
(
EyemImage
tpImage
,
double
dThreshold
,
EyemOcsFXYR
*
tpCircle
,
EyemImage
*
tpDstImg
,
bool
bHighAccuracy
=
false
);
EXPORTS
int
eyemMulFuncTool
(
EyemImage
tpImage
,
EyemRect
tpRoi
,
const
char
*
funcName
,
double
dThreshold
,
int
iNumToIgnore
,
EyemOcsFXYR
*
tpCircle
,
EyemImage
*
tpDstImg
);
EXPORTS
int
eyemMulFuncTool
(
EyemImage
tpImage
,
EyemRect
tpRoi
,
const
char
*
funcName
,
double
dThreshold
,
int
iNumToIgnore
,
EyemOcsFXYR
*
tpCircle
,
EyemImage
*
tpDstImg
);
EXPORTS
int
eyemLibImpl
(
EyemImage
tpImage
,
EyemImage
*
tpDstImg
);
EXPORTS
int
eyemLibImpl
(
EyemImage
tpImage
,
EyemImage
*
tpDstImg
);
EXPORTS
int
eyemDrawLine
(
EyemImage
tpImage
,
EyemOcsDABC
tpLine
);
EXPORTS
int
eyemDrawLine
(
EyemImage
tpImage
,
EyemOcsDABC
tpLine
);
...
...
eyemLib/eyemLib.rc
查看文件 @
30d336d
此文件类型无法预览
eyemLib/eyemMisc.cpp
查看文件 @
30d336d
...
@@ -1727,6 +1727,7 @@ int eyemCountObjectIrregularParts(EyemImage tpImage, EyemRect tpRoi, const char
...
@@ -1727,6 +1727,7 @@ int eyemCountObjectIrregularParts(EyemImage tpImage, EyemRect tpRoi, const char
}
}
}
}
});
});
//增强到目标亮度方便显示
//增强到目标亮度方便显示
cc
+=
cv
::
Scalar
((
162
-
backThresh
),
(
162
-
backThresh
),
(
162
-
backThresh
));
cc
+=
cv
::
Scalar
((
162
-
backThresh
),
(
162
-
backThresh
),
(
162
-
backThresh
));
//去掉干扰
//去掉干扰
...
@@ -7264,7 +7265,7 @@ int eyemAOIForTSAV(EyemImage tpRefImg, EyemImage tpNextImg, EyemRect3 *tpRois, i
...
@@ -7264,7 +7265,7 @@ int eyemAOIForTSAV(EyemImage tpRefImg, EyemImage tpNextImg, EyemRect3 *tpRois, i
return
FUNC_OK
;
return
FUNC_OK
;
}
}
int
eyemMarkerTracing
(
EyemImage
tpImage
,
double
dThreshold
,
EyemOcsFXYR
*
tpCircle
,
bool
bHighAccuracy
)
int
eyemMarkerTracing
(
EyemImage
tpImage
,
double
dThreshold
,
EyemOcsFXYR
*
tpCircle
,
EyemImage
*
tpDstImg
,
bool
bHighAccuracy
)
{
{
cv
::
Mat
image
=
cv
::
Mat
(
tpImage
.
iHeight
,
tpImage
.
iWidth
,
MAKETYPE
(
tpImage
.
iDepth
,
tpImage
.
iChannels
),
tpImage
.
vpImage
).
clone
();
cv
::
Mat
image
=
cv
::
Mat
(
tpImage
.
iHeight
,
tpImage
.
iWidth
,
MAKETYPE
(
tpImage
.
iDepth
,
tpImage
.
iChannels
),
tpImage
.
vpImage
).
clone
();
...
@@ -7281,6 +7282,23 @@ int eyemMarkerTracing(EyemImage tpImage, double dThreshold, EyemOcsFXYR *tpCircl
...
@@ -7281,6 +7282,23 @@ int eyemMarkerTracing(EyemImage tpImage, double dThreshold, EyemOcsFXYR *tpCircl
cv
::
cvtColor
(
image
,
image
,
cv
::
COLOR_GRAY2BGR
);
cv
::
cvtColor
(
image
,
image
,
cv
::
COLOR_GRAY2BGR
);
}
}
//画图
cv
::
Mat
cc
=
image
.
clone
();
cv
::
Mat
imgGray
;
cv
::
cvtColor
(
image
,
imgGray
,
cv
::
COLOR_BGR2HSV
);
cv
::
Mat
mask1
,
mask2
;
cv
::
inRange
(
imgGray
,
cv
::
Scalar
(
0
,
50
,
20
),
cv
::
Scalar
(
5
,
255
,
255
),
mask1
);
cv
::
inRange
(
imgGray
,
cv
::
Scalar
(
175
,
50
,
20
),
cv
::
Scalar
(
180
,
255
,
255
),
mask2
);
cv
::
Mat
maskj
,
imageR
;
cv
::
bitwise_or
(
mask1
,
mask2
,
maskj
);
//膨胀部分区域
cv
::
bitwise_and
(
image
,
image
,
imageR
,
maskj
);
image
=
imageR
;
//归一化
//归一化
cv
::
parallel_for_
(
cv
::
Range
(
0
,
Y
),
[
&
](
const
cv
::
Range
range
)
->
void
{
cv
::
parallel_for_
(
cv
::
Range
(
0
,
Y
),
[
&
](
const
cv
::
Range
range
)
->
void
{
for
(
int
y
=
range
.
start
;
y
<
range
.
end
;
y
++
)
{
for
(
int
y
=
range
.
start
;
y
<
range
.
end
;
y
++
)
{
...
@@ -7303,7 +7321,7 @@ int eyemMarkerTracing(EyemImage tpImage, double dThreshold, EyemOcsFXYR *tpCircl
...
@@ -7303,7 +7321,7 @@ int eyemMarkerTracing(EyemImage tpImage, double dThreshold, EyemOcsFXYR *tpCircl
cv
::
threshold
(
mv
[
2
],
mask
,
dThreshold
,
255
,
cv
::
THRESH_BINARY
);
cv
::
threshold
(
mv
[
2
],
mask
,
dThreshold
,
255
,
cv
::
THRESH_BINARY
);
//去掉干扰
//去掉干扰
cv
::
morphologyEx
(
mask
,
mask
,
cv
::
MORPH_OPEN
,
cv
::
getStructuringElement
(
cv
::
MORPH_RECT
,
cv
::
Size
(
7
,
7
)));
cv
::
morphologyEx
(
mask
,
mask
,
cv
::
MORPH_OPEN
,
cv
::
getStructuringElement
(
cv
::
MORPH_RECT
,
cv
::
Size
(
3
,
3
)));
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
contours
,
contourfilter
;
std
::
vector
<
std
::
vector
<
cv
::
Point
>>
contours
,
contourfilter
;
cv
::
findContours
(
mask
,
contours
,
cv
::
RETR_TREE
,
cv
::
CHAIN_APPROX_SIMPLE
);
cv
::
findContours
(
mask
,
contours
,
cv
::
RETR_TREE
,
cv
::
CHAIN_APPROX_SIMPLE
);
...
@@ -7325,7 +7343,7 @@ int eyemMarkerTracing(EyemImage tpImage, double dThreshold, EyemOcsFXYR *tpCircl
...
@@ -7325,7 +7343,7 @@ int eyemMarkerTracing(EyemImage tpImage, double dThreshold, EyemOcsFXYR *tpCircl
}
}
};
};
bool
typeCircle
=
fals
e
;
bool
typeCircle
=
tru
e
;
if
(
typeCircle
)
{
if
(
typeCircle
)
{
//过滤
//过滤
std
::
vector
<
cv
::
Point
>
approx
;
std
::
vector
<
cv
::
Point
>
approx
;
...
@@ -7334,17 +7352,16 @@ int eyemMarkerTracing(EyemImage tpImage, double dThreshold, EyemOcsFXYR *tpCircl
...
@@ -7334,17 +7352,16 @@ int eyemMarkerTracing(EyemImage tpImage, double dThreshold, EyemOcsFXYR *tpCircl
cv
::
approxPolyDP
(
cv
::
Mat
(
contour
),
approx
,
arcL
*
0.01
,
true
);
cv
::
approxPolyDP
(
cv
::
Mat
(
contour
),
approx
,
arcL
*
0.01
,
true
);
if
(
approx
.
size
()
>
10
)
{
if
(
approx
.
size
()
>
10
)
{
cv
::
Rect
bbox
=
cv
::
boundingRect
(
contour
);
cv
::
Rect
bbox
=
cv
::
boundingRect
(
contour
);
if
(
M
AX
(
bbox
.
width
,
bbox
.
height
)
>
20
&&
((
float
)
bbox
.
width
/
(
float
)
bbox
.
height
)
>
0.8
5
&&
\
if
(
M
IN
(
bbox
.
width
,
bbox
.
height
)
>
20
&&
((
float
)
bbox
.
width
/
(
float
)
bbox
.
height
)
>
0.7
5
&&
\
((
float
)
bbox
.
width
/
(
float
)
bbox
.
height
)
<
1.
1
5
)
{
((
float
)
bbox
.
width
/
(
float
)
bbox
.
height
)
<
1.
2
5
)
{
//圆度
//圆度
double
afa
=
4.0
f
*
CV_PI
*
cv
::
contourArea
(
contour
,
false
)
/
std
::
pow
(
arcL
,
2
);
double
afa
=
4.0
f
*
CV_PI
*
cv
::
contourArea
(
contour
,
false
)
/
std
::
pow
(
arcL
,
2
);
if
(
afa
>
0.
8
5
)
{
if
(
afa
>
0.
4
5
)
{
contourfilter
.
push_back
(
contour
);
contourfilter
.
push_back
(
contour
);
}
}
}
}
}
}
}
}
std
::
vector
<
AFA
>
afas
;
std
::
vector
<
AFA
>
afas
;
//画图
//画图
for
(
auto
&
contour
:
contourfilter
)
{
for
(
auto
&
contour
:
contourfilter
)
{
...
@@ -7357,7 +7374,7 @@ int eyemMarkerTracing(EyemImage tpImage, double dThreshold, EyemOcsFXYR *tpCircl
...
@@ -7357,7 +7374,7 @@ int eyemMarkerTracing(EyemImage tpImage, double dThreshold, EyemOcsFXYR *tpCircl
}
}
double
min_err
;
double
min_err
;
EyemOcsDXYR
_tpCircle
;
EyemOcsDXYR
_tpCircle
;
eyemFitCircle
((
int
)
taPoints
.
size
(),
&
taPoints
[
0
],
1
5
,
min_err
,
_tpCircle
);
eyemFitCircle
((
int
)
taPoints
.
size
(),
&
taPoints
[
0
],
1
0
,
min_err
,
_tpCircle
);
afas
.
push_back
(
AFA
(
min_err
,
_tpCircle
));
afas
.
push_back
(
AFA
(
min_err
,
_tpCircle
));
}
}
...
@@ -7370,6 +7387,10 @@ int eyemMarkerTracing(EyemImage tpImage, double dThreshold, EyemOcsFXYR *tpCircl
...
@@ -7370,6 +7387,10 @@ int eyemMarkerTracing(EyemImage tpImage, double dThreshold, EyemOcsFXYR *tpCircl
tpCircle
->
fX
=
(
float
)
afas
[
0
].
tpCircle
.
dX
;
tpCircle
->
fX
=
(
float
)
afas
[
0
].
tpCircle
.
dX
;
tpCircle
->
fY
=
(
float
)
afas
[
0
].
tpCircle
.
dY
;
tpCircle
->
fY
=
(
float
)
afas
[
0
].
tpCircle
.
dY
;
tpCircle
->
fR
=
(
float
)
afas
[
0
].
tpCircle
.
dR
;
tpCircle
->
fR
=
(
float
)
afas
[
0
].
tpCircle
.
dR
;
//画图
cv
::
rectangle
(
cc
,
cv
::
Rect
(
cv
::
Point2f
(
tpCircle
->
fX
-
2.0
f
*
tpCircle
->
fR
,
tpCircle
->
fY
-
2.0
f
*
tpCircle
->
fR
),
cv
::
Point2f
(
tpCircle
->
fX
+
2.0
f
*
tpCircle
->
fR
,
tpCircle
->
fY
+
2.0
f
*
tpCircle
->
fR
)),
cv
::
Scalar
(
0
,
255
,
255
),
4
);
cv
::
drawMarker
(
cc
,
cv
::
Point2f
(
tpCircle
->
fX
,
tpCircle
->
fY
),
cv
::
Scalar
(
0
,
255
,
0
),
cv
::
MARKER_CROSS
,
20
,
1
);
}
}
else
{
else
{
std
::
vector
<
AFA
>
rboxes
;
std
::
vector
<
AFA
>
rboxes
;
...
@@ -7401,6 +7422,21 @@ int eyemMarkerTracing(EyemImage tpImage, double dThreshold, EyemOcsFXYR *tpCircl
...
@@ -7401,6 +7422,21 @@ int eyemMarkerTracing(EyemImage tpImage, double dThreshold, EyemOcsFXYR *tpCircl
tpCircle
->
fY
=
(
float
)
rboxes
[
0
].
tpCircle
.
dY
;
tpCircle
->
fY
=
(
float
)
rboxes
[
0
].
tpCircle
.
dY
;
tpCircle
->
fR
=
(
float
)
rboxes
[
0
].
tpCircle
.
dR
;
tpCircle
->
fR
=
(
float
)
rboxes
[
0
].
tpCircle
.
dR
;
}
}
//<输出结果图像
tpDstImg
->
iWidth
=
cc
.
cols
;
tpDstImg
->
iHeight
=
cc
.
rows
;
tpDstImg
->
iDepth
=
cc
.
depth
();
tpDstImg
->
iChannels
=
cc
.
channels
();
//内存尺寸
int
_Size
=
tpDstImg
->
iWidth
*
tpDstImg
->
iHeight
*
tpDstImg
->
iChannels
*
sizeof
(
uint8_t
);
//分配初始化内存
tpDstImg
->
vpImage
=
(
uint8_t
*
)
malloc
(
_Size
);
if
(
NULL
==
tpDstImg
->
vpImage
)
return
FUNC_NOT_ENOUGH_MEM
;
memset
(
tpDstImg
->
vpImage
,
0
,
_Size
);
//拷贝数据
memcpy
(
tpDstImg
->
vpImage
,
cc
.
data
,
_Size
);
return
FUNC_OK
;
return
FUNC_OK
;
}
}
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论