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

BarCodeReader encapsulates an image which may contain one or several barcodes, it then can perform ReadBarCodes operation to detect barcodes. More...

Inherits asposebarcode.Assist.BaseJavaClass.

Public Member Functions

def __init__ (self, image, rectangles, decodeTypes)
 Initializes a new instance of the BarCodeReader :param: image encoded as base64 string or path to image :param: rectangles array of object by type Rectangle :param: decodeTypes the array of objects by DecodeType. More...
 
def containsAny (self, decodeTypes)
 Determines whether any of the given decode types is included into :param: ...decodeTypes Types to verify. More...
 
def init (self)
 
def getTimeout (self)
 Gets the timeout of recognition process in milliseconds. More...
 
def setTimeout (self, value)
 Sets the timeout of recognition process in milliseconds. More...
 
def getChecksumValidation (self)
 Enable checksum validation during recognition for 1D barcodes. More...
 
def setChecksumValidation (self, value)
 Enable checksum validation during recognition for 1D barcodes. More...
 
def getStripFNC (self)
 Strip FNC1, FNC2, FNC3 characters from codetext. More...
 
def setStripFNC (self, value)
 Strip FNC1, FNC2, FNC3 characters from codetext. More...
 
def getCustomerInformationInterpretingType (self)
 Gets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER. More...
 
def setCustomerInformationInterpretingType (self, value)
 Sets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER. More...
 
def abort (self)
 
def getFoundBarCodes (self)
 Gets recognized BarCodeResult array. More...
 
def getFoundCount (self)
 Gets recognized barcodes count. More...
 
def readBarCodes (self)
 Reads BarCodeResult from the image. More...
 
def getQualitySettings (self)
 QualitySettings allows to configure recognition quality and speed manually. More...
 
def setQualitySettings (self, value)
 QualitySettings allows to configure recognition quality and speed manually. More...
 
def getBarcodeSettings (self)
 The main BarCode decoding parameters. More...
 
def getDetectEncoding (self)
 A flag which force engine to detect codetext encoding for Unicode codesets. More...
 
def setDetectEncoding (self, value)
 A flag which force engine to detect codetext encoding for Unicode codesets. More...
 
def setBarCodeImage (self, image, areas)
 Sets bitmap image and areas for Recognition. More...
 
def setBarCodeReadType (self, types)
 Sets SingleDecodeType type array for Recognition. More...
 
def getBarCodeDecodeType (self)
 
def exportToXml (self, xmlFile)
 Exports BarCode properties to the xml-file specified :param: xmlFile The name of the file :return: Whether or not export completed successfully. More...
 
- Public Member Functions inherited from asposebarcode.Assist.BaseJavaClass
def __init__ (self, javaClass)
 
def getJavaClass (self)
 
def setJavaClass (self, javaClass)
 
def getJavaClassName (self)
 
def isNull (self)
 
def printJavaClassName (self)
 

Static Public Member Functions

def construct (javaClass)
 
def convertToBase64Image (image)
 
def importFromXml (xmlFile)
 Exports BarCode properties to the xml-file specified :param xmlFile: xmlFile The name of the file :return:Whether or not export completed successfully. More...
 

Public Attributes

 qualitySettings
 
 recognizedResults
 
 barcodeSettings
 
- Public Attributes inherited from asposebarcode.Assist.BaseJavaClass
 javaClass
 
 javaClassName
 

Static Public Attributes

string javaClassName = "com.aspose.mw.barcode.recognition.MwBarCodeReader"
 

Detailed Description

BarCodeReader encapsulates an image which may contain one or several barcodes, it then can perform ReadBarCodes operation to detect barcodes.

This sample shows how to detect Code39 and Code128 barcodes.

reader = BarCodeReader("test.png", None, [DecodeType.CODE_39_STANDARD, DecodeType.CODE_128])
for result in reader.readBarCodes():
print("BarCode Type: " + result.getCodeTypeName())
print("BarCode CodeText: " + result.getCodeText())

Constructor & Destructor Documentation

◆ __init__()

def asposebarcode.Recognition.BarCodeReader.__init__ (   self,
  image,
  rectangles,
  decodeTypes 
)

