From Zero to Image
This guide will get you all set up for Python-based image processing on your Raspberry Pi 3! You can also use this guide with other hardware if you apply some slight tweaks (e.g. pick another architecture when downloading software). You should also be familiar with basic usage of your system's terminal. Let's get started!
Prerequisites
- This guide assumes that you're running Debian Jessie or a similar derivate (think Ubuntu) on your machine
- Ensure your system's software is up-to-date by running the following commands from your terminal:
sudo apt-get update
sudo apt-get dist-upgrade
sudo raspi-update
pylon
Pylon contains all the software we need for interacting with Basler cameras. Builds are provided for multiple platforms.
- Download the latest pylon version from here, pick the hardfloat ARM version for Linux
- Unpack the file to a directory of your choice
- Follow the instructions in the
INSTALL
file. Do not attempt to run the pylon viewer as it is not bundled with ARM releases - After successful installation plug in e.g. your Basler USB camera
- Now we will check if everything works. In your terminal move to pylon's
Samples/Grab
directory and executemake
, then run./Grab
, you should see some text scrolling with information about pictures being grabbed
OpenCV and Python 3
In this step we'll set up Python 3 and the OpenCV image processing library. Just follow the instructions over here.
PyPylon
The only missing part is connecting Python to your camera now. PyPylon takes care of this task.
- First, ensure you're using the
cv
virtualenv you created while installing OpenCV - Get your exact python version by running
python --version
from within your virtualenv - Using this information, pick the corresponding PyPylon version from here (e.g. Python 3.4 →
..cp34-cp34m-linux_armv7l.whl
) - Install the
whl
file with pip viapip3 install *path-to-whl*
- Open a Python REPL with
python
and check that runningimport pypylon.pylon
does not yield any errors
Done! You can either try out our example projects now or create some cool stuff of your own. Have fun!