Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
ReelCounter
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit 9e086d51
由
SK
编写于
2019-04-15 15:33:03 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
其他Blob的label导致的死循环
1 个父辈
cc99ba63
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
14 行删除
AccImage/ImageUtil.cs
AccImage/SplitItem.cs
AccImage/ImageUtil.cs
查看文件 @
9e086d5
...
@@ -715,6 +715,7 @@ namespace Acc.Img
...
@@ -715,6 +715,7 @@ namespace Acc.Img
while
(
true
)
while
(
true
)
{
{
bool
hasFind
=
false
;
bool
hasFind
=
false
;
bool
hasPixToHandle
=
false
;
for
(
int
x
=
blob
.
MinX
;
x
<
blob
.
MaxX
;
x
++)
for
(
int
x
=
blob
.
MinX
;
x
<
blob
.
MaxX
;
x
++)
{
{
for
(
int
y
=
blob
.
MinY
;
y
<
blob
.
MaxY
;
y
++)
for
(
int
y
=
blob
.
MinY
;
y
<
blob
.
MaxY
;
y
++)
...
@@ -729,6 +730,7 @@ namespace Acc.Img
...
@@ -729,6 +730,7 @@ namespace Acc.Img
//matDistanceArr[x, y] = 0;
//matDistanceArr[x, y] = 0;
continue
;
continue
;
}
}
hasPixToHandle
=
true
;
if
(!
item
.
isEnd
)
if
(!
item
.
isEnd
)
{
{
double
distanceToCircle
=
item
.
minDistanceToCircles
(
x
,
y
,
reelCenter
);
double
distanceToCircle
=
item
.
minDistanceToCircles
(
x
,
y
,
reelCenter
);
...
@@ -766,7 +768,7 @@ namespace Acc.Img
...
@@ -766,7 +768,7 @@ namespace Acc.Img
{
{
item
.
calOneItem
(
oneBlobRadius
);
item
.
calOneItem
(
oneBlobRadius
);
}
}
if
(
item
.
isEnd
)
if
(
item
.
isEnd
||
hasPixToHandle
)
{
{
break
;
break
;
}
}
...
@@ -869,7 +871,7 @@ namespace Acc.Img
...
@@ -869,7 +871,7 @@ namespace Acc.Img
}
}
}
}
//放大宽度,防止误判断
//放大宽度,防止误判断
maxWidth
=
maxWidth
*
1.
02
;
maxWidth
=
maxWidth
*
1.
1
;
Console
.
WriteLine
(
"Start count"
);
Console
.
WriteLine
(
"Start count"
);
int
totalCount
=
0
;
int
totalCount
=
0
;
foreach
(
CvBlob
blob
in
blobs
.
Values
)
foreach
(
CvBlob
blob
in
blobs
.
Values
)
...
@@ -903,10 +905,10 @@ namespace Acc.Img
...
@@ -903,10 +905,10 @@ namespace Acc.Img
Circle
c
=
groupCircle
[
0
];
Circle
c
=
groupCircle
[
0
];
srcMat
.
Circle
(
c
.
x
,
c
.
y
,
(
int
)
c
.
radius
/
2
,
Scalar
.
Yellow
);
srcMat
.
Circle
(
c
.
x
,
c
.
y
,
(
int
)
c
.
radius
/
2
,
Scalar
.
Yellow
);
totalCount
=
totalCount
+
1
;
totalCount
=
totalCount
+
1
;
foreach
(
Circle
cg
in
groupCircle
)
//
foreach (Circle cg in groupCircle)
{
//
{
srcMat
.
Circle
(
cg
.
x
,
cg
.
y
,
(
int
)
c
.
radius
,
color
);
//
srcMat.Circle(cg.x, cg.y, (int)c.radius, color);
}
//
}
}
}
}
}
}
}
...
@@ -1057,13 +1059,17 @@ namespace Acc.Img
...
@@ -1057,13 +1059,17 @@ namespace Acc.Img
image
=
BitmapConverter
.
ToBitmap
(
dst
);
image
=
BitmapConverter
.
ToBitmap
(
dst
);
CvBlobs
blobs
=
new
CvBlobs
();
CvBlobs
blobs
=
new
CvBlobs
();
blobs
.
Label
(
dst
);
blobs
.
Label
(
dst
);
int
blobArea
=
-
1
;
foreach
(
CvBlob
blob
in
blobs
.
Values
)
{
foreach
(
CvBlob
blob
in
blobs
.
Values
)
{
if
(
blob
.
Rect
.
Contains
(
new
OpenCvSharp
.
Point
(
markX
,
markY
)))
if
(
blob
.
Rect
.
Contains
(
new
OpenCvSharp
.
Point
(
markX
,
markY
)))
{
{
return
blob
.
Area
;
if
(
blob
.
Area
<
blobArea
||
blobArea
==
-
1
)
{
blobArea
=
blob
.
Area
;
}
}
}
}
}
return
-
1
;
return
blobArea
;
}
}
}
}
}
}
AccImage/SplitItem.cs
查看文件 @
9e086d5
...
@@ -31,7 +31,7 @@ namespace AccImage
...
@@ -31,7 +31,7 @@ namespace AccImage
{
{
//与平均半径差值在10%以内,认为OK
//与平均半径差值在10%以内,认为OK
double
diff
=
avgRadius
-
currentMaxRadius
;
double
diff
=
avgRadius
-
currentMaxRadius
;
if
(
diff
/
avgRadius
<=
0.
3
)
if
(
diff
/
avgRadius
<=
0.
4
)
{
{
isValid
=
true
;
isValid
=
true
;
}
}
...
@@ -50,13 +50,17 @@ namespace AccImage
...
@@ -50,13 +50,17 @@ namespace AccImage
currentMaxRadius
=
0
;
currentMaxRadius
=
0
;
centerX
=
0
;
centerX
=
0
;
centerY
=
0
;
centerY
=
0
;
//平均半径
////平均半径
double
total
=
0
;
//double total = 0;
foreach
(
Circle
c
in
circles
)
//foreach (Circle c in circles)
//{
// total = total + c.radius;
//}
//avgRadius = total / circles.Count;
if
(
circle
.
radius
>
avgRadius
)
{
{
total
=
total
+
c
.
radius
;
avgRadius
=
circle
.
radius
;
}
}
avgRadius
=
total
/
circles
.
Count
;
}
}
else
else
{
{
...
...
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论