Initializes a new instance of the BarCodeReader :param: image encoded as base64 string or path to image :param: rectangles array of object by type Rectangle :param: decodeTypes the array of objects by DecodeType.

Member Function Documentation

◆ abort()

def asposebarcode.Recognition.BarCodeReader.abort (   self)

◆ construct()

def asposebarcode.Recognition.BarCodeReader.construct (   javaClass)
static

◆ containsAny()

def asposebarcode.Recognition.BarCodeReader.containsAny (   self,
  decodeTypes 
)

Determines whether any of the given decode types is included into :param: ...decodeTypes Types to verify.

:return: bool Value is a true if any types are included into.

◆ convertToBase64Image()

def asposebarcode.Recognition.BarCodeReader.convertToBase64Image (   image)
static

◆ exportToXml()

def asposebarcode.Recognition.BarCodeReader.exportToXml (   self,
  xmlFile 
)

Exports BarCode properties to the xml-file specified :param: xmlFile The name of the file :return: Whether or not export completed successfully.

Returns True in case of success False Otherwise

◆ getBarCodeDecodeType()

def asposebarcode.Recognition.BarCodeReader.getBarCodeDecodeType (   self)

◆ getBarcodeSettings()

def asposebarcode.Recognition.BarCodeReader.getBarcodeSettings (   self)

The main BarCode decoding parameters.

Contains parameters which make influence on recognized data.

return The main BarCode decoding parameters

◆ getChecksumValidation()

def asposebarcode.Recognition.BarCodeReader.getChecksumValidation (   self)

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 = BarcodeGenerator(EncodeTypes.EAN_13, "1234567890128")
generator.save("test.png")
reader = BarCodeReader("test.png", None, DecodeType.EAN_13)
#checksum disabled
reader.setChecksumValidation(ChecksumValidation.OFF)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())
print("BarCode Value: " + result.getExtended().getOneD().getValue())
print("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum())
reader = BarCodeReader("test.png", None, DecodeType.EAN_13)
#checksum enabled
reader.setChecksumValidation(ChecksumValidation.ON)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())
print("BarCode Value: " + result.getExtended().getOneD().getValue())
print("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum())

The checksum validation flag.

◆ getCustomerInformationInterpretingType()

def asposebarcode.Recognition.BarCodeReader.getCustomerInformationInterpretingType (   self)

Gets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER.

◆ getDetectEncoding()

def asposebarcode.Recognition.BarCodeReader.getDetectEncoding (   self)

A flag which force engine to detect codetext encoding for Unicode codesets.

This sample shows how to detect text encoding on the fly if DetectEncoding is enabled

image = "image.png"
generator = BarcodeGenerator(EncodeTypes.QR, "пїЅпїЅпїЅпїЅпїЅ"))
generator.getParameters().getBarcode().getQR().setCodeTextEncoding("UTF-8")
generator.save(image, BarCodeImageFormat.getPng())
#detects encoding for Unicode codesets is enabled
reader = BarCodeReader(image, None, DecodeType.QR)
reader.setDetectEncoding(true)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())
#detect encoding is disabled
reader = BarCodeReader(image, None, DecodeType.QR)
reader.setDetectEncoding(false)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())

◆ getFoundBarCodes()

def asposebarcode.Recognition.BarCodeReader.getFoundBarCodes (   self)

Gets recognized BarCodeResult array.

This sample shows how to read barcodes with BarCodeReader

reader = BarCodeReader("test.png", None, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ])
reader.readBarCodes()
for(let i = 0 reader.getFoundCount() > i ++i)
print("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText())

Value: The recognized BarCodeResult array

◆ getFoundCount()

def asposebarcode.Recognition.BarCodeReader.getFoundCount (   self)

Gets recognized barcodes count.


This sample shows how to read barcodes with BarCodeReader

reader = BarCodeReader("test.png", None, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ])
reader.readBarCodes()
for(let i = 0 reader.getFoundCount() > i ++i)
print("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText())

Value: The recognized barcodes count

◆ getQualitySettings()

def asposebarcode.Recognition.BarCodeReader.getQualitySettings (   self)

QualitySettings allows to configure recognition quality and speed manually.

You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality,

HighQuality, MaxBarCodes or you can manually configure separate options.

Default value of QualitySettings is NormalQuality.

This sample shows how to use QualitySettings with BarCodeReader

reader = BarCodeReader("test.png", None, None)
#set high performance mode
reader.setQualitySettings(QualitySettings.getHighPerformance())
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())
reader = BarCodeReader("test.png", None, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ])
#normal quality mode is set by default
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())
reader = BarCodeReader("test.png", None, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ])
#set high performance mode
reader.setQualitySettings(QualitySettings.getHighPerformance())
#set separate options
reader.getQualitySettings().setAllowMedianSmoothing(true)
reader.getQualitySettings().setMedianSmoothingWindowSize(5)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())

