我有一个斑点,其中有3个字母。我已经提取了斑点信息,还使用了轮廓分析来查找字母的轮廓,并将其用作OCR,并使用emguCV将其检测为字符。当用户单击Blob时,我正在使用pictureBox1_Click事件显示Blob信息。但是,逻辑不显示斑点内的所有3个字母,而是显示我单击斑点内的字母。如果我单击A,它会显示A,但我希望在blob中单击的任何位置都应在文本框中显示所有3个。
这是我的代码:
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
int x = e.X - 1;
int y = e.Y - 1;
if ((pictureBox1.Image != null) && (x >= 0) && (y >= 0) &&
(x < pictureBox1.Image.Width) && (y < pictureBox1.Image.Height))
{
int blobID = blobCounter.ObjectLabels[y * pictureBox1.Image.Width + x];
if (blobID != 0)
{
Invalidate();
string s = "";
foreach (Blob blobss in blobs)
{
if(blobss.ID == blobID)
{
//Extract letter coordinates and name
foreach (FoundCharacter found in processor.foundTemplates)
{
Rectangle foundRect = found.sample.contour.SourceBoundingRect;
int x1 = foundRect.X;
int y1 = foundRect.Y;
s = found.template.name;
if ((x1 < x) && (y1 < y))
{
txtchar.Text = s;
}
}
}
}
}
}
}