barKoder SDK - Python library

Requirements #

  • A 64-bit OS based on Linux, for an x86-64 CPU architecture. As a general guideline Ubuntu 22.04 or newer is recommended. Install commands given below assume a Debian distro is used (but are not limited to).
  • python3 (version 3.11 or newer; contact us if you need support for older versions)
  • Most linux distos come with python. If not already present, it can be installed with:

sudo apt-get install python3

  • opencv-python (for sample app; note that this package has to be installed for the same version of python that will be used)
  • OpenCV for Python can be installed via pip with:

sudo apt install python3-pip

sudo pip3 install opencv-python

  • curl (optional)

Curl might be needed for licensing, depending on the type of license used. In particular, curl from snap is required (ref https://snapcraft.io/curl). It can be installed with:

sudo apt install snapd

sudo snap install curl

Using a specific python version #

If you need to use a specific python version, i.e. running the sample app like so:

                python3.11 run.py
            

you may need to install a side-by-side python version, different than the one you have, for example:

                sudo apt-get install python3.11
            

and OpenCV for Python should also be available under that version, and can be installed with:

                python3.11 -m pip install opencv-python
            

On RedHat distributions you may need to add, depending on which distro you are working with:

                sudo yum install mesa-libGL
            

Python SDK Examples#

Handling and Showing Results#

                #---------------handle the result--------------
result = json.loads(result_json)

print("resultsCount: ", result["resultsCount"])

# the result is a Python dictionary:
if result["resultsCount"] == 1:
    print(result["barcodeTypeName"])
    print(result["textualData"])
    
elif result["resultsCount"] > 1:
    for res in result["results"]:
        print(res["barcodeTypeName"])
        print(res["textualData"])
        print("---------------------------")
        
else:
    print("No barcode found.")
#---------------handle the result--------------
            

Page Contents

History:

close