zingmars / gst-pylonsrc

A gstreamer plugin for image capture from Basler's USB3 cameras. Please read the README before using.
Other
14 stars 7 forks source link
basler gst gstreamer plugin pylon usb3

gst-pylonsrc

Repository deprecation note

This plugin has been merged in https://github.com/joshdoe/gst-plugins-vision, where it will be updated and maintained by a new maintainer. The maintained version includes support for more parameters, compatibility with Microsoft Windows, and some internal fixes. This version is still functional, and can be used if for some reason you dislike CMake, and/or need to run the plugin only on Linux. If you find a problem with the version in this repository please try the version in the gst-plugins-vision repository first, and raise any issues in that repository if the issue is still present.

Original description

This is a gstreamer element that allows using Basler's USB3 Vision cameras using gstreamer.

This package also includes a simple plugin to check the framerate of any given pipeline called fpsfilter.

These plugins were open sourced by PlayGineering Ltd. on June 12, 2018.

Requirements

To run

To compile

Compiling

After cloning the repository run the autogen.sh file in the root directory of the project. Autoconf will generate everything required for compilation. After it completes simply run the make command in the root directory and it should compile.

Installation

After compiling there are two ways to install this plugin - automated and manual.

To install automatically simply run sudo make install inside the root directory of this project and Automake will automatically install the plugin.

To install manually you need copy, move or symlink the following files

to either of these locations:

Note that these are the default locations which might be different if you installed gstreamer with a custom location prefix.

Usage

To test whether this plugin was installed correctly use the gst-inspect-1.0 pylonsrc command. If it returns information about the plugin, then it's installed successfully and can be used like any other gstreamer source.

An example pipeline with this plugin for an older camera with no rgb8 support would be gst-launch-1.0 -v pylonsrc ! bayer2rgb ! videoconvert ! xvimagesink.

You set the parameters the same way one would set parameters for any other gstreamer pipeline element - by appending key=value to the plugin. For example, to get ycbcr422_8 output from the camera, you would write your pipeline like this - gst-launch-1.0 pylonsrc imageformat=rgb8 ! videoconvert ! xvimagesink.

Formats

This plugin supports the following output formats:

To change the output format simply set the imageformat parameter to the value of one of the formats above. Note that with the bayer formats you want to use the bayer2rgb plugin available in gst-plugins-bad (followed by videoconvert if you want the stream in YUY2 or similar format). RGB, BGR and Mono8 streams might require videoconvert for output to screen (video sinks such as xvimagesink only seems to play nice with YUY2 despite claiming to work with RGB).

Properties

If you have multiple cameras you can specify the camera you want to use using the camera parameter. To find out the IDs for each camera simply launch the pipeline without specifying the camera parameter, and the plugin will output them.

Each camera has a custom field that is saved on the camera called userid. This parameter allows user to quickly identify cameras on the field. This parameter will be listed when connecting to a camera or listing the devices. It can be set by either passing the userid parameter to the plugin, or by setting it in the Pylon Viewer App (camera -> Device Control -> Device User ID).

If you want to set a custom resolution you can do so with the width and height parameters. To find out the maximum resolution of the camera either refer to camera's technical specs or simply launch the plugin with logging tuned to loglevel4 (GST_DEBUG=pylonsrc:4), and it will output the maximum resolution the camera is capable of. Please note that the camera actually saves the resolution you set, so if you launch a pipeline with a camera once while specifying a resolution then the following runs will use the same resolution unless you either reconnect the device or specify a different resolution.

You can also specify resolution offsets to slightly move the image. Possible offsets are calculated max(width|height)-current(width|height). The parameters to specify offsets are offsetx and offsety. If you want to center the image you can use centerx and centery. Note that setting the centering parameters will cause the plugin to ignore the offset values.

The limitbandwidth parameter can be used to disable bandwidth limitations on the cameras. Basler cameras seem to limit themselves to 300MB/s (which is approx 130fps with a 1920x1200 resolution). Depending on the camera, it might be required to change the sensor readout mode (sensorreadoutmode) to fast for this to have any effect, as the default settings are usually close to the normal readout mode's maximum values. The possible values for this are either on or off. If you want to limit bandwidth to a specific number then set this property to on (or just don't specify it as on is the default) and use the maxbandwidth parameter which takes in the number of bytes per second that the camera will send data at. Note that setting the value too low will cause the camera to send data at a lower framerate than it is capable of, while setting it too high will in most cases have no discernible effect as the camera will only use as much bandwidth as it needs for the specified resolution and framerate. To see the bandwidth use run the pipeline with debugging level set to 4 (i.e. by adding GST_DEBUG=pylonsrc:4 before the gst-launch-1.0 command) and all of the information related to framerate and bandwidth will be printed to screen during the initialisation procedure.

To achieve the full potential of the camera it might be required to set the sensor readout mode to fast. To do this use the sensorreadoutmode parameter which takes in either fast or normal as values. As the name implies, fast allows for higher framerates, while normal is the safe (and default) option.

To change the framerate use the fps property.

To have the camera send a test pattern instead of a video stream you can use the testimage property. It accepts values from 1-6 all of which correspond to different test patterns.

There are two modes for picture capture - trigger mode and continuous. Trigger mode asks for each frame seperately which while continuous mode makes the camera capture frames without software input. Continuous is default, but it can be disabled by setting the continuous parameter to false (default - true).

NOTE: Some of the parameters are saved to the camera. Running the pipeline multiple times without either reconnecting the device or using the reset parameter might cause weird behaviour. See the gst-inspect-1.0 output for more details.

Image settings

To fine tune the image you can use the following properties:

Recording: GST_DEBUG=pylonsrc:5 gst-launch-1.0 pylonsrc camera=0 ! bayer2rgb ! videoconvert ! x264enc noise-reduction=10000 pass=4 quantizer=22 bitrate=32768 speed-preset=0 byte-stream=true ! matroskamux ! filesink location='recording.mkv' sync=false

Record a video at 150fps: GST_DEBUG=pylonsrc:5 gst-launch-1.0 pylonsrc limitbandwidth=off sensorreadoutmode=fast fps=150 ! bayer2rgb ! videoconvert ! matroskamux ! filesink location='recording.mkv

fpsfilter

This package includes a simple plugin called fpsfilter. To use it simply plug it in any pipeline you want.

For example - GST_DEBUG=pylonsrc:5 gst-launch-1.0 pylonsrc ! fpsfilter ! bayer2rgb ! videoconvert ! xvimagesink.

The output is displayed in the console. You can control the frequency of the reports using reporttime parameter, which (in miliseconds) defines the time between messages that are sent to the screen. (default - 1000ms).

Misc

If you need to reset the camera(s) quickly but don't want to reset it(them) using the reset parameter, you can use the reset.sh file in the tools directory which will reset the USB devices.

TODO