![]() |
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 _MwWrapper.
Public Member Functions | |
| def | __init__ (self, Optional[Union[str, os.PathLike, bytes, BinaryIO, Image.Image, None]] image, Optional[Union[List[DecodeType], DecodeType, None]] decode_types) |
| Initializes a new instance of the BarCodeReader. More... | |
| None | abort (self) |
| None | barcode_image (self, Optional[Union[str, "os.PathLike"], bytes, BinaryIO, Image.Image, None] image, Optional[Union[List[RectLike], RectLike]] areas) |
| Sets bitmap image and areas for Recognition. More... | |
| Union[List[DecodeType], DecodeType] | barcode_read_type (self) |
| None | barcode_read_type (self, Union[List[DecodeType], DecodeType] types) |
| Sets SingleDecodeType type array for Recognition. More... | |
| Optional[BarcodeSettings] | barcode_settings (self) |
| bool | contains_any (self, Union[List[DecodeType], DecodeType] decode_types) |
| bool | export_to_xml (self, str xml_file) |
| Optional[List[BarCodeResult]] | found_barcodes (self) |
| int | found_count (self) |
| def | from_image_with_areas (cls, Optional[Union[str, os.PathLike, bytes, BinaryIO, Image.Image]] image, Optional[Union[List[RectLike], RectLike]] areas, Optional[Union[List[DecodeType], DecodeType]] decode_types) |
| Initializes a new instance of the BarCodeReader. More... | |
| BarCodeReader | import_from_xml (cls, str xml_file) |
| Imports BarCode properties from the specified XML file. More... | |
| Optional[QualitySettings] | quality_settings (self) |
| None | quality_settings (self, QualitySettings value) |
| Optional[List[BarCodeResult]] | read_barcodes (self) |
| int | timeout (self) |
| None | timeout (self, int value) |
Public Attributes | |
| barcodeSettings | |
| qualitySettings | |
| recognizedResults | |
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.
| def __init__ | ( | self, | |
| Optional[Union[str, os.PathLike, bytes, BinaryIO, Image.Image, None]] | image, | ||
| Optional[Union[List[DecodeType], DecodeType, None]] | decode_types | ||
| ) |
Initializes a new instance of the BarCodeReader.
| image encoded as base64 string or path to image | |
| decode_types the array of objects by DecodeType |
| None abort | ( | self | ) |
| None barcode_image | ( | self, | |
| Optional[Union[str, "os.PathLike"], bytes, BinaryIO, Image.Image, None] | image, | ||
| Optional[Union[List[RectLike], RectLike]] | areas | ||
| ) |
Sets bitmap image and areas for Recognition.
Must be called before ReadBarCodes() method. This sample shows how to detect Code39 and Code128 barcodes.
| imageResource path to image or object of PIL.Image | |
| areas The areas list for recognition |
| BarCodeException |
| Union[List[DecodeType], DecodeType] barcode_read_type | ( | self | ) |
Gets the decode types of the input barcode decoding.
| None barcode_read_type | ( | self, | |
| Union[List[DecodeType], DecodeType] | types | ||
| ) |
Sets SingleDecodeType type array for Recognition.
Must be called before readBarCodes() method.
This sample shows how to detect Code39 and Code128 barcodes.
| types The SingleDecodeType type array to read. |
| Optional[BarcodeSettings] barcode_settings | ( | self | ) |
The main BarCode decoding parameters. Contains parameters that influence the recognized data.
| bool contains_any | ( | self, | |
| Union[List[DecodeType], DecodeType] | decode_types | ||
| ) |
Determines whether any of the given decode types is included. :param decode_types: Types to verify. :return: True if any of the types are included.
| bool export_to_xml | ( | self, | |
| str | xml_file | ||
| ) |
Exports BarCode properties to an XML file.
| Optional[List[BarCodeResult]] found_barcodes | ( | self | ) |
Recognized barcodes as a list of BarCodeResult.
Example:
reader = Recognition.BarCodeReader(image_path_code39, None, [Recognition.DecodeType.CODE_39, Recognition.DecodeType.CODE_128])
reader.read_barcodes()
for result in reader.found_barcodes:
print("BarCode CodeText:", result.code_text)
:return: Recognized barcodes.
| int found_count | ( | self | ) |
Number of recognized barcodes.
Example:
reader = Recognition.BarCodeReader(self.image_path, None, [Recognition.DecodeType.CODE_39, Recognition.DecodeType.CODE_128])
reader.read_barcodes()
print(f\"\\nFound {reader.found_count} barcodes\")
:return: Count of recognized barcodes.
| def from_image_with_areas | ( | cls, | |
| Optional[Union[str, os.PathLike, bytes, BinaryIO, Image.Image]] | image, | ||
| Optional[Union[List[RectLike], RectLike]] | areas, | ||
| Optional[Union[List[DecodeType], DecodeType]] | decode_types | ||
| ) |
Initializes a new instance of the BarCodeReader.
| image encoded as base64 string or path to image | |
| areas array of object by type Rectangle | |
| decode_types the array of objects by DecodeType |
| BarCodeReader import_from_xml | ( | cls, | |
| str | xml_file | ||
| ) |
Imports BarCode properties from the specified XML file.
| Optional[QualitySettings] quality_settings | ( | self | ) |
QualitySettings allows configuring recognition quality and speed.
You can quickly set up QualitySettings using presets:
HighPerformance, NormalQuality, HighQuality, MaxBarCodes,
or configure options manually.
Default value: NormalQuality.
\code
reader = BarCodeReader(image_path, None, None)
# set high performance mode
reader.quality_settings = QualitySettings.high_performance()
for result in reader.read_barcodes():
print("BarCode CodeText:", result.code_text)
# normal quality mode is default
for result in reader.read_barcodes():
print("BarCode CodeText:", result.code_text)
# set high performance and tweak options
reader.quality_settings = QualitySettings.high_performance()
qs = reader.quality_settings
qs.allow_incorrect_barcodes = True
for result in reader.read_barcodes():
print("BarCode CodeText:", result.code_text)
\endcode
| None quality_settings | ( | self, | |
| QualitySettings | value | ||
| ) |
| Optional[List[BarCodeResult]] read_barcodes | ( | self | ) |
Reads barcodes from the image.
Example:
reader = Recognition.BarCodeReader(self.image_path, None, [Recognition.DecodeType.CODE_39, Recognition.DecodeType.CODE_128])
for result in reader.read_barcodes():
print("BarCode CodeText:", result.code_text)
# or use found_barcodes after reading
reader.read_barcodes()
for result in reader.found_barcodes:
print("BarCode CodeText:", result.code_text)
:return: A list of recognized BarCodeResult objects. If nothing is recognized, an empty list is returned.
| int timeout | ( | self | ) |
Timeout of the recognition process in milliseconds.
\code
reader = BarCodeReader("test.png")
reader.timeout = 5000
for result in reader.read_barcodes():
print("BarCode CodeText:", result.code_text)
\endcode
:return: Timeout in milliseconds.
| None timeout | ( | self, | |
| int | value | ||
| ) |
Timeout of the recognition process in milliseconds. :param value: Timeout in milliseconds.
| barcodeSettings |
| qualitySettings |
| recognizedResults |