diff --git a/src/textord/tablerecog.cpp b/src/textord/tablerecog.cpp index 705473395..16e4bb9b4 100644 --- a/src/textord/tablerecog.cpp +++ b/src/textord/tablerecog.cpp @@ -59,6 +59,28 @@ const double kGoodRowNumberOfColumnsLarge = 0.7; // be considered "filled" const double kMinFilledArea = 0.35; +// Indicates that a table row is weak. This means that it has +// many missing data cells or very large cell heights compared. +// to the rest of the table. +// Code is buggy right now. It is disabled in the calling function. +// It seems like sometimes the row that is passed in is not correct +// sometimes (like a phantom row is introduced). There's something going +// on in the cell_y_ data member before this is called... not certain. +static bool IsWeakTableRow(StructuredTable *table, int row) { + if (!table->VerifyRowFilled(row)) { + return false; + } + + double threshold; + if (table->column_count() < countof(kGoodRowNumberOfColumnsSmall)) { + threshold = kGoodRowNumberOfColumnsSmall[table->column_count()]; + } else { + threshold = table->column_count() * kGoodRowNumberOfColumnsLarge; + } + + return table->CountFilledCellsInRow(row) < threshold; +} + //////// //////// StructuredTable Class //////// @@ -1059,23 +1081,4 @@ int TableRecognizer::NextHorizontalSplit(int left, int right, int y, bool top_to return last_y; } -// Code is buggy right now. It is disabled in the calling function. -// It seems like sometimes the row that is passed in is not correct -// sometimes (like a phantom row is introduced). There's something going -// on in the cell_y_ data member before this is called... not certain. -bool TableRecognizer::IsWeakTableRow(StructuredTable *table, int row) { - if (!table->VerifyRowFilled(row)) { - return false; - } - - double threshold; - if (table->column_count() < countof(kGoodRowNumberOfColumnsSmall)) { - threshold = kGoodRowNumberOfColumnsSmall[table->column_count()]; - } else { - threshold = table->column_count() * kGoodRowNumberOfColumnsLarge; - } - - return table->CountFilledCellsInRow(row) < threshold; -} - } // namespace tesseract diff --git a/src/textord/tablerecog.h b/src/textord/tablerecog.h index 080cfaec3..f7f49fbde 100644 --- a/src/textord/tablerecog.h +++ b/src/textord/tablerecog.h @@ -1,7 +1,7 @@ /////////////////////////////////////////////////////////////////////// // File: tablerecog.h // Description: Functions to detect structure of tables. -// Author: Nicholas Beato +// Author: Nicholas Beato // // (C) Copyright 2010, Google Inc. // Licensed under the Apache License, Version 2.0 (the "License"); @@ -352,11 +352,6 @@ protected: // as I thought. I went with alternatives for most of the other uses. int NextHorizontalSplit(int left, int right, int y, bool top_to_bottom); - // Indicates that a table row is weak. This means that it has - // many missing data cells or very large cell heights compared. - // to the rest of the table. - static bool IsWeakTableRow(StructuredTable *table, int row); - // Input data, used as read only data to make decisions. ColPartitionGrid *text_grid_ = nullptr; // Text ColPartitions ColPartitionGrid *line_grid_ = nullptr; // Line ColPartitions