Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
When working with barcodes in applications, optimizing recognition quality and speed is essential. The RecognitionMode
setting in the Aspose.BarCode.Cloud SDK for Python offers a way to adjust these parameters, making it possible to prioritize either quality or speed during barcode recognition.
The RecognitionMode
parameter can be set to the following values to control the recognition process:
The RecognizeApi
interface provides methods to recognize barcodes from files using different HTTP request types. Below are the available methods:
recognize
: Recognizes barcode from a file on the server using a GET
request.recognize_body
: Recognizes barcode from a file provided in the request body using a POST
request with JSON or XML format.recognize_multipart
: Recognizes barcode from a file provided in the request body using a POST
request with multipart/form-data
.recognize
import os
from aspose_barcode_cloud import (
RecognizeApi,
ApiClient,
Configuration,
DecodeBarcodeType,
RecognitionImageKind,
RecognitionMode,
)
def make_configuration():
access_token = os.getenv("TEST_CONFIGURATION_ACCESS_TOKEN")
if access_token:
config = Configuration(access_token=access_token)
else:
config = Configuration(
client_id="Client Id from https://dashboard.aspose.cloud/applications",
client_secret="Client Secret from https://dashboard.aspose.cloud/applications",
)
return config
def main():
config = make_configuration()
recognize_api = RecognizeApi(ApiClient(config))
result = recognize_api.recognize(
barcode_type=DecodeBarcodeType.QR,
file_url="https://products.aspose.app/barcode/scan/img/how-to/scan/step2.png",
recognition_mode=RecognitionMode.FAST,
recognition_image_kind=RecognitionImageKind.PHOTO,
)
print(f"File recognized, result: '{result.barcodes[0].barcode_value}'")
if __name__ == "__main__":
main()
recognize_body
import os
import base64
from aspose_barcode_cloud import (
RecognizeApi,
ApiClient,
Configuration,
DecodeBarcodeType,
RecognizeBase64Request,
)
def make_configuration():
access_token = os.getenv("TEST_CONFIGURATION_ACCESS_TOKEN")
if access_token:
config = Configuration(access_token=access_token)
else:
config = Configuration(
client_id="Client Id from https://dashboard.aspose.cloud/applications",
client_secret="Client Secret from https://dashboard.aspose.cloud/applications",
)
return config
def main():
config = make_configuration()
recognize_api = RecognizeApi(ApiClient(config))
file_name = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "testdata", "pdf417.png"))
with open(file_name, "rb") as file:
image_bytes = file.read()
image_base64 = base64.b64encode(image_bytes).decode("utf-8")
request = RecognizeBase64Request(barcode_types=[DecodeBarcodeType.PDF417], file_base64=image_base64)
result = recognize_api.recognize_base64(request)
print(f"File '{file_name}' recognized, result: '{result.barcodes[0].barcode_value}'")
if __name__ == "__main__":
main()
recognize_multipart
import os
from aspose_barcode_cloud import (
RecognizeApi,
ApiClient,
Configuration,
DecodeBarcodeType,
RecognitionImageKind,
RecognitionMode,
)
def make_configuration():
access_token = os.getenv("TEST_CONFIGURATION_ACCESS_TOKEN")
if access_token:
config = Configuration(access_token=access_token)
else:
config = Configuration(
client_id="Client Id from https://dashboard.aspose.cloud/applications",
client_secret="Client Secret from https://dashboard.aspose.cloud/applications",
)
return config
def main():
config = make_configuration()
recognize_api = RecognizeApi(ApiClient(config))
file_name = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "testdata", "aztec.png"))
with open(file_name, "rb") as file:
file_content = file.read()
result = recognize_api.recognize_multipart(
DecodeBarcodeType.AZTEC, file_content, RecognitionMode.NORMAL, RecognitionImageKind.SCANNEDDOCUMENT
)
if result.barcodes:
print(
f"File '{file_name}' recognized, results: value: '{result.barcodes[0].barcode_value}', type: {result.barcodes[0].type}"
)
else:
print(f"File '{file_name}' recognized, but no barcodes found.")
if __name__ == "__main__":
main()
Choosing the appropriate RecognitionMode
is essential in tailoring barcode recognition to the specific needs of your application. Whether prioritizing speed or accuracy, the examples provided demonstrate how to use the RecognizeApi
interface to adjust settings for optimal performance. By fine-tuning RecognitionMode
and RecognitionImageKind
, you can enhance both efficiency and accuracy, making your barcode processing solution robust across various use cases.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.