QualitySettings to configure recognition quality and speed.

◆ getStripFNC()

def asposebarcode.Recognition.BarCodeReader.getStripFNC (   self)

Strip FNC1, FNC2, FNC3 characters from codetext.

Default value is false.

This sample shows how to strip FNC characters

generator = BarcodeGenerator(EncodeTypes.GS1Code128, "(02)04006664241007(37)1(400)7019590754")
generator.save("test.png")
reader = BarCodeReader("test.png", None, DecodeType.CODE_128)
#StripFNC disabled
reader.setStripFNC(false)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())
reader = BarCodeReader("test.png", None, DecodeType.CODE_128)
#StripFNC enabled
reader.setStripFNC(true)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())

◆ getTimeout()

def asposebarcode.Recognition.BarCodeReader.getTimeout (   self)

Gets the timeout of recognition process in milliseconds.

reader = BarCodeReader("test.png", None, None)
reader.setTimeout(5000)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())

:return: The timeout.

◆ importFromXml()

def asposebarcode.Recognition.BarCodeReader.importFromXml (   xmlFile)
static

Exports BarCode properties to the xml-file specified :param xmlFile: xmlFile The name of the file :return:Whether or not export completed successfully.

Returns True in case of success; False Otherwise

◆ init()

def asposebarcode.Recognition.BarCodeReader.init (   self)

◆ readBarCodes()

def asposebarcode.Recognition.BarCodeReader.readBarCodes (   self)

Reads BarCodeResult from the image.

This sample shows how to read barcodes with BarCodeReader

reader = BarCodeReader("test.png", None, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ])
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())
reader = BarCodeReader("test.png", None, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ])
reader.readBarCodes()
for(let i = 0 reader.getFoundCount() > i ++i)
print("BarCode CodeText: " + reader.getFoundBarCodes()[i].getCodeText())

:return: Returns array of recognized

BarCodeResult

s on the image. If nothing is recognized, zero array is returned.

◆ setBarCodeImage()

def asposebarcode.Recognition.BarCodeReader.setBarCodeImage (   self,
  image,
  areas 
)

Sets bitmap image and areas for Recognition.

Must be called before ReadBarCodes() method.

This sample shows how to detect Code39 and Code128 barcodes.

let bmp = "test.png"
reader = BarCodeReader()
reader.setBarCodeReadType([ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ])
var img = Image()
img.src = 'path_to_image'
width = img.width
height = img.height
reader.setBarCodeImage(bmp, [Rectangle(0, 0, width, height)])
for result in results:
print("BarCode Type: " + result.getCodeTypeName())
print("BarCode CodeText: " + result.getCodeText())

:param: value The bitmap image for Recognition. :param: areas areas list for recognition

Exceptions
BarCodeException

◆ setBarCodeReadType()

def asposebarcode.Recognition.BarCodeReader.setBarCodeReadType (   self,
  types 
)

Sets SingleDecodeType type array for Recognition.

Must be called before readBarCodes() method.

This sample shows how to detect Code39 and Code128 barcodes.

reader = BarCodeReader()
reader.setBarCodeReadType([ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ])
reader.setBarCodeImage("test.png")
for result in reader.readBarCodes():
print("BarCode Type: " + result.getCodeTypeName())
print("BarCode CodeText: " + result.getCodeText())

:param: types The SingleDecodeType type array to read.

◆ setChecksumValidation()

