private void startDetectBtn_Click(object sender, EventArgs e) { DetectionFields fields = new DetectionFields(); DetectionField f = new DetectionField(); f.TopLeft = new Point(212, 359); f.Size = new Size(233, 531); f.NumOfRows = 10; f.NumOfCols = 5; f.Ident = "SoBaoDanh"; fields.addField(f); // drawDetectionField(f); List <DataHolder> data = new List <DataHolder>(); for (int i = 0; i < f.NumOfRows; i++) { for (int j = 0; j < f.NumOfCols; j++) { DataHolder dh = new DataHolder(); dh.Col = j; dh.Row = i; dh.Ident = f.Ident; dh.Score = recognizeCell(f.TopLeft.X + f.Size.Width * j / f.NumOfCols, f.TopLeft.X + f.Size.Width * (j + 1) / f.NumOfCols, f.TopLeft.Y + f.Size.Height * i / f.NumOfRows, f.TopLeft.Y + f.Size.Height * (i + 1) / f.NumOfRows); data.Add(dh); } } Console.WriteLine("Detection of field completed!"); imageBox1.Image = colorImage; }
private void drawDetectionField(DetectionField f) { CvInvoke.Rectangle(colorImage, new Rectangle(f.TopLeft, f.Size), redColor); for (int i = 1; i < f.NumOfCols; i++) { CvInvoke.Line(colorImage, new Point(f.TopLeft.X + f.Size.Width * i / f.NumOfCols, f.TopLeft.Y), new Point(f.TopLeft.X + f.Size.Width * i / f.NumOfCols, f.TopLeft.Y + f.Size.Height), redColor); } for (int i = 1; i < f.NumOfRows; i++) { CvInvoke.Line(colorImage, new Point(f.TopLeft.X, f.TopLeft.Y + f.Size.Height * i / f.NumOfRows), new Point(f.TopLeft.X + f.Size.Width, f.TopLeft.Y + f.Size.Height * i / f.NumOfRows), redColor); } }
public void addField(DetectionField d) { detectionFields.Add(d); }