mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-12-22 22:47:50 +08:00
TableRecognizer: Adding functions in order to calculate row and columns bounding boxes
This commit is contained in:
parent
2954367c62
commit
877ef39c40
@ -304,6 +304,36 @@ void StructuredTable::Display(ScrollView* window, ScrollView::Color color) {
|
||||
#endif
|
||||
}
|
||||
|
||||
std::vector<TBOX> StructuredTable::getRows()
|
||||
{
|
||||
if(cell_y_.size() < 2)
|
||||
return std::vector<TBOX>();
|
||||
|
||||
std::vector<TBOX> rows(cell_y_.size() - 1);
|
||||
for(unsigned i = 0; i + 1 < cell_y_.size(); i++) {
|
||||
const ICOORD left(bounding_box_.left(), cell_y_[i]);
|
||||
const ICOORD right(bounding_box_.right(), cell_y_[i + 1]);
|
||||
rows[i] = TBOX(left, right);
|
||||
}
|
||||
|
||||
return rows;
|
||||
}
|
||||
|
||||
std::vector<TBOX> StructuredTable::getCols()
|
||||
{
|
||||
if(cell_x_.size() < 2)
|
||||
return std::vector<TBOX>();
|
||||
|
||||
std::vector<TBOX> cols(cell_x_.size() - 1);
|
||||
for(unsigned i = 0; i + 1 < cell_x_.size(); i++) {
|
||||
const ICOORD top(cell_x_[i], bounding_box_.top());
|
||||
const ICOORD bot(cell_x_[i+1], bounding_box_.bottom());
|
||||
cols[i] = TBOX(top, bot);
|
||||
}
|
||||
|
||||
return cols;
|
||||
}
|
||||
|
||||
// Clear structure information.
|
||||
void StructuredTable::ClearStructure() {
|
||||
cell_x_.clear();
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include "colpartitiongrid.h"
|
||||
#include <tesseract/genericvector.h>
|
||||
#include <vector>
|
||||
#include "points.h"
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
@ -136,6 +138,11 @@ class StructuredTable {
|
||||
// Debug display, draws the table in the given color. If the table is not
|
||||
// valid, the table and "best" grid lines are still drawn in the given color.
|
||||
void Display(ScrollView* window, ScrollView::Color color);
|
||||
|
||||
/// calcualte bounding boxes of the rows and return them
|
||||
std::vector<TBOX> getRows();
|
||||
/// calcualte bounding boxes of the columns and return them
|
||||
std::vector<TBOX> getCols();
|
||||
|
||||
protected:
|
||||
// Clear the structure information.
|
||||
|
Loading…
Reference in New Issue
Block a user