Basler Pylon 5 API from Python

You can control Basler cameras from Python using the Pylon 5 API via Cython with this procedure for Linux, Mac, and Windows. The Raspberry Pi and some other ARM systems are also covered by Basler camera drivers. PyPylon (the Python Basler interface) is Python 2.7 and Python 3 compatible.

Install Basler Python API

  1. Install Pylon 5 with SDK/Developer options. For the Raspberry Pi 3, choose ARM 32-bit hardfloat Debian installer.

     sudo gdebi pylon_5*.deb
    

    This puts icons in your Linux menu under “Sound & Video/pylon Viewer” and “other/pylon IP Configurator”.

  2. setup PyPylon:

     git clone https://github.com/mabl/PyPylon
     cd PyPylon
     python setup.py develop
    
  3. try PyPylon example scripts

Live Basler preview on Raspberry Pi

The ARM install as well as x86 Linux installs put the Basler Pylon GUI live viewer at

/opt/pylon5/bin/PylonViewerApp

Notes

Fix error

ImportError: PyPylon/pypylon/cython/factory.cpython-36m-x86_64-linux-gnu.so: undefined symbol: _ZTINSt8ios_base7failureB5cxx11E

conda install libgcc

Error

RuntimeError: Payload data has been discarded. Payload data can be discarded by the camera device if the available bandwidth is insufficient.

Basler claims root is needed but that didn’t solve it for me on an x64 Linux laptop. RichardLangFromNZ fork of PyPylon didn’t help either.

Reference

The PyPylon Python Basler API is used extensively by the Open Source Cytometry Project.

Leave a Comment