def asposebarcode.Recognition.BarCodeReader.setChecksumValidation (   self,
  value 
)

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 = BarcodeGenerator(EncodeTypes.EAN_13, "1234567890128")
generator.save("test.png")
reader = BarCodeReader("test.png", None, DecodeType.EAN_13)
#checksum disabled
reader.setChecksumValidation(ChecksumValidation.OFF)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())
print("BarCode Value: " + result.getExtended().getOneD().getValue())
print("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum())
reader = BarCodeReader("test.png", None, DecodeType.EAN_13)
#checksum enabled
reader.setChecksumValidation(ChecksumValidation.ON)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())
print("BarCode Value: " + result.getExtended().getOneD().getValue())
print("BarCode Checksum: " + result.getExtended().getOneD().getCheckSum())

The checksum validation flag.

◆ setCustomerInformationInterpretingType()

def asposebarcode.Recognition.BarCodeReader.setCustomerInformationInterpretingType (   self,
  value 
)

Sets the Interpreting Type for the Customer Information of AustralianPost BarCode.Default is CustomerInformationInterpretingType.OTHER.

◆ setDetectEncoding()

def asposebarcode.Recognition.BarCodeReader.setDetectEncoding (   self,
  value 
)

A flag which force engine to detect codetext encoding for Unicode codesets.

This sample shows how to detect text encoding on the fly if DetectEncoding is enabled

let image = "image.png"
generator = BarcodeGenerator(EncodeTypes.QR, "пїЅпїЅпїЅпїЅпїЅ")
generator.getParameters().getBarcode().getQR().setCodeTextEncoding("UTF-8")
generator.save(image, BarCodeImageFormat.getPng())
#detects encoding for Unicode codesets is enabled
reader = BarCodeReader(image, None, DecodeType.QR)
reader.setDetectEncoding(true)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())
#detect encoding is disabled
reader = BarCodeReader(image, None, DecodeType.QR)
reader.setDetectEncoding(true)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())

◆ setQualitySettings()

def asposebarcode.Recognition.BarCodeReader.setQualitySettings (   self,
  value 
)

QualitySettings allows to configure recognition quality and speed manually.

You can quickly set up QualitySettings by embedded presets: HighPerformance, NormalQuality,

HighQuality, MaxBarCodes or you can manually configure separate options.

Default value of QualitySettings is NormalQuality.

This sample shows how to use QualitySettings with BarCodeReader

reader = BarCodeReader("test.png", None, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ])
#set high performance mode
reader.setQualitySettings(QualitySettings.getHighPerformance())
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())
reader = BarCodeReader("test.png", None, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ])
#normal quality mode is set by default
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())
reader = BarCodeReader("test.png", None, [ DecodeType.CODE_39_STANDARD, DecodeType.CODE_128 ])
#set high performance mode
reader.setQualitySettings(QualitySettings.getHighPerformance())
#set separate options
reader.getQualitySettings().setAllowMedianSmoothing(true)
reader.getQualitySettings().setMedianSmoothingWindowSize(5)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())

QualitySettings to configure recognition quality and speed.

◆ setStripFNC()

def asposebarcode.Recognition.BarCodeReader.setStripFNC (   self,
  value 
)

Strip FNC1, FNC2, FNC3 characters from codetext.

Default value is false.

This sample shows how to strip FNC characters

generator = BarcodeGenerator(EncodeTypes.GS1Code128, "(02)04006664241007(37)1(400)7019590754")
generator.save("test.png")
reader = BarCodeReader("test.png", None, DecodeType.CODE_128)
#StripFNC disabled
reader.setStripFNC(false)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())
reader = BarCodeReader("test.png", None, DecodeType.CODE_128)
#StripFNC enabled
reader.setStripFNC(true)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())

◆ setTimeout()

def asposebarcode.Recognition.BarCodeReader.setTimeout (   self,
  value 
)

Sets the timeout of recognition process in milliseconds.

reader = BarCodeReader("test.png", None, None)
reader.setTimeout(5000)
for result in reader.readBarCodes():
print("BarCode CodeText: " + result.getCodeText())

:param: value The timeout.

Member Data Documentation

◆ barcodeSettings

asposebarcode.Recognition.BarCodeReader.barcodeSettings

◆ javaClassName

string asposebarcode.Recognition.BarCodeReader.javaClassName = "com.aspose.mw.barcode.recognition.MwBarCodeReader"
static

◆ qualitySettings

asposebarcode.Recognition.BarCodeReader.qualitySettings

◆ recognizedResults

asposebarcode.Recognition.BarCodeReader.recognizedResults