Commit 9e086d51 SK

其他Blob的label导致的死循环

1 个父辈 cc99ba63
......@@ -715,6 +715,7 @@ namespace Acc.Img
while (true)
{
bool hasFind = false;
bool hasPixToHandle = false;
for (int x = blob.MinX; x< blob.MaxX; x++)
{
for (int y = blob.MinY; y < blob.MaxY; y++)
......@@ -729,6 +730,7 @@ namespace Acc.Img
//matDistanceArr[x, y] = 0;
continue;
}
hasPixToHandle = true;
if (!item.isEnd)
{
double distanceToCircle = item.minDistanceToCircles(x, y, reelCenter);
......@@ -766,7 +768,7 @@ namespace Acc.Img
{
item.calOneItem(oneBlobRadius);
}
if (item.isEnd)
if (item.isEnd || hasPixToHandle)
{
break;
}
......@@ -869,7 +871,7 @@ namespace Acc.Img
}
}
//放大宽度,防止误判断
maxWidth = maxWidth * 1.02;
maxWidth = maxWidth * 1.1;
Console.WriteLine("Start count");
int totalCount = 0;
foreach (CvBlob blob in blobs.Values)
......@@ -903,10 +905,10 @@ namespace Acc.Img
Circle c = groupCircle[0];
srcMat.Circle(c.x, c.y, (int)c.radius/2, Scalar.Yellow);
totalCount = totalCount + 1;
foreach (Circle cg in groupCircle)
{
srcMat.Circle(cg.x, cg.y, (int)c.radius, color);
}
//foreach (Circle cg in groupCircle)
//{
// srcMat.Circle(cg.x, cg.y, (int)c.radius, color);
//}
}
}
}
......@@ -1057,13 +1059,17 @@ namespace Acc.Img
image = BitmapConverter.ToBitmap(dst);
CvBlobs blobs = new CvBlobs();
blobs.Label(dst);
int blobArea = -1;
foreach(CvBlob blob in blobs.Values) {
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;
}
}
}
......@@ -31,7 +31,7 @@ namespace AccImage
{
//与平均半径差值在10%以内,认为OK
double diff = avgRadius - currentMaxRadius;
if (diff/avgRadius <= 0.3)
if (diff/avgRadius <= 0.4)
{
isValid = true;
}
......@@ -50,13 +50,17 @@ namespace AccImage
currentMaxRadius = 0;
centerX = 0;
centerY = 0;
//平均半径
double total = 0;
foreach (Circle c in circles)
////平均半径
//double total = 0;
//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
{
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!