Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
张士柳
/
eyemLib
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
图表
网络
创建新的问题
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 201558f5
由
张士柳
编写于
2021-02-24 17:38:07 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
无
1 个父辈
8939e507
全部展开
显示空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
36 行增加
和
39 行删除
eyemLib-Sharp/EyemLib.cs
eyemLib-Sharp/EyemLibDemo.cs
eyemLib-Sharp/eyemLib-Sharp.csproj
eyemLib/eyemLib.rc
eyemLib/eyemMisc.cpp
eyemLib-Sharp/EyemLib.cs
查看文件 @
201558f
...
@@ -905,7 +905,7 @@ namespace eyemLib_Sharp
...
@@ -905,7 +905,7 @@ namespace eyemLib_Sharp
string
file
=
fileName
.
Split
(
new
string
[]
{
"\\"
},
StringSplitOptions
.
RemoveEmptyEntries
)[
2
];
string
file
=
fileName
.
Split
(
new
string
[]
{
"\\"
},
StringSplitOptions
.
RemoveEmptyEntries
)[
2
];
//"IP_SMALL_PARTS","IP_LARGE_PARTS","IP_LONG_PARTS",""
//"IP_SMALL_PARTS","IP_LARGE_PARTS","IP_LONG_PARTS",""
//eyemCountObject(ucpImage, file.Replace(".png", ""), 35, 0, 100, 5, ref pNumObj, out tpDstImg);
//eyemCountObject(ucpImage, file.Replace(".png", ""), 35, 0, 100, 5, ref pNumObj, out tpDstImg);
eyemCountObjectIrregularParts
(
image
,
file
.
Replace
(
".png"
,
""
),
"IP_LARGE_PARTS"
,
""
,
0.7
,
ref
pNumObj
,
out
tpDstImg
);
eyemCountObjectIrregularParts
(
image
,
file
.
Replace
(
".png"
,
""
),
"IP_LARGE_PARTS"
,
"
D://批量测试图像//template.png
"
,
0.7
,
ref
pNumObj
,
out
tpDstImg
);
//int ipNum; EyemBarCode* tpResults;
//int ipNum; EyemBarCode* tpResults;
//DataCodeHandle hObject;
//DataCodeHandle hObject;
//int iRes = eyemDetectAndDecode(image, tpRoi, file.Replace(".png", ""), "QR_CODE|DATA_MATRIX|CODE_39|CODE_128", out hObject, out tpResults, out ipNum, false, 11, 5, 128, 256, 1d);
//int iRes = eyemDetectAndDecode(image, tpRoi, file.Replace(".png", ""), "QR_CODE|DATA_MATRIX|CODE_39|CODE_128", out hObject, out tpResults, out ipNum, false, 11, 5, 128, 256, 1d);
...
@@ -934,12 +934,13 @@ namespace eyemLib_Sharp
...
@@ -934,12 +934,13 @@ namespace eyemLib_Sharp
EyemRect3
roi4
=
new
EyemRect3
();
EyemRect3
roi4
=
new
EyemRect3
();
roi4
.
iXs
=
303
;
roi4
.
iYs
=
400
;
roi4
.
iWidth
=
100
;
roi4
.
iHeight
=
100
;
roi4
.
dVar
=
0.35
;
roi4
.
iXs
=
303
;
roi4
.
iYs
=
400
;
roi4
.
iWidth
=
100
;
roi4
.
iHeight
=
100
;
roi4
.
dVar
=
0.35
;
//需要监控的位置
//需要监控的位置
信息
tpRois
.
Add
(
roi1
);
tpRois
.
Add
(
roi2
);
tpRois
.
Add
(
roi3
);
tpRois
.
Add
(
roi4
);
tpRois
.
Add
(
roi1
);
tpRois
.
Add
(
roi2
);
tpRois
.
Add
(
roi3
);
tpRois
.
Add
(
roi4
);
//转内存指针
//
结构体
转内存指针
IntPtr
hGlobal
=
eyemStructArray2IntPtr
(
tpRois
.
ToArray
());
IntPtr
hGlobal
=
eyemStructArray2IntPtr
(
tpRois
.
ToArray
());
//读取视频接口
int
ipNum
;
EyemImage
*
tpImages
;
int
ipNum
;
EyemImage
*
tpImages
;
VideoHandle
hObject
;
VideoHandle
hObject
;
eyemVideoCapture
(
fileName
,
out
hObject
,
out
tpImages
,
out
ipNum
);
eyemVideoCapture
(
fileName
,
out
hObject
,
out
tpImages
,
out
ipNum
);
...
@@ -950,6 +951,7 @@ namespace eyemLib_Sharp
...
@@ -950,6 +951,7 @@ namespace eyemLib_Sharp
//类似于实时采集的图像
//类似于实时采集的图像
for
(
int
i
=
1
;
i
<
ipNum
;
i
++)
for
(
int
i
=
1
;
i
<
ipNum
;
i
++)
{
{
//存放结果
int
[]
iArrRes
=
new
int
[
tpRois
.
Count
];
int
[]
iArrRes
=
new
int
[
tpRois
.
Count
];
//fixed (int* ipResults = &iArrRes[0])
//fixed (int* ipResults = &iArrRes[0])
//{
//{
...
...
eyemLib-Sharp/EyemLibDemo.cs
0 → 100644
查看文件 @
201558f
此文件的差异被折叠,
点击展开。
eyemLib-Sharp/eyemLib-Sharp.csproj
查看文件 @
201558f
...
@@ -49,6 +49,7 @@
...
@@ -49,6 +49,7 @@
</ItemGroup>
</ItemGroup>
<ItemGroup>
<ItemGroup>
<Compile Include="EyemLib.cs" />
<Compile Include="EyemLib.cs" />
<Compile Include="EyemLibDemo.cs" />
<Compile Include="Program.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
</ItemGroup>
...
...
eyemLib/eyemLib.rc
查看文件 @
201558f
此文件类型无法预览
eyemLib/eyemMisc.cpp
查看文件 @
201558f
...
@@ -1444,27 +1444,28 @@ int eyemCountObjectIrregularParts(EyemImage tpImage, const char *fileName, const
...
@@ -1444,27 +1444,28 @@ int eyemCountObjectIrregularParts(EyemImage tpImage, const char *fileName, const
//使用大料算法
//使用大料算法
else
if
(
strcmp
(
ccSubType
,
"IP_LARGE_PARTS"
)
==
0
)
else
if
(
strcmp
(
ccSubType
,
"IP_LARGE_PARTS"
)
==
0
)
{
{
//cv::imwrite("tplResult.png", srcPrev);
int
tplWidth
,
tplHeight
,
tplDstWidth
,
tplDstHeight
;
int
tplWidth
,
tplHeight
,
tplDstWidth
,
tplDstHeight
;
//用八个方向的模板进行模板匹配
//加载模板
cv
::
Mat
tplResult
(
Y
,
X
,
CV_32F
,
cv
::
Scalar
(
0
));
//std::vector<cv::Mat> tplResults;
const
float
icvDirections
[
9
]
=
{
-
180
,
-
135
,
-
90
,
-
45
,
0
,
45
,
90
,
135
,
180
};
for
(
int
tpl
=
0
;
tpl
<
8
;
tpl
++
)
{
cv
::
Mat
tplMat
=
cv
::
imread
(
"D://批量测试图像//template.png"
,
-
1
);
cv
::
Mat
tplMat
=
cv
::
imread
(
"D://批量测试图像//template.png"
,
-
1
);
tplWidth
=
tplMat
.
cols
,
tplHeight
=
tplMat
.
rows
;
tplWidth
=
tplMat
.
cols
,
tplHeight
=
tplMat
.
rows
;
//用八个方向的模板进行模板匹配(模板匹配的方式对于发生形变的器件效果不好)
const
float
icvDirections
[
4
]
=
{
-
180
,
-
90
,
0
,
90
};
//用以计算元件中心
const
int
icvDirectionDeltas
[
4
][
2
]
=
{
{
tplWidth
/
2
,
tplHeight
/
2
},{
tplHeight
/
2
,
tplWidth
/
2
},{
tplWidth
/
2
,
tplHeight
/
2
},{
tplHeight
/
2
,
tplWidth
/
2
}
};
cv
::
Mat
sinParts
(
Y
,
X
,
CV_8UC1
,
cv
::
Scalar
(
0
));
for
(
int
tpl
=
0
;
tpl
<
4
;
tpl
++
)
{
float
t
=
icvDirections
[
tpl
];
float
t
=
icvDirections
[
tpl
];
tplDstWidth
=
tplHeight
*
abs
(
sin
(
t
*
CV_PI
/
180
))
+
tplWidth
*
abs
(
cos
(
t
*
CV_PI
/
180
));
tplDstWidth
=
cvRound
((
double
)
tplHeight
*
abs
(
sin
(
t
*
CV_PI
/
180
))
+
(
double
)
tplWidth
*
abs
(
cos
(
t
*
CV_PI
/
180
)
));
tplDstHeight
=
c
eil
(
tplWidth
*
abs
(
sin
(
t
*
CV_PI
/
180
))
+
tplHeight
*
abs
(
cos
(
t
*
CV_PI
/
180
)));
tplDstHeight
=
c
vRound
(
ceil
((
double
)
tplWidth
*
abs
(
sin
(
t
*
CV_PI
/
180
))
+
(
double
)
tplHeight
*
abs
(
cos
(
t
*
CV_PI
/
180
)
)));
cv
::
Mat
matx23f
(
2
,
3
,
CV_64F
);
cv
::
Mat
matx23f
(
2
,
3
,
CV_64F
);
matx23f
=
cv
::
getRotationMatrix2D
(
cv
::
Point2f
((
float
)
tplWidth
/
2.0
f
-
0.5
f
,
(
float
)
tplHeight
/
2.0
f
-
0.5
f
),
t
,
1.0
);
matx23f
=
cv
::
getRotationMatrix2D
(
cv
::
Point2f
((
float
)
tplWidth
/
2.0
f
-
0.5
f
,
(
float
)
tplHeight
/
2.0
f
-
0.5
f
),
t
,
1.0
);
...
@@ -1474,42 +1475,32 @@ int eyemCountObjectIrregularParts(EyemImage tpImage, const char *fileName, const
...
@@ -1474,42 +1475,32 @@ int eyemCountObjectIrregularParts(EyemImage tpImage, const char *fileName, const
matx23f
.
ptr
<
double
>
(
1
)[
2
]
+=
(
float
)(
tplDstHeight
-
tplHeight
)
/
2.0
;
matx23f
.
ptr
<
double
>
(
1
)[
2
]
+=
(
float
)(
tplDstHeight
-
tplHeight
)
/
2.0
;
//旋转
//旋转
cv
::
warpAffine
(
tplMat
,
tplMat
,
matx23f
,
cv
::
Size
((
int
)
tplDstWidth
,
(
int
)
tplDstHeight
),
cv
::
INTER_CUBIC
);
cv
::
Mat
tplMatD
;
cv
::
warpAffine
(
tplMat
,
tplMatD
,
matx23f
,
cv
::
Size
((
int
)
tplDstWidth
,
(
int
)
tplDstHeight
),
cv
::
INTER_LINEAR
,
cv
::
BORDER_CONSTANT
,
cv
::
Scalar
(
0
));
//模板匹配
//模板匹配
cv
::
Mat
tplResult0
;
cv
::
Mat
tplResult0
;
cv
::
matchTemplate
(
srcPrev
,
tplMat
,
tplResult0
,
cv
::
TM_CCOEFF_NORMED
);
cv
::
matchTemplate
(
srcPrev
,
tplMatD
,
tplResult0
,
cv
::
TM_CCOEFF_NORMED
);
//为什么尺寸会发生比那花
//各个方向图取最大值
cv
::
max
(
tplResult0
,
tplResult
,
tplResult
);
//为什么尺寸会发生变化
int
bottom
,
right
;
bottom
=
(
Y
-
tplResult0
.
rows
),
right
=
(
X
-
tplResult0
.
cols
);
cv
::
copyMakeBorder
(
tplResult0
,
tplResult0
,
0
,
bottom
,
0
,
right
,
cv
::
BORDER_CONSTANT
,
cv
::
Scalar
(
0
));
//分数大于0.7才当作元件处理
//tplResults.push_back(tplResult
);
cv
::
add
(
cv
::
Mat
(
tplResult0
>
dMinScore
)
/
255
,
sinParts
,
sinParts
);
}
}
////
//sinParts += bin;
////分数大于0.7才当作元件处理
////连通域分析
//cv::Mat bin;
//bin = tplResult > dMinScore;
//std::vector<cv::Point> pts;
//cv::Mat labels, stats, centroids;
//cv::Mat labels, stats, centroids;
//int nccomps2 = cv::connectedComponentsWithStats(bin, labels, stats, centroids);
//int nccomps2 = cv::connectedComponentsWithStats(bin, labels, stats, centroids);
//for (int i = 1; i < nccomps2; i++) {
//for (int i = 1; i < nccomps2; i++) {
//
pts.push_back(cv::Point(cvRound(centroids.ptr<double>(i)[1]), cvRound(centroids.ptr<double>(i)[0])
));
//
cv::drawMarker(cc, cv::Point(cvRound(centroids.ptr<double>(i)[0]) + icvDirectionDeltas[tpl][0], cvRound(centroids.ptr<double>(i)[1]) + icvDirectionDeltas[tpl][1]), cv::Scalar(0, 255, 0, 255
));
//}
//}
//for (int t = 0; t < (int)pts.size(); t++)
cv
::
imwrite
(
"tplResult.png"
,
cc
);
//{
// cv::rectangle(cc, cv::Rect(pts[t].y, pts[t].x, templ.cols, templ.rows), cv::Scalar(0, 255, 0, 255), 1);
//}
//cv::imwrite("tplResult.png", cc);
//二值化
//二值化
cv
::
threshold
(
srcPrev
,
binary
,
0
,
255
,
cv
::
THRESH_BINARY
|
cv
::
THRESH_OTSU
);
cv
::
threshold
(
srcPrev
,
binary
,
0
,
255
,
cv
::
THRESH_BINARY
|
cv
::
THRESH_OTSU
);
...
@@ -2878,6 +2869,9 @@ int eyemTrackFeature(EyemImage tpRefImg, EyemImage tpNextImg, EyemRect3 *tpRois,
...
@@ -2878,6 +2869,9 @@ int eyemTrackFeature(EyemImage tpRefImg, EyemImage tpNextImg, EyemRect3 *tpRois,
cv
::
Mat
nextImg
(
tpNextImg
.
iHeight
,
tpNextImg
.
iWidth
,
cv
::
Mat
nextImg
(
tpNextImg
.
iHeight
,
tpNextImg
.
iWidth
,
MAKETYPE
(
tpNextImg
.
iDepth
,
tpNextImg
.
iChannels
),
tpNextImg
.
vpImage
);
MAKETYPE
(
tpNextImg
.
iDepth
,
tpNextImg
.
iChannels
),
tpNextImg
.
vpImage
);
if
(
refImg
.
empty
()
|
nextImg
.
empty
())
return
FUNC_IMAGE_NOT_EXIST
;
cv
::
cvtColor
(
refImg
,
refImg
,
cv
::
COLOR_BGR2GRAY
);
cv
::
cvtColor
(
refImg
,
refImg
,
cv
::
COLOR_BGR2GRAY
);
cv
::
cvtColor
(
nextImg
,
nextImg
,
cv
::
COLOR_BGR2GRAY
);
cv
::
cvtColor
(
nextImg
,
nextImg
,
cv
::
COLOR_BGR2GRAY
);
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论