L_BarCodeGetNextDuplicated - Barcode C API Help

L_BarCodeGetNextDuplicated

#include "ltbar.h"

L_LTBAR_API L_INT L_BarCodeGetNextDuplicated(pBarCodeData, nCurIndex)

Returns the index of the next barcode in the array that is a duplicate of the barcode at index nCurIndex.

Parameters

pBARCODEDATA pBarCodeData

Pointer to an array of BARCODEDATA structures that contain barcode information for a bitmap. This parameter is the same array returned by L_BarCodeRead or L_BarCodeReadExt.

L_INT nCurIndex

Index of the current duplicated barcode. The value returned by L_BarCodeGetNextDuplicated will be greater than this value. This index is zero based.

Returns

Value Meaning
>=0 An index of duplicated barcode.
< 0 An error occurred. Refer to Return Codes.

Comments

LEADTOOLS provides a number of functions to let you work with duplicated barcodes. They let you:

To determine whether a barcode is duplicated, use the L_BarCodeIsDuplicated function. If a barcode is duplicated, L_BarCodeGetDuplicated will return the index of the first barcode in the array after the specified barcode, which is a duplicate of the specified barcode.

If you know the index of a barcode within an array, you can get the index of the first duplicate of the specified barcode using L_BarCodeGetFirstDuplicated. Use the L_BarCodeGetNextDuplicated to get the next instance of a duplicated barcode.

Although no function is included to tell you the number of different sets of barcodes that are duplicated, you can easily program this by using the following code:

L_INT i, j, nCount; 
L_BOOL * pbVisited = (L_BOOL *)malloc(pBarCodeData->nTotalCount*sizeof(L_BOOL)); 
memset(pbVisited, 0, pBarCodeData->nTotalCount*sizeof(L_BOOL)); 
nCount = 0; 
for (i=0; i<pBarCodeData->nTotalCount; i++) 
{ 
   if(pbVisited[i]) 
      continue; 
   pbVisited[i] = TRUE; 
   nCount++; 
   j = i; 
   while(pBarCodeData[j].nIndexDuplicate != -1) 
   { 
      j = pBarCodeData[j].nIndexDuplicate; 
      pbVisited[j] = TRUE; 
   } 
} 
free(pbVisited); 

After this code is executed, nCount will contain the number of different sets of barcodes.

As an example, suppose a call to L_BarCodeRead reads ten barcodes into a BARCODEDATA array. When L_BarCodeIsDuplicated is called for the item at index 3 in the array, TRUE is returned. Therefore one or more barcodes in the array are duplicates of the specified item.

Calling L_BarCodeGetFirstDuplicated returns the index of the first barcode in the array that is a duplicate of the barcode at index 3 in the array. Suppose this value is 0. The barcode present at index three in the array is the first duplicate of the barcode at index 3.

Calling L_BarCodeGetNextDuplicated with nCurIndex set to 3 will return the index of the next barcode in the array that is a duplicate of the barcodes at index 0 and 3. Suppose this value is 9. Therefore the barcodes at index 0, index 3, and index 9 of the array are all duplicates.

Required DLLs and Libraries

Platforms

Win32, x64, Linux.

Help Version 20.0.2018.6.21
Products | Support | Contact Us | Copyright Notices
© 1991-2018 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Barcode C API Help