Skip to main content

The python wrapper for the Basler pylon Camera Software Suite.

Project description

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 at pypylon-samples.

Please Note: This project is offered with limited technical support by Basler AG. You are welcome to post any questions or issues on GitHub. For additional technical assistance, please reach out to our official Support team.

Build Status

Getting Started

  • Install pylon This is strongly recommended but not mandatory. See known issues for further details.
  • Install pypylon: pip3 install pypylon For more installation options and the supported systems please read the Installation paragraph.
  • Look at samples/grab.py or use the following snippet:
from pypylon import pylon

camera = pylon.InstantCamera(pylon.TlFactory.GetInstance().CreateFirstDevice())
camera.Open()

# demonstrate some feature access
new_width = camera.Width.Value - camera.Width.Inc
if new_width >= camera.Width.Min:
    camera.Width.Value = new_width

numberOfImagesToGrab = 100
camera.StartGrabbingMax(numberOfImagesToGrab)

while camera.IsGrabbing():
    grabResult = camera.RetrieveResult(5000, pylon.TimeoutHandling_ThrowException)

    if grabResult.GrabSucceeded():
        # Access the image data.
        print("SizeX: ", grabResult.Width)
        print("SizeY: ", grabResult.Height)
        img = grabResult.Array
        print("Gray value of first pixel: ", img[0, 0])

    grabResult.Release()
camera.Close()

Getting Started with pylon Data Processing

from pypylon import pylondataprocessing
import os

resultCollector = pylondataprocessing.GenericOutputObserver()
recipe = pylondataprocessing.Recipe()
recipe.Load('dataprocessing_barcode.precipe')
recipe.RegisterAllOutputsObserver(resultCollector, pylon.RegistrationMode_Append);
recipe.Start()

for i in range(0, 100):
    if resultCollector.GetWaitObject().Wait(5000):
        result = resultCollector.RetrieveResult()
        # Print the barcodes
        variant = result["Barcodes"]
        if not variant.HasError():
            # Print result data
            for barcodeIndex in range(0, variant.NumArrayValues):
                print(variant.GetArrayValue(barcodeIndex).ToString())
        else:
            print("Error: " + variant.GetErrorDescription())
    else:
        print("Result timeout")
        break

recipe.Unload()

Update your code to pypylon >= 3.0.0

The current pypylon implementation allows direct feature assignment:

cam.Gain = 42

This 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 = 42

To identify the locations in your code that have to be updated, run with enabled warnings:

PYTHONWARNINGS=default python script.py

Installation

Prerequisites

  • Installed pylon For the binary installation this is not mandatory but strongly recommended. See known issues for further details.
  • Installed python with pip
  • Installed CodeMeter Runtime when you want to use pylon vTools and the pylon Data Processing API extension on your platform.

pylon OS Versions and Features

Please 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 Camera Software Suite 8.1.0 supports Windows 10/11 64 bit, Linux x86_64 and Linux aarch64 with glibc version >= 2.31 or newer, macOS Sonoma 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/
  • CXP-12: To use CXP with pypylon >= 4.0.0 you need to install the CXP GenTL producer and drivers using the pylon Camera Software Suite setup.
  • For accessing Basler 3D cameras, e.g. Basler blaze, installation of pylon Camera Software Suite 8.1.0 and the latest pylon Supplementary Package for blaze is required.

Binary Installation

The easiest way to get pypylon is to install a prebuild wheel. Binary releases for most architectures are available on pypi**. To install pypylon open your favourite terminal and run:

pip3 install pypylon

The following versions are available on pypi:

3.9 3.10 3.11 3.12 3.13
Windows 64bit x x x x x
Linux x86_64* x x x x x
Linux aarch64* x x x x x
macOS x86_64** x x x x x
macOS arm64** x x x x x

Additional Notes on binary packages:

  • (*) 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 >= 14.0 (Sonoma)

Installation from Source

Building the pypylon bindings is supported and tested on Windows, Linux and macOS

You need a few more things to compile pypylon:

  • An installation of pylon SDK for your platform
  • A 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-dev on linux)
  • swig 4.3
    • For all 64bit platforms you can install the tool via pip install "swig==4.3"

To build pypylon from source:

git clone https://github.com/basler/pypylon.git
cd pypylon
pip install .

