private void addIdentificationNumberField() { Detection.DetectionField f = new Detection.DetectionField(); f.FieldType = "QUESTION_COL"; f.Ident = "MSSV"; f.NumOfCols = 8; f.NumOfRows = 10; f.ResultType = "NUMERIC"; f.TopLeft = new System.Drawing.Point(1674, 266); f.Size = new System.Drawing.Size(425, 501); template.addField(f); }
private void fieldWithMarginVertical(int topX, int topY, int bottomY, int width, int height, int numOfFields, string identPrefix, int numOfCols, int numOfRows, string fieldType) { for (int i = 1; i <= numOfFields; i++) { Detection.DetectionField f = new Detection.DetectionField(); f.FieldType = fieldType; f.Ident = identPrefix + "_" + i; f.NumOfCols = numOfCols; f.NumOfRows = numOfRows; f.ResultType = "NUMERIC"; // First item @4, 893, Last item @4, 2842 int topYCurrent = topY + (i - 1) * (bottomY - topY) / (numOfFields - 1); f.TopLeft = new System.Drawing.Point(topX, topYCurrent); f.Size = new System.Drawing.Size(width, height); template.addField(f); } }
private void allCellsRecognize(Detection.DetectionField f) { for (int i = 0; i < f.NumOfRows; i++) { for (int j = 0; j < f.NumOfCols; j++) { Result.Response dh = new Result.Response(); dh.Col = j; dh.Row = i; dh.Ident = f.Ident; dh.Score = (int)recognizeCell(f.TopLeft.X + f.Size.Width * j / f.NumOfCols, Math.Min(f.TopLeft.X + f.Size.Width * (j + 1) / f.NumOfCols, convertedWThreshold.Width - 1), f.TopLeft.Y + f.Size.Height * i / f.NumOfRows, Math.Min(f.TopLeft.Y + f.Size.Height * (i + 1) / f.NumOfRows, convertedWThreshold.Height - 1)); // Console.WriteLine("Cell " + dh.Ident + " @" + dh.Row + "/" + dh.Col + ": " + dh.Score); resultManager.Result.Add(dh); } } }