Sample applications, Jupyter notebooks, and contrib utilities using pypylon, the official Python language binding for the Basler pylon C++ APIs.
This is a companion repository to pypylon. The examples cover camera configuration, image acquisition, triggering, sequencers, and serial communication.
The pypylon Programmer's Guide is available in the Basler Product Documentation and on GitHub.
-
Install Python with pip. Installing the pylon Software Suite is also recommended; some camera interfaces require additional drivers. See the pypylon installation instructions for platform and camera requirements.
-
Clone this repository and install the notebook dependencies:
git clone https://github.com/basler/pypylon-samples.git cd pypylon-samples python -m pip install -r requirements.txt
-
For example, start JupyterLab and open a notebook from the overview below:
jupyter lab
For the contrib examples, also install pypylon-contrib.
Note: Camera features and names vary between models and interfaces. Check the requirements in each notebook before running it. Samples may not always reflect the latest pypylon API or coding style; refer to the pypylon samples and changelog for current guidance.
- Some of the content was part of the Basler webinar about pypylon. You can watch this to get more in depth information about pylon SDK and pypylon. Please check for the recording at Basler PyPylon Webinar
- The Python requirements to run the Jupyter notebooks and samples are listed in requirements.txt.
These examples use pypylon directly and do not require pypylon-contrib. Notebook, visualization, and image-processing dependencies are included in requirements.txt.
-
Device enumeration and configuration basics deviceenumeration_and_configuration
-
Demonstration of different grab strategies grabstrategies
-
How to handle multicamera setups in pypylon multicamera
-
Using hardware trigger and access image chunks ( USB ) hw_trigger_and_chunks
-
Low overhead image capturing in a virtual line scan setup and display in notebook ( USB ) USB_linescan_performance_demo_opencv_notebook
-
Exposure bracketing using the sequencer feature of ace devices ( USB) USB_HDR_exposure_sequencer
-
Exposure bracketing using the sequencer feature of ace2/boost-R devices ( USB) USB_Ace2_BoostR_HDR_exposure_sequencer
-
Full HDR multi-exposure example full_HDR_multiexposure_example
These examples require the pypylon-contrib library which provides additional utilities and helper functions. Install it using:
python -m pip install pypylon-contrib-
Sequencer utilities - Simplified interface for camera sequencer configuration sequencer
Demonstrates how to configure camera sequences using the
CameraSequence,SinglePathSet, andSequencerTransitionclasses from pypylon-contrib. -
Serial communication - Communication with serial devices connected to Basler cameras serial_communication
Shows how to use the BaslerSerial class to communicate with serial devices connected to a Basler camera, enabling control of external hardware through the camera's serial interface.
Pull requests to pypylon-samples are very welcome. e.g. generic samples that demonstrate interaction with GUI toolkits, as we typically only use Qt.
To work on the contrib utilities, install the local package with development and notebook dependencies:
python -m pip install -e ".[dev,notebook]"Run the unit tests with:
python -m pytest tests- info table missing that clearly identifies which samples work for which camera model
You are welcome to post any questions or issues on GitHub. For questions or issues related to these samples or the contrib utilities, please use pypylon-samples issues. For issues with pypylon itself, please use pypylon issues. For additional technical support for business customers, please reach out to our official Support team.