/// <summary> /// Adjusts the bounding box. /// </summary> /// <returns>The bounding box.</returns> /// <param name="rowIndicatorColumn">Row indicator column.</param> private static BoundingBox adjustBoundingBox(DetectionResultRowIndicatorColumn rowIndicatorColumn) { if (rowIndicatorColumn == null) { return(null); } int[] rowHeights = rowIndicatorColumn.getRowHeights(); if (rowHeights == null) { return(null); } int maxRowHeight = getMax(rowHeights); int missingStartRows = 0; foreach (int rowHeight in rowHeights) { missingStartRows += maxRowHeight - rowHeight; if (rowHeight > 0) { break; } } Codeword[] codewords = rowIndicatorColumn.Codewords; for (int row = 0; missingStartRows > 0 && codewords[row] == null; row++) { missingStartRows--; } int missingEndRows = 0; for (int row = rowHeights.Length - 1; row >= 0; row--) { missingEndRows += maxRowHeight - rowHeights[row]; if (rowHeights[row] > 0) { break; } } for (int row = codewords.Length - 1; missingEndRows > 0 && codewords[row] == null; row--) { missingEndRows--; } return(rowIndicatorColumn.Box.addMissingRows(missingStartRows, missingEndRows, rowIndicatorColumn.IsLeft)); }
/// <summary> /// Adjusts the bounding box. /// </summary> /// <returns>The bounding box.</returns> /// <param name="rowIndicatorColumn">Row indicator column.</param> private static BoundingBox adjustBoundingBox(DetectionResultRowIndicatorColumn rowIndicatorColumn) { if (rowIndicatorColumn == null) { return null; } int[] rowHeights = rowIndicatorColumn.getRowHeights(); if (rowHeights == null) { return null; } int maxRowHeight = getMax(rowHeights); int missingStartRows = 0; foreach (int rowHeight in rowHeights) { missingStartRows += maxRowHeight - rowHeight; if (rowHeight > 0) { break; } } Codeword[] codewords = rowIndicatorColumn.Codewords; for (int row = 0; missingStartRows > 0 && codewords[row] == null; row++) { missingStartRows--; } int missingEndRows = 0; for (int row = rowHeights.Length - 1; row >= 0; row--) { missingEndRows += maxRowHeight - rowHeights[row]; if (rowHeights[row] > 0) { break; } } for (int row = codewords.Length - 1; missingEndRows > 0 && codewords[row] == null; row--) { missingEndRows--; } return rowIndicatorColumn.Box.addMissingRows(missingStartRows, missingEndRows, rowIndicatorColumn.IsLeft); }