RecAPI
|
Table detection and working with tables. More...
Classes | |
struct | CELL_INFO |
Structure of a cell in a table. More... | |
Typedefs | |
typedef CELL_INFO * | LPCELL_INFO |
Pointer to a structure CELL_INFO. | |
typedef const CELL_INFO * | LPCCELL_INFO |
Const pointer to a structure CELL_INFO. | |
Enumerations | |
enum | BORDERINDEX { LEFT_BORDER = 1, TOP_BORDER = 2, RIGHT_BORDER = 3, BOTTOM_BORDER = 4 } |
Index of the border element of a table or a cell. More... | |
enum | RLSTYLE { LS_NO, LS_SOLID, LS_DOUBLE, LS_DASHED, LS_DOTTED, LS_OTHER } |
Possible types of lines. More... | |
Functions | |
RECERR RECAPIKRN | kRecLocateTableColumns (int sid, HPAGE hPage, int zone) |
Cell detection. | |
RECERR RECAPIKRN | kRecLocateTable (int sid, HPAGE hPage, int zone, INTBOOL bForce) |
RECERR RECAPIKRN | kRecCreateTableInfo (HPAGE hPage, int xZone) |
Creating table information. | |
RECERR RECAPIKRN | kRecGetCellCount (HPAGE hPage, int xZone, int *pnCells) |
Getting cell number. | |
RECERR RECAPIKRN | kRecGetOCRCellCount (HPAGE hPage, int xZone, int *pnCells) |
Getting cell number. | |
RECERR RECAPIKRN | kRecGetCellInfo (HPAGE hPage, IMAGEINDEX iiImg, int xZone, int CellIndex, LPCELL_INFO pCellInfo) |
Getting cell information. | |
RECERR RECAPIKRN | kRecGetOCRCellInfo (HPAGE hPage, IMAGEINDEX iiImg, int xZone, int CellIndex, LPCELL_INFO pCellInfo) |
Getting cell information. | |
RECERR RECAPIKRN | kRecSplitCells (HPAGE hPage, IMAGEINDEX iiImg, int xZone, INTBOOL bVertical, const RECT *pRect, POINT Position, int LineWidth, int LineStyle, REC_COLOR lineColor) |
Splitting the selected cells. | |
RECERR RECAPIKRN | kRecMergeCells (HPAGE hPage, IMAGEINDEX iiImg, int xZone, const RECT *pRect) |
Merging selected cells. | |
RECERR RECAPIKRN | kRecGetPointInfoFromTable (HPAGE hPage, IMAGEINDEX iiImg, int xZone, POINT Point, int xDist, int yDist, int *pCellIndex, BORDERINDEX *pBorderIndex) |
Getting the index of the nearest border. | |
RECERR RECAPIKRN | kRecMoveCellBorder (HPAGE hPage, IMAGEINDEX iiImg, int xZone, int CellIndex, BORDERINDEX BorderIndex, POINT NewPosition) |
Moving a cell border. | |
RECERR RECAPIKRN | kRecDragCellBorder (HPAGE hPage, IMAGEINDEX iiImg, int xZone, int CellIndex, BORDERINDEX BorderIndex, POINT *xy, POINT *from, POINT *to, POINT *mmin, POINT *mmax) |
Getting the limits of a border. | |
RECERR RECAPIKRN | kRecGetTabPositionInTable (HPAGE hPage, IMAGEINDEX iiImg, int xZone, POINT Point, POINT *pTab) |
Getting the next tabulator. | |
RECERR RECAPIKRN | kRecSetCells (HPAGE hPage, IMAGEINDEX iiImg, int xZone, LPCCELL_INFO pCells, int nCells) |
Setting cells. | |
RECERR RECAPIKRN | kRecSetCellColor (HPAGE hPage, int xZone, int CellIndex, REC_COLOR color) |
Setting the color of a cell. | |
RECERR RECAPIKRN | kRecGetCellColor (HPAGE hPage, int xZone, int CellIndex, REC_COLOR *pcolor) |
Getting the color of a cell. | |
RECERR RECAPIKRN | kRecGetHSplitters (HPAGE hPage, IMAGEINDEX iiImg, int xZone, int **pSplitters, int *nSplitter) |
Getting the horizontal splitters. | |
RECERR RECAPIKRN | kRecGetVSplitters (HPAGE hPage, IMAGEINDEX iiImg, int xZone, int **pSplitters, int *nSplitter) |
Getting the vertical splitters. | |
RECERR RECAPIKRN | kRecSetCellName (HPAGE hPage, int xZone, int xCell, LPCTSTR pCellName) |
Changing the name of a table-cell. | |
RECERR RECAPIKRN | kRecGetCellName (HPAGE hPage, int xZone, int xCell, LPTSTR *ppCellName) |
Querying the name of a table-cell. | |
RECERR RECAPIKRN | kRecSetOCRCellName (HPAGE hPage, int xZone, int xCell, LPCTSTR pCellName) |
Changing the name of a table-cell. | |
RECERR RECAPIKRN | kRecGetOCRCellName (HPAGE hPage, int xZone, int xCell, LPTSTR *ppCellName) |
Querying the name of a table-cell. | |
RECERR RECAPIKRN | kRecGetTableDimensions (HPAGE hPage, int xZone, int *pnRows, int *pnColumns) |
Querying the dimensions of a table. | |
RECERR RECAPIKRN | kRecGetOCRTableDimensions (HPAGE hPage, int xZone, int *pnRows, int *pnColumns) |
Querying the dimensions of a table. |
Table detection and working with tables.
This module detects tables on the page and connects the recognition result and the table information to each other.
A table is described by the list of its cells in reading order (from left to right and top to bottom) ordered by their top-left coordinates. A cell is always a rectangle, thus a table is a sequence of rectangles.
All cell operations must adhere to the following restrictions:
NOTE: In both the SDK and its documentation, coordinates refer to grid-coordinates - i.e. the top or left borders of pixels. Thus a rectangle does not contain the pixels according to its right and bottom coordinates.
Table information in a table zone (WT_TABLE) contains the above mentioned table description. (See CELL_INFO.) The structure of a table zone can be determined in three different ways:
WT_TABLE
user zone. Having such table information the User can insert splitters into it (kRecSplitCells), or can replace the cell list with a User-defined cell sequence (kRecSetCells). Note that kRecSetCells
creates the table information, if kRecCreateTableInfo
has not run before.WT_TABLE
user zone before recognition. The module automatically detects the structure of the table covered by the given zone and creates the table information.WT_TABLE
user zones that have not been processed by the previous two methods and for all the automatically detected table type OCR zones.The User-started method is less accurate than the Engine-controlled one, thus it may be useful only when automatic cell detection is required before recognition (mainly for displaying on the UI).
The Engine-controlled method leaves the existing cell sequence, if any. In contrast, the User-started method recreates the cell sequence of the user zone even if the zone contains previous table information.
It follows from the above that the Engine-controlled method can be disabled by calling kRecCreateTableInfo.
About detection of tables having invisible cell-separators (so-called non-gridded tables) see the description in kRecSetNongriddedTableDetect.
enum BORDERINDEX |
enum RLSTYLE |
Creating table information.
The kRecCreateTableInfo function creates table information for a user zone. The resulting table info has only one cell with the size of the whole table. This is required, because the cell manipulating functions work for user zones having table information (kRecSplitCells, kRecMergeCells, kRecMoveCellBorder, kRecDragCellBorder, kRecSetCellColor).
[in] | hPage | Handle of the page. |
[in] | xZone | Index of the zone in the user zone list. |
RECERR |
RECERR kRecCreateTableInfo(IntPtr hPage, int xZone);
RECERR RECAPIKRN kRecDragCellBorder | ( | HPAGE | hPage, |
IMAGEINDEX | iiImg, | ||
int | xZone, | ||
int | CellIndex, | ||
BORDERINDEX | BorderIndex, | ||
POINT * | xy, | ||
POINT * | from, | ||
POINT * | to, | ||
POINT * | mmin, | ||
POINT * | mmax | ||
) |
Getting the limits of a border.
The kRecDragCellBorder function gets the moving limits of the border.
[in] | hPage | Handle of the page. |
[in] | iiImg | Index of the image whose coordinate system is to be used to report the limits. |
[in] | xZone | Index of the zone in the user zone list. |
[in] | CellIndex | Index of the cell within the given zone. |
[in] | BorderIndex | The index of the inquired border. |
[out] | xy | Pointer of a variable to store the old position of the border. For a horizontal border, this is the old vertical position and vice versa. |
[out] | from | Pointer of a variable to store the start of the line. For a horizontal border this is the starting x-coordinate of the border and vice versa. |
[out] | to | Pointer of a variable to store the end of the line. For a horizontal border this is the ending x-coordinate of the border and vice versa. |
[out] | mmin | Pointer of a variable to store the minimum limit. For a horizontal border this is the minimum y-coordinate the border can move to and vice versa. |
[out] | mmax | Pointer of a variable to store the maximum limit. For a horizontal border this is the maximum y-coordinate the border can move to and vice versa. |
RECERR |
RECERR kRecDragCellBorder(IntPtr hPage, IMAGEINDEX iiImg, int xZone, int CellIndex, BORDERINDEX BorderIndex, out POINT xy, out POINT from, out POINT to, out POINT mmin, out POINT mmax);
Getting the color of a cell.
The kRecGetCellColor function gets the color of a cell.
[in] | hPage | Handle of the page. |
[in] | xZone | Index of the zone in the user zone list. |
[in] | CellIndex | Index of the cell within the given zone. |
[out] | pcolor | Pointer of a variable to store the color of the cell. |
RECERR |
RECERR kRecGetCellColor(IntPtr hPage, int xZone, int CellIndex, out uint color);
Getting cell number.
The kRecGetCellCount function gets the number of cells in a user zone.
[in] | hPage | Handle of the page. |
[in] | xZone | Index of the zone in the user zone list. |
[out] | pnCells | Pointer to a variable to get the number of cells. |
RECERR |
RECERR kRecGetCellCount(IntPtr hPage, int xZone, out int pnCells);
RECERR RECAPIKRN kRecGetCellInfo | ( | HPAGE | hPage, |
IMAGEINDEX | iiImg, | ||
int | xZone, | ||
int | CellIndex, | ||
LPCELL_INFO | pCellInfo | ||
) |
Getting cell information.
The kRecGetCellInfo function gets the parameters of a cell in a user zone.
[in] | hPage | Handle of the page. |
[in] | iiImg | Index of the image, in which the coordinates of the cell information are given. |
[in] | xZone | Index of the zone in the user zone list. |
[in] | CellIndex | Index of the cell within the given zone. |
[out] | pCellInfo | Pointer to a variable to get the structure of cell information. |
RECERR |
RECERR kRecGetCellInfo(IntPtr hPage, IMAGEINDEX iiImg, int xZone, int CellIndex, out CELL_INFO pCellInfo);
Querying the name of a table-cell.
The kRecGetCellName queries the name of a cell of a table type user zone.
[in] | hPage | Handle of the page. |
[in] | xZone | Index of the user zone to be queried. |
[in] | xCell | Index of the cell to be queried. |
[out] | ppCellName | Address of a pointer to a string which will be allocated and filled by the API-call and will contain the name characters. (The string will be terminated with a null character.) |
RECERR |
RECERR kRecGetCellName(IntPtr hPage, int xZone, int xCell, out string ppCellName);
RECERR RECAPIKRN kRecGetHSplitters | ( | HPAGE | hPage, |
IMAGEINDEX | iiImg, | ||
int | xZone, | ||
int ** | pSplitters, | ||
int * | nSplitter | ||
) |
Getting the horizontal splitters.
The kRecGetHSplitters function gets the number and position of horizontal splitters.
[in] | hPage | Handle of the page. |
[in] | iiImg | Index of the image whose coordinate system is used to report the splitters. |
[in] | xZone | Index of the zone in the user zone list. |
[out] | pSplitters | Pointer of a variable to store the address of an array with the y positions of the splitters. |
[out] | nSplitter | Pointer of a variable to store the number of splitters in the retrieved array. |
RECERR |
RECERR kRecGetHSplitters(IntPtr hPage, IMAGEINDEX iiImg, int xZone, out int[] splitters);
Getting cell number.
The kRecGetOCRCellCount function gets the number of cells in a OCR zone.
[in] | hPage | Handle of the page. |
[in] | xZone | Index of the zone in the OCR zone list. |
[out] | pnCells | Pointer to a variable to get the number of cells. |
RECERR |
RECERR kRecGetOCRCellCount(IntPtr hPage, int xZone, out int pnCells);
RECERR RECAPIKRN kRecGetOCRCellInfo | ( | HPAGE | hPage, |
IMAGEINDEX | iiImg, | ||
int | xZone, | ||
int | CellIndex, | ||
LPCELL_INFO | pCellInfo | ||
) |
Getting cell information.
The kRecGetOCRCellInfo function gets the parameters of a cell in an OCR zone.
[in] | hPage | Handle of the page. |
[in] | iiImg | Index of the image, in which the coordinates of the cell information are given. |
[in] | xZone | Index of the zone in the OCR zone list. |
[in] | CellIndex | Index of the cell within the given zone. |
[out] | pCellInfo | Pointer to a variable to get the structure of cell information. |
RECERR |
RECERR kRecGetOCRCellInfo(IntPtr hPage, IMAGEINDEX iiImg, int xZone, int CellIndex, out CELL_INFO pCellInfo);
Querying the name of a table-cell.
The kRecGetOCRCellName queries the name of a cell of a table type OCR zone.
[in] | hPage | Handle of the page. |
[in] | xZone | Index of the OCR zone to be queried. |
[in] | xCell | Index of the cell to be queried. |
[out] | ppCellName | Address of a pointer to a string which will be allocated and filled by the API-call and will contain the name characters. (The string will be terminated with a null character.) |
RECERR |
RECERR kRecGetOCRCellName(IntPtr hPage, int xZone, int xCell, out string ppCellName);
RECERR RECAPIKRN kRecGetOCRTableDimensions | ( | HPAGE | hPage, |
int | xZone, | ||
int * | pnRows, | ||
int * | pnColumns | ||
) |
Querying the dimensions of a table.
The kRecGetOCRTableDimensions queries the number of rows and columns of a table type OCR zone.
[in] | hPage | Handle of the page. |
[in] | xZone | Index of the OCR zone to be queried. |
[out] | pnRows | Pointer to a variable for storing the number of rows. |
[out] | pnColumns | Pointer to a variable for storing the number of columns. |
RECERR |
RECERR kRecGetOCRTableDimensions(IntPtr hPage, int xZone, int xCell, out int pnRows, out int pnColumns);
RECERR RECAPIKRN kRecGetPointInfoFromTable | ( | HPAGE | hPage, |
IMAGEINDEX | iiImg, | ||
int | xZone, | ||
POINT | Point, | ||
int | xDist, | ||
int | yDist, | ||
int * | pCellIndex, | ||
BORDERINDEX * | pBorderIndex | ||
) |
Getting the index of the nearest border.
The kRecGetPointInfoFromTable function gets the cell index and the nearest border's index for a given point.
[in] | hPage | Handle of the page. |
[in] | iiImg | Index of the image, in which the coordinates of the point are given. |
[in] | xZone | Index of the zone in the user zone list. |
[in] | Point | The point inquired. |
[in] | xDist | If the distance of the point from the left or right border is less then this, the output border index will be the index of the nearest one. See pBorderIndex . |
[in] | yDist | If the distance of the point from the top or bottom border is less then this, the output border index will be the index of the nearest one. See pBorderIndex . |
[out] | pCellIndex | Pointer of a variable to store the index of the cell, in which the given point is localized. |
[out] | pBorderIndex | Pointer of a variable to store the index of the nearest border to the given point. Its value is always zero when the distance is greater than xDist and yDist from the proper border. |
RECERR |
RECERR kRecGetPointInfoFromTable(IntPtr hPage, IMAGEINDEX iiImg, int xZone, POINT Point, int xDist, int yDist, out int pCellIndex, out BORDERINDEX pBorderIndex);
Querying the dimensions of a table.
The kRecGetTableDimensions queries the number of rows and columns of a table type user zone.
[in] | hPage | Handle of the page. |
[in] | xZone | Index of the OCR zone to be queried. |
[out] | pnRows | Pointer to a variable for storing the number of rows. |
[out] | pnColumns | Pointer to a variable for storing the number of columns. |
RECERR |
RECERR kRecGetTableDimensions(IntPtr hPage, int xZone, int xCell, out int pnRows, out int pnColumns);
RECERR RECAPIKRN kRecGetTabPositionInTable | ( | HPAGE | hPage, |
IMAGEINDEX | iiImg, | ||
int | xZone, | ||
POINT | Point, | ||
POINT * | pTab | ||
) |
Getting the next tabulator.
The kRecGetTabPositionInTable function gets the first tabulator position after the given position. The tabulator has only a horizontal position.
[in] | hPage | Handle of the page. |
[in] | iiImg | Index of the image, in which the coordinates of the points are given. |
[in] | xZone | Index of the zone in the user zone list. |
[in] | Point | The point inquired. |
[out] | pTab | Pointer of a variable to store the position of the tabulator following Point . |
RECERR |
RECERR kRecGetTabPositionInTable(IntPtr hPage, IMAGEINDEX iiImg, int xZone, POINT Point, out POINT pTab);
RECERR RECAPIKRN kRecGetVSplitters | ( | HPAGE | hPage, |
IMAGEINDEX | iiImg, | ||
int | xZone, | ||
int ** | pSplitters, | ||
int * | nSplitter | ||
) |
Getting the vertical splitters.
The kRecGetVSplitters function gets the number and position of vertical splitters.
[in] | hPage | Handle of the page. |
[in] | iiImg | Index of the image whose coordinate system is used to report the splitters. |
[in] | xZone | Index of the zone in the user zone list. |
[out] | pSplitters | Pointer of a variable to store the address of an array with the x positions of the splitters. |
[out] | nSplitter | Pointer of a variable to store the number of splitters in the retrieved array. |
RECERR |
RECERR kRecGetVSplitters(IntPtr hPage, IMAGEINDEX iiImg, int xZone, out int[] splitters);
This function detects the columns within a table type user zone (WT_TABLE) of the page.
[in] | sid | Settings Collection ID. |
[in] | hPage | Handle of the page. |
[in] | zone | The index of the zone in the user zone list. |
[in] | bForce | Force the zone type to be table. If it is FALSE the zone type may be changed to WT_GRAPHIC. |
RECERR |
RECERR kRecLocateTable(int sid, IntPtr hPage, int zone, bool bForce);
Cell detection.
This function detects the cells within a table type user zone (WT_TABLE) of the page.
[in] | sid | Settings Collection ID. |
[in] | hPage | Handle of the page. |
[in] | zone | The index of the zone in the user zone list. |
RECERR |
RECERR kRecLocateTableColumns(int sid, IntPtr hPage, int zone);
RECERR RECAPIKRN kRecMergeCells | ( | HPAGE | hPage, |
IMAGEINDEX | iiImg, | ||
int | xZone, | ||
const RECT * | pRect | ||
) |
Merging selected cells.
The kRecMergeCells function merges the selected cells if they make up a rectangle.
[in] | hPage | Handle of the page. |
[in] | iiImg | Index of the image, in which the coordinates of the selecting rectangle are to be given. |
[in] | xZone | Index of the zone in the user zone list. |
[in] | pRect | The cells intersected or contained by this rectangle are selected for this function. |
RECERR |
RECERR kRecMergeCells(IntPtr hPage, IMAGEINDEX iiImg, int xZone, RECT pRect);
RECERR RECAPIKRN kRecMoveCellBorder | ( | HPAGE | hPage, |
IMAGEINDEX | iiImg, | ||
int | xZone, | ||
int | CellIndex, | ||
BORDERINDEX | BorderIndex, | ||
POINT | NewPosition | ||
) |
Moving a cell border.
The kRecMoveCellBorder function moves a border.
[in] | hPage | Handle of the page. |
[in] | iiImg | Index of the image, in which the coordinates of the point are given. |
[in] | xZone | Index of the zone in the user zone list. |
[in] | CellIndex | Index of the cell within the given zone. |
[in] | BorderIndex | The index of the border to be moved. |
[in] | NewPosition | The new position of the given border. |
RECERR |
RECERR kRecMoveCellBorder(IntPtr hPage, IMAGEINDEX iiImg, int xZone, int CellIndex, BORDERINDEX BorderIndex, POINT NewPosition);
Setting the color of a cell.
The kRecSetCellColor function sets the color of a cell.
[in] | hPage | Handle of the page. |
[in] | xZone | Index of the zone in the user zone list. |
[in] | CellIndex | Index of the cell within the given zone. |
[in] | color | The color to be set. |
RECERR |
RECERR kRecSetCellColor(IntPtr hPage, int xZone, int CellIndex, uint color);
Changing the name of a table-cell.
The kRecSetCellName changes the name of a cell of a table type user zone.
[in] | hPage | Handle of the page. |
[in] | xZone | Index of the user zone to be updated. |
[in] | xCell | Index of the cell to be updated. |
[in] | pCellName | Pointer to a string containing the name characters to be set. (The string is terminated with a null character.) |
RECERR |
RECERR kRecSetCellName(IntPtr hPage, int xZone, int xCell, string pCellName);
RECERR RECAPIKRN kRecSetCells | ( | HPAGE | hPage, |
IMAGEINDEX | iiImg, | ||
int | xZone, | ||
LPCCELL_INFO | pCells, | ||
int | nCells | ||
) |
Setting cells.
The kRecSetCells function puts the given cell sequence into a WT_TABLE user zone. If the given zone does not have table information this function creates it. If the zone has any cell sequence the former one is replaced by the new one.
[in] | hPage | Handle of the page. |
[in] | iiImg | Index of the image whose coordinate system you have used in defining the cell borders. |
[in] | xZone | Index of the zone in the user zone list. |
[in] | pCells | Pointer to the array of cells to be set in the table. |
[in] | nCells | The number of cells in the array. |
RECERR |
RECERR kRecSetCells(IntPtr hPage, IMAGEINDEX iiImg, int xZone, CELL_INFO[] pCells);
Changing the name of a table-cell.
The kRecSetOCRCellName changes the name of a cell of a table type OCR zone.
[in] | hPage | Handle of the page. |
[in] | xZone | Index of the OCR zone to be updated. |
[in] | xCell | Index of the cell to be updated. |
[in] | pCellName | Pointer to a string containing the name characters to be set. (The string is terminated with a null character.) |
RECERR |
RECERR kRecSetOCRCellName(IntPtr hPage, int xZone, int xCell, string pCellName);
RECERR RECAPIKRN kRecSplitCells | ( | HPAGE | hPage, |
IMAGEINDEX | iiImg, | ||
int | xZone, | ||
INTBOOL | bVertical, | ||
const RECT * | pRect, | ||
POINT | Position, | ||
int | LineWidth, | ||
int | LineStyle, | ||
REC_COLOR | lineColor | ||
) |
Splitting the selected cells.
The kRecSplitCells function splits the cells (if the cut is in a selected area, only the selected cells are affected). This function supposes that the given user zone already has table information.
[in] | hPage | Handle of the page. |
[in] | iiImg | Index of the image, in which the position coordinates and the selecting rectangle must be given. |
[in] | xZone | Index of the zone in the user zone list. |
[in] | bVertical | This determines whether the splitter is vertical or not. |
[in] | pRect | The cells intersected or contained by this rectangle are selected for this function. |
[in] | Position | The position of the splitter. |
[in] | LineWidth | The width of the splitter. |
[in] | LineStyle | The style of the splitter. |
[in] | lineColor | The color of the line. |
RECERR |
RECERR kRecSplitCells(IntPtr hPage, IMAGEINDEX iiImg, int xZone, bool bVertical, RECT pRect, POINT Position, int LineWidth, RLSTYLE LineStyle, int lineColor);