Returns a value that indicates whether the specified barcode is duplicated or not.
#include "ltbar.h"
L_LTBAR_API L_BOOL L_BarCodeIsDuplicated(pBarCodeDataItem)
Pointer to the BARCODEDATA structure that contains the barcode information.
Value | Meaning |
---|---|
TRUE | The specified barcode is duplicated. |
FALSE | The specified barcode is not duplicated. |
This function determines if a barcode is duplicated in another location in the bitmap.
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.
To find out how many sets of barcodes are duplicated, use the following:
int GetSetsCount(pBARCODEDATA pBarCodeData)
{
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 && pBarCodeData[j].nIndexDuplicate != 255)
{
j = pBarCodeData[j].nIndexDuplicate;
pbVisited[j] = TRUE;
}
}
free(pbVisited);
return nCount;
}
For example, in an array of ten barcodes, the first, third, and fifth might be duplicates of each other, while the 4th, 8th and 9th are duplicates of a different barcode. After this code is executed, nCount will contain the number of different sets of barcodes.
To read in barcodes present in a bitmap, use the L_BarCodeRead or L_BarCodeReadExt function. Any item in the barcode array returned by L_BarCodeRead can be passed to L_BarCodeIsDuplicated.
Win32, x64, Linux.
For an example, refer to L_BarCodeGetDuplicated.