L_FindBarcodeCandidateAreas

Summary

Detects the potential barcode areas on a bitmap.

Syntax

#include "l_bitmap.h"

L_LTIMGCOR_API L_INT L_FindBarcodeCandidateAreas(pBitmap, pOptions, pFoundAreas)

Parameters

pBITMAPHANDLE pBitmap

Pointer to the bitmap handle referencing the bitmap to detect the barcode areas.

FIND_BARCODE_CANDIDATE_AREAS_OPTIONS *pOptions

Pointer to a structure that contains the options to be used in detecting the barcode areas.

BARCODE_CANDIDATE_AREAS *pFoundAreas

Pointer to a structure to be updated with the detected barcode candidate areas.

Returns

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

Comments

This function is useful for images that have a barcode but one that is poor quality by returning the barcode bounds and confidence.

This will also provide speedup by using the bounds of the candidates to pass to the L_BarCodeRead on the entire bitmap.

When the detected barcode candidate areas specified by pFoundAreas is no longer needed, free it by calling L_FreeBarcodeCandidateAreas.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

See Also

Functions

Example

This example processes a bitmap to find potential barcode candidates and gives a confidence value for each area.

L_INT L_FindBarcodeCandidateAreasExample(L_VOID) 
{ 
   L_INT nRet; 
 
   /* Bitmap handle to hold the loaded image. */ 
   BITMAPHANDLE LeadBitmap; 
   FIND_BARCODE_CANDIDATE_AREAS_OPTIONS candidateOptions = { 0 }; 
   BARCODE_CANDIDATE_AREAS candidates; 
   pBARCODEDATA pBarcodeData = NULL; 
   L_INT nCandidates; 
 
   /* Load the bitmap, keeping the bits per pixel of the file the same */ 
   nRet = L_LoadBitmap(MAKE_IMAGE_PATH(L_TEXT("barcode2.tif")), &LeadBitmap, sizeof(BITMAPHANDLE), 24, ORDER_BGR, NULL, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   candidateOptions.uStructSize = sizeof(FIND_BARCODE_CANDIDATE_AREAS_OPTIONS); 
   candidateOptions.uUnits = BARCODE_CANDIDATE_AREAS_USE_PIXELS; 
   candidateOptions.BackgroundColor = RGB(255, 255, 255); 
   candidateOptions.BarcodeColor = RGB(0, 0, 0); 
 
   candidates.uStructSize = sizeof(BARCODE_CANDIDATE_AREAS); 
 
   /* Finds potential barcodes */ 
   nRet = L_FindBarcodeCandidateAreas(&LeadBitmap, &candidateOptions, &candidates); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   /* Number of barcode candidate areas */ 
   nCandidates = candidates.AreasCount; 
 
   L_BarCodeInit(BARCODES_QR_READ); 
 
   // Loop through the candidates and read the barcode while storing the data 
   for (int n = 0; n < nCandidates; n++) 
   { 
      L_BarCodeRead(&LeadBitmap, &candidates.Areas[n].Bounds, BARCODE_QR_CODE, BARCODE_SCANLINES_PER_PIXELS, NULL, 0, NULL, NULL, NULL, &pBarcodeData, sizeof(BARCODEDATA)); 
   } 
 
   // Free memory  
   L_FreeBarcodeCandidateAreas(&candidates); 
   L_BarCodeFree(&pBarcodeData); 
 
   L_BarCodeExit(); 
 
   if (LeadBitmap.Flags.Allocated) 
      L_FreeBitmap(&LeadBitmap); 
 
   return nRet; 
} 

Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 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.