Package: pypylon
The official python wrapper for the Basler pylon Camera Software Suite.Background information about usage of pypylon, programming samples and jupyter notebooks can also be found atpypylon-samples.Please Note:This project is offered with no technical support by Basler AG.
You are welcome to post any questions or issues onGitHubor onImagingHub.Getting StartedInstallpylonThis is strongly recommended but not mandatory. Seeknown issuesfor further details.Install pypylon:pip3 install pypylonFor more installation options and the supported systems please read theInstallationparagraph.Look atsamples/grab.pyor use the following snippet:frompypylonimportpyloncamera=pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())camera.Open()# demonstrate some feature accessnew_width=camera.Width.Value-camera.Width.Incifnew_width>=camera.Width.Min:camera.Width.Value=new_widthnumberOfImagesToGrab=100camera.StartGrabbingMax(numberOfImagesToGrab)whilecamera.IsGrabbing():grabResult=camera.RetrieveResult(5000,pylon.TimeoutHandling_ThrowException)ifgrabResult.GrabSucceeded():# Access the image data.print("SizeX: ",grabResult.Width)print("SizeY: ",grabResult.Height)img=grabResult.Arrayprint("Gray value of first pixel: ",img[0,0])grabResult.Release()camera.Close()Getting Started with pylon Data Processingpypylon additionally supports the pylon Data Processing API extension.Thepylon Workbenchallows you to create image processing designs using a graphical editor.Hint: Thepylondataprocessing_testscan optionally be used as a source of information about the syntax of the API.Look atsamples/dataprocessing_barcode.pyor use the following snippet:frompypylonimportpylondataprocessingimportosresultCollector=pylondataprocessing.GenericOutputObserver()recipe=pylondataprocessing.Recipe()recipe.Load('dataprocessing_barcode.precipe')recipe.RegisterAllOutputsObserver(resultCollector,pylon.RegistrationMode_Append);recipe.Start()foriinrange(0,100):ifresultCollector.GetWaitObject().Wait(5000):result=resultCollector.RetrieveResult()# Print the barcodesvariant=result["Barcodes"]ifnotvariant.HasError():# Print result dataforbarcodeIndexinrange(0,variant.NumArrayValues):print(variant.GetArrayValue(barcodeIndex).ToString())else:print("Error: "+variant.GetErrorDescription())else:print("Result timeout")breakrecipe.Unload()Update your code to pypylon >= 3.0.0The current pypylon implementation allows direct feature assignment:cam.Gain=42This assignment style is deprecated with pypylon 3.0.0, as it prevents full typing support for pypylon.The recommended assignment style is now:cam.Gain.Value=42To identify the locations in your code that have to be updated, run with enabled warnings:PYTHONWARNINGS=default python script.pyInstallationPrerequisitesInstalledpylonFor the binary installation this is not mandatory but strongly recommended. Seeknown issuesfor further details.InstalledpythonwithpipInstalledCodeMeter Runtimewhen you want to use pylon vTools and the pylon Data Processing API extension on your platform.pylon OS Versions and FeaturesPlease note that the pylon Camera Software Suite may support different operating system versions and features than pypylon.
For latest information on pylon refer to:https://www.baslerweb.com/en/software/pylon/In addition, check the release notes of your pylon installation.
For instance:pylon 7.4.0 supports Windows 10/11 64 bit, Linux x86_64 and Linux aarch64 with glibc version >= 2.31 or newer.pylon vTools are supported on pylon 7.0.0 and newer.pylon vTools are supported on pypylon 3.0 and newer only on Windows 10/11 64 bit, Linux x86_64 and Linux aarch64.For pylon vTools that require a license refer to:https://www.baslerweb.com/en/software/pylon-vtools/Binary InstallationThe easiest way to get pypylon is to install a prebuild wheel.
Binary releases for most architectures are available onpypi**.
To install pypylon open your favourite terminal and run:pip3 install pypylonThe following versions are available on pypi:3.63.73.83.93.103.11Windows 64bitxxxxxxLinux x86_64***xxxxxxLinux armv7l*xxxxxxLinux aarch64***xxxxxxmacOS x86_64**xxxxxxmacOS arm64**xxxxAdditional Notes on binary packages:(*) The linux 32bit binaries are manylinux_2_28 conformant.
This is roughly equivalent to a minimum glibc version >= 2.28.
:warning: You need at least pip 20.3 to install them.(***) The linux 64bit binaries are manylinux_2_31 conformant.
This is roughly equivalent to a minimum glibc version >= 2.31.
:warning: You need at least pip 20.3 to install them.(**) macOS binaries are built for macOS >= 11.0 (Big-Sur)Installation from SourceBuilding the pypylon bindings is supported and tested on Windows, Linux and macOSYou need a few more things to compile pypylon:An installation of pylon SDK for your platformA compiler for your system (Visual Studio on Windows, gcc on linux, xCode commandline tools on macOS)Python development files (e.g.sudo apt install python-devon linux)swig>= 4.0For all 64bit platforms you can install the tool viapip install swigTo build pypylon from source:git clone https://github.com/basler/pypylon.gitcd pypylonpip install .If pylon SDK is not installed in a default location you have to specify the location from the environmenton Linux:export PYLON_ROOT=<installation directory of pylon SDK>on macOS:export PYLON_FRAMEWORK_LOCATION=<framework base folder that contains pylon.framework>DevelopmentPull requests to pypylon are very welcome. To help you getting started with pypylon improvements, here are some hints:Starting Developmentpython setup.py developThis will "link" the local pypylon source directory into your python installation. It will not package the pylon libraries and always use the installed pylon.
After changing pypylon, executepython setup.py buildand test...Running Unit TestsNOTE: The unit tests try to importpypylon...., so they run against theinstalledversion of pypylon.pytest tests/....Known IssuesFor USB 3.0 cameras to work on Linux, you need to install appropriate udev rules.
The easiest way to get them is to install the officialpylonpackage.