我有一个使用EMGUCV检测某些斑点内的文本的类。我还有另一个类,它使用Aforge分别处理blob信息。在第二个类中,我试图识别Blob中的文本并将其分别显示在文本框中。但是我得到的只是一串由所有blob数据组成的联合字符,而不是应该在那1个blob中的数据。
这是代码:
Bitmap sourceImage = (Bitmap)(pictureBox1.Image);
blobCounter.ProcessImage(sourceImage);
blobs = blobCounter.GetObjectsInformation();
Graphics g = pictureBox1.CreateGraphics();
foreach (Blob blob in blobs)
{
if(blob.ID == userset)
{
string s = "";
foreach (FoundTemplateDesc found in processor.foundTemplates)
{
Font font = new Font(Font.FontFamily, 24);//16
Brush foreBrush = new SolidBrush(Color.White));
Pen borderPen = new Pen(Color.Green);
Rectangle foundRect = found.sample.contour.SourceBoundingRect;
System.Drawing.Point p1 = new System.Drawing.Point((foundRect.Left
+ foundRect.Right) / 2, foundRect.Top);
string text = found.template.name;
s += found.template.name;
g.DrawRectangle(borderPen, foundRect);
g.DrawString(text, font, foreBrush, new PointF(p1.X - font.Height
/ 3, p1.Y - font.Height));
TextBox9.Text = s;
}
}
}
我得到的结果是1234567890,而不是我选择的blobID中的数据123。