-
Notifications
You must be signed in to change notification settings - Fork 18
Basler Pylon for Linux backend
Tested on Ubuntu 16.04.5 LTS 64-bit.
Download pylon installation file (Ubuntu accepts Debian installer *.deb) from the official Basler Website. Install the package:
$ sudo dpkg -i pylon_5.X.XX.XXXXX-deb0_amd64.deb
NOTE: we noticed that pylon 5.1.0.12682 has a bug that partially blocks the screen. No such bug, however, is in the earlier version 5.0.12.11829.
To run the pylon software, go to the default folder (unless you decided to install it somewhere else) and run PylonViewer:
$ cd /opt/pylon5/bin/
$ ./PylonViewerApp
USB3 cameras are likely to be recognized automatically. For GigE cameras, use the configuration tool:
$ ./IpConfigurator
For testing purposes Basler GigE cameras can be connected to a computer directly (with an external power supply). If the camera is not recognized, try manual network configuration:
$ sudo ifconfig eth1 down
$ sudo ifconfig eth1 up 169.254.1.1
Replace eth1 with with the name of the interface you want to use locally with the camera (see ifconfig
). If this worked, the pylon software should be able to detect your camera.
N.B., these notes are true at time of writing, for my (Scott Livingston) application in Murray's lab, but slight naming variations may be required for your system (or if versions change, etc.). Also, I am working on 32-bit hardware, hence do not consider the 64-bit case. For the most part, a good start in that direction is to replace "32" with "64" in the notes below.
Basler's secret link to their pylon Linux package
ftp://Pylon4Linux-ro:h50UZgkl@ftp.baslerweb.com
(found on an FAQ page:
http://www.baslerweb.com/beitraege/faq_en_105934.html
they will also send (email) you the above link if you ask); Note that the link only seems to work through the Firefox browser. Anyway, the translation of it is "open an FTP connection with ftp.baslerweb.com, as user Pylon4Linux-ro, and password h50UZgkl "
They (Basler) provide packages for SuSE and Ubuntu, but both are (at time of writing) targeted at old releases of these distributions. In these instructions, we consider the most general solution, using the generic release: pylon-2.1.0-1747-bininst-32.tar.bz2 If you had trouble reading the directories found from the above FTP URL, try this direct URL:
ftp://Pylon4Linux-ro:h50UZgkl@ftp.baslerweb.com/Pylon-2.1.0/pylon-2.1.0-1747-bininst-32.tar.bz2
If these fail, contact me, Scott Livingston slivingston@caltech.edu, for a copy of the files.
When you untar/unzip this file, you will obtain various installation and other notes, and our desired file
pylon-bininst-32.tar.bz2
Copy this file onto the machine on which you wish to install Pylon for Linux. Untar/unzip it into a path off of the typical branches. E.g.,
$ cd /home/scott
$ tar -xjf pylon-bininst-32.tar.bz2
$ sudo mv pylon /opt
This will create a directory /opt/pylon , under which you can find binaries, include-related/development files and libraries associated with the Pylon for Linux distribution.
Some applications that use the Basler Pylon libraries will need access to /opt/pylon/lib/genapi, and they tend to look under /usr/lib/genapi for this. Also, some shared files were needed by the ViewerApp. Appease them with a symbolic link:
$ sudo ln -s /opt/pylon/lib/genapi /usr/lib/genapi
$ sudo ln -s /opt/pylon/share/pylon /usr/share/pylon
For some unknown reason, PylonViewerApp and possibly other programs under /opt/pylon/bin complain unless the following environment variables are set
$ export GENICAM_ROOT_V1_1=/opt/pylon
$ export GENICAM_LOG_CONFIG=/opt/pylon/share/genicam/log/config/DefaultLogging.properties
Finally, to make the recently installed libraries visible, update your library search path
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/opt/pylon/lib
To automatically set these environment variables everytime you login, append them to your shell configuration file. E.g., in Bash this is ~/.bashrc
, and in Z shell, ~/.zshrc
(where ~
expands to your home directory on Unix systems). This should suffice. In some situations, unrelated to the steps above, you need to add /usr/local/lib to the library search path. Do that by appending ":/usr/local/lib" to the above LD_LIBRARY_PATH export. Try running the Viewer Application that ships with Pylon for Linux:
$ /opt/pylon/bin/PylonViewerApp
If you camera is on the local net, you should be able to see it.
The Basler acA640 (GigE) cameras that I am working with appear to ship with a static, "automatic self-assigned" IP address. You may have trouble communicating with the cameras as such. Upon booting, however, they will (again, with the shipped firmware) look for any DHCP servers on the local net and, if one is found and friendly, obtain a dynamic address. To avoid writing abstruse one-size-fits-all directions, here is a description of the particular setup process for my use case.
I have a DHCP server on my local network. It assigns addresses to anyone who requests one, without restriction (i.e. no credentials required; though it does reserve certain addresses for special nodes on the LAN). If I attach one of the GigE cameras (as shipped by Basler, i.e. virgin) to a network switch, via a Power-over-Ethernet device, then it will obtain an address from my DHCP server. Though it is not necessary, there are at least two ways to discover the assigned address:
i) look at the DHCP server logs, for times very close to when you physically connected the camera -- this is typically (e.g., on Ubuntu/Debian) visible with
$ tail /var/log/syslog
ii) or, sniff network traffic and watch for the DHCP requests directly, the appearance of new local IP addresses, etc.
Each computer that handles camera processing (for a single camera) has two ethernet interfaces. One is for local network traffic (e.g. communication with flydra_mainbrain), and the other is for direct connection to a GigE camera. In my case, the former is eth3, and the latter is eth1. I assume eth3 is already configured properly, so you can access the host over the LAN. I configure eth1 to be a local network -- again, to be used only by this particular computer and its connected camera. This is achieved at the shell with
$ sudo ifconfig eth1 up 192.168.3.1
Note that if a mistake is made, you can always take the interface down and try again: ("sudo ifconfig eth1 down"). To make this permanent, append to the /etc/network/interfaces file
auto eth1
iface eth1 inet static
address 192.168.3.1
netmask 255.255.255.0
gateway 192.168.3.1
Now, to configure the camera (please recall, we attached it to the network as above, and it has an appropriate address as assigned by the local DHCP server), open the Basler Pylon IpConfigurator application:
$ /opt/pylon/bin/IpConfigurator
You should be able to see the camera, specified by a model name, serial number, etc. Select it (though it should be the only camera on the network, hence selected by default), and change the configuration to use a "persistent IP", with
IP Address 192.168.3.3 Subnet Mask 255.255.255.0 Gateway 192.168.3.1
uncheck the "Use DHCP" box, and finally click Write Configuration (a button). Close the application, and detach the camera from the local net, and reattach it to the dedicated port (eth1) on its corresponding computer. If the above steps were successful, the camera should now respond to pings:
$ ping 192.168.3.3
from the computer to which it is attached. Fview, flydra_camera_node, and other such tools running on this computer should now all be able to see and use the camera. Further, the same Basler tools mentioned above should be able to use the camera on this host. E.g. capture a snapshot using the Pylon Viewer Application,
$ /opt/pylon/bin/PylonViewerApp
When building the motmot/libcamiface code, you need to set environment variables to point to the Basler Pylon libraries and include paths. Following with what has been done above,
$ export BASLER_PYLON_INCLUDE_PATH=/opt/pylon/include
$ export BASLER_PYLON_LIB_PATH=/opt/pylon/lib
The rest of the build and install process is as normal. Note that, if CMake fails to find the environment variables above, it will complain during the Makefile-generation step, i.e. after
$ cd /home/scott/scm/motmot/libcamiface
$ mkdir build
$ cd build
$ cmake ..
As a specific (and brief) use case, consider that all of the above steps have been completed. That is, you have installed the Basler Pylon software and can ping the camera. Now you wish to install fview and stream images from the camera. To install fview using Andrew Straw's public Ubuntu package repository (adding it to your apt source list is easy but outside the scope of this article), enter
$ sudo apt-get install python-motmot-fview
As part of the installation, apt-get will handle dependencies automatically and, importantly, install a version of libcamiface that does not support Basler. Thus let us build libcamiface from source and replace the apt-get installed edition. (Admittedly this is sloppy; however it is fast and easy.) Create a directory under which to place the sources, and pull from the GitHub repo:
$ mkdir scm
$ cd scm
$ git clone https://github.com/motmot/libcamiface.git
Now set appropriate environment variables and build the library, as noted above (and repeated here for convenience):
$ export BASLER_PYLON_INCLUDE_PATH=/opt/pylon/include
$ export BASLER_PYLON_LIB_PATH=/opt/pylon/lib
$ cd libcamiface
$ mkdir build
$ cd build
$ cmake ..
$ make
$ sudo make install
Finally, delete the edition of the library installed by apt-get:
$ sudo rm -ri /usr/lib/*libcam*
where you the flag "-i" is included to require confirmation before deleting, just to be sure. In my setup, the dialog was
rm: remove symbolic link `/usr/lib/libcam_iface_dc1394.so.0'? y
rm: remove regular file `/usr/lib/libcam_iface_dc1394.so.0.6.2'? y
rm: remove symbolic link `/usr/lib/libcam_iface_mega.so.0'? y
rm: remove regular file `/usr/lib/libcam_iface_mega.so.0.6.2'? y
In many situations, you must also augment the system library search path to find the basler-linked libcamiface.
$ export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib
You may also need to append this statement to the end of your shell init script (so that it is set automatically each time you login). E.g., with bash this can be done by
$ echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib' >> ~/.bashrc
Test the result by running fview.