L_DetectTablesBitmap

Summary

Contains functions for detecting tables in an image.

Syntax

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_DetectTablesBitmap(pBitmap, pOptions, pOutputs)

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap.

pDETECT_TABLES_OPTIONS pOptions

Pointer to the specified options for the table detection.

pDETECT_TABLES_RESULT pOutputs

Pointer to the table results obtained after calling this function.

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

If L_DetectLinesBitmap has been called prior to this function, then manually pass in the DETECT_LINES_RESULT to the DETECT_TABLES_OPTIONS to speed up processing.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Example

This example detects horizontal and vertical lines in an image.

L_INT L_DetectTablesBitmapExample() 
{ 
   DETECT_TABLES_OPTIONS TablesDetectOptions = { 0 }; 
   DETECT_TABLES_RESULT  TablesDetectResult; 
   DETECT_LINES_OPTIONS  LinesDetectOptions = { 0 }; 
   DETECT_LINES_RESULT   LinesDetectResult; 
   BITMAPHANDLE          LeadBitmap = { 0 }; 
   CORELINE              FirstVerticalLine; 
   L_INT                 nVerticalLineCount; 
   L_INT                 nDetectedTablesCount; 
   L_INT                 nRet; 
 
   /* Load Bitmap */ 
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(TEXT("Forms\\Forms to be Recognized\\Invoice\\Invoice.tif")), &LeadBitmap, sizeof(BITMAPHANDLE), 0, ORDER_BGR, NULL, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   /* Set line detection options */ 
   LinesDetectOptions.uStructSize = sizeof(DETECT_LINES_OPTIONS); 
   LinesDetectOptions.uHorizontalLineMinimumLength = 10; 
   LinesDetectOptions.uVerticalLineMinimumLength = 10; 
   LinesDetectOptions.uFlags = REMOVE_LINES; 
 
   /* Call detection, pass reference to output */ 
   nRet = L_DetectLinesBitmap(&LeadBitmap, &LinesDetectOptions, &LinesDetectResult); 
   if (nRet != SUCCESS) 
      goto CLEANUP; 
 
   /* Number of vertical lines detected */ 
   nVerticalLineCount = LinesDetectResult.VerticalLines.uCount; 
 
   /* First vertical line in output list */ 
   FirstVerticalLine = LinesDetectResult.VerticalLines.pLines[0]; 
 
   /* Save Bitmap to view lines removal */ 
   L_SaveBitmap(MAKE_IMAGE_PATH(TEXT("Invoice_nolines.jpg")), &LeadBitmap, FILE_JPEG, 24, 0, NULL); 
 
   /* Set tables detection options */ 
   TablesDetectOptions.uStructSize = sizeof(DETECT_TABLES_OPTIONS); 
   TablesDetectOptions.uHorizontalLineMinimumLength = 10; 
   TablesDetectOptions.uVerticalLineMinimumLength = 10; 
 
   /* Since we performed lines detection first, we can pass the detected lines to the tables option structure */ 
   /* This will speed up the table detection */ 
   TablesDetectOptions.pDetectedLines = &LinesDetectResult; 
 
   /* Perform Table detection */ 
   nRet = L_DetectTablesBitmap(&LeadBitmap, &TablesDetectOptions, &TablesDetectResult); 
   if (nRet != SUCCESS) 
      goto CLEANUP; 
 
   nDetectedTablesCount = TablesDetectResult.uCount; 
 
CLEANUP: 
   /* Free memory */ 
   L_FreeDetectTablesBitmap(&TablesDetectResult); 
   L_FreeDetectLinesBitmap(&LinesDetectResult); 
 
   if (LeadBitmap.Flags.Allocated) 
      L_FreeBitmap(&LeadBitmap); 
 
   return nRet; 
} 

Help Version 22.0.2023.7.11
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.