Aspose.Barcode for Python via Java Generation and Recognition API docs
ChecksumValidation Class Reference

Enable checksum validation during recognition for 1D barcodes. More...

Inherits Enum.

Static Public Attributes

int DEFAULT = 0
 If checksum is required by the specification - it will be validated. More...
 
int OFF = 2
 Do not validate checksum. More...
 
int ON = 1
 Always validate checksum if possible. More...
 

Detailed Description

Enable checksum validation during recognition for 1D barcodes.

Default is treated as Yes for symbologies which must contain checksum, as No where checksum only possible. Checksum never used: Codabar Checksum is possible: Code39 Standard/Extended, Standard2of5, Interleaved2of5, Matrix2of5, ItalianPost25, DeutschePostIdentcode, DeutschePostLeitcode, VIN Checksum always used: Rest symbologies This sample shows influence of ChecksumValidation on recognition quality and results

generator = Generation.BarcodeGenerator(Generation.EncodeTypes.EAN_13, "1234567890128")
generator.save(self.image_path_to_save, Generation.BarCodeImageFormat.PNG)
reader = Recognition.BarCodeReader(self.image_path_to_save, None, Recognition.DecodeType.EAN_13)
# checksum disabled
reader.getBarcodeSettings().setChecksumValidation(Recognition.ChecksumValidation.OFF)
results = reader.readBarCodes()
for result in results:
print(f"\nBarCode Type: {result.getCodeTypeName()}")
print(f"BarCode CodeText: {result.getCodeText()}")
print(f"BarCode Checksum: {result.getExtended().getOneD().getCheckSum()}")
generator = Generation.BarcodeGenerator(Generation.EncodeTypes.EAN_13, "1234567890128")
generator.save(self.image_path_to_save, Generation.BarCodeImageFormat.PNG)
reader = Recognition.BarCodeReader(self.image_path_to_save, None, Recognition.DecodeType.EAN_13)
# checksum enabled
reader.getBarcodeSettings().setChecksumValidation(Recognition.ChecksumValidation.ON)
results = reader.readBarCodes()
for result in results:
print(f"\nBarCode Type: {result.getCodeTypeName()}")
print(f"BarCode CodeText: {result.getCodeText()}")
print(f"BarCode Checksum: {result.getExtended().getOneD().getCheckSum()}")

Member Data Documentation

◆ DEFAULT

int DEFAULT = 0
static

If checksum is required by the specification - it will be validated.

◆ OFF

int OFF = 2
static

Do not validate checksum.

◆ ON

int ON = 1
static

Always validate checksum if possible.