Hello,
we have a subscription for the Barcode Recognize API.
We have found an example that certain images are recognized if sent to the web site with Options “Excellent” and “SSCC-18” but if sent from a program, we get no results.
The code that we have to recognize images is the following:
configuration = aspose_barcode_cloud.Configuration(
client_id= client_id,
client_secret= client_secret,
)
# create an instance of the API class
api = aspose_barcode_cloud.BarcodeApi(aspose_barcode_cloud.ApiClient(configuration))
try:
response = api.post_barcode_recognize_from_url_or_content(
image=file_path,
preset=aspose_barcode_cloud.PresetType.HIGHQUALITYDETECTION,
type="SSCC18")
return response
except ApiException as e:
print("Exception when calling BarcodeApi->get_barcode_recognize: %s\n" % e)
Our web site use special optimization which reduces image size. Some camera noise were reduced with image compression. As workaround, I can suggest you to reduce image size by half with Python Pillow library. See example:
# Additional code to resize image
from PIL import Image
with Image.open(file_path) as image:
orig_size = image.size
image.thumbnail(size=(orig_size[0]//2, orig_size[1]//2))
fd, shrunk_file_path = tempfile.mkstemp()
os.close(fd)
with open(shrunk_file_path, "wb") as f:
image.save(f, format="PNG")
# Existing code
# create an instance of the API class
api = aspose_barcode_cloud.BarcodeApi(aspose_barcode_cloud.ApiClient(configuration))
try:
response = api.post_barcode_recognize_from_url_or_content(
image=shrunk_file_path,
preset=aspose_barcode_cloud.PresetType.HIGHQUALITYDETECTION,
type="SSCC18")
return response
except ApiException as e:
print("Exception when calling BarcodeApi->get_barcode_recognize: %s\n" % e)