If pylon SDK is not installed in a default location you have to specify the location from the environment

  • on Linux: export PYLON_ROOT=<installation directory of pylon SDK>
  • on macOS: export PYLON_FRAMEWORK_LOCATION=<framework base folder that contains pylon.framework>

Development

Pull requests to pypylon are very welcome. To help you getting started with pypylon improvements, here are some hints:

Starting Development

python setup.py develop

This 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, execute python setup.py build and test...

Running Unit Tests

NOTE: The unit tests try to import pypylon...., so they run against the installed version of pypylon.

pytest tests/....

Known Issues

  • For 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 official pylon package.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

pypylon-26.4.1-cp39-abi3-win_amd64.whl (111.8 MB view details)

Uploaded CPython 3.9+Windows x86-64

pypylon-26.4.1-cp39-abi3-manylinux_2_31_x86_64.whl (88.7 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.31+ x86-64

pypylon-26.4.1-cp39-abi3-manylinux_2_31_aarch64.whl (71.3 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.31+ ARM64

pypylon-26.4.1-cp39-abi3-macosx_14_0_x86_64.whl (30.4 MB view details)

Uploaded CPython 3.9+macOS 14.0+ x86-64

pypylon-26.4.1-cp39-abi3-macosx_14_0_arm64.whl (30.4 MB view details)

Uploaded CPython 3.9+macOS 14.0+ ARM64

File details

Details for the file pypylon-26.4.1-cp39-abi3-win_amd64.whl.

File metadata

  • Download URL: pypylon-26.4.1-cp39-abi3-win_amd64.whl
  • Upload date:
  • Size: 111.8 MB
  • Tags: CPython 3.9+, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.13

File hashes

Hashes for pypylon-26.4.1-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 0b4868c0ce6d62c3bee9c62fcf58773dad40f8e598cb5bd09e15eb2e9ffd5b2e
MD5 bd260e16b4bc4dffbc4c7fb443db7999
BLAKE2b-256 deb4406b8162bd46bdd05df0bad3b849ec632fa617384586df8176b089d18cf0

See more details on using hashes here.

File details

Details for the file pypylon-26.4.1-cp39-abi3-manylinux_2_31_x86_64.whl.

File metadata

File hashes

Hashes for pypylon-26.4.1-cp39-abi3-manylinux_2_31_x86_64.whl
Algorithm Hash digest
SHA256 cf9267efad31bc036fb193ac94e55ad7c3291170d4bcaa1e4476c500f206dba0
MD5 f9198b615e6761796360087d6c8d7c0a
BLAKE2b-256 1ba5120b7640027f8e6d7062e2e8e3ffd5ed54cf407853812ce90012bad93c0c

See more details on using hashes here.

File details

Details for the file pypylon-26.4.1-cp39-abi3-manylinux_2_31_aarch64.whl.

File metadata

File hashes

Hashes for pypylon-26.4.1-cp39-abi3-manylinux_2_31_aarch64.whl
Algorithm Hash digest
SHA256 777f8978ac2856995a7a9a6ec27a1ec8c5514479084fca32b6fc3ca04b73f2ca
MD5 1f93571e4603729501f7e14e85c5b622
BLAKE2b-256 6188dc2f3951e6e1e731c7c0e9109c7fa3456ae5f73b9e1363567266d0e04030

See more details on using hashes here.

File details

Details for the file pypylon-26.4.1-cp39-abi3-macosx_14_0_x86_64.whl.

File metadata

File hashes

Hashes for pypylon-26.4.1-cp39-abi3-macosx_14_0_x86_64.whl
Algorithm Hash digest
SHA256 2cb20789f4f7f5aa3ee671c2c70c3103b8619a969b6cb3284162726dde0e93c7
MD5 053ae9b7d7059aeabbfe417db5ff3af0
BLAKE2b-256 13b4e47c76136f498fb3c9b72f7775918bba8a34ff144dc796ae7ea3533631cf

See more details on using hashes here.

File details

Details for the file pypylon-26.4.1-cp39-abi3-macosx_14_0_arm64.whl.

File metadata

File hashes

Hashes for pypylon-26.4.1-cp39-abi3-macosx_14_0_arm64.whl
Algorithm Hash digest
SHA256 ec075daf70c6121222c03a160078e71ebd4acc6c31082b74a2b175da89d884be
MD5 c9ccebf37d0abc281a1ec5794b92e8d4
BLAKE2b-256 0a87e9b38417b5f32106d228307deb5fbd8cd82a0baa103909adca3da61140d5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page