Losing frames - Pylon for linux on a PC
Hi everyone,
I have a problem with losing frames. I am using pylon für linux (on a PC). What can I do to solve this?
Regards.
What camera model do you use?
If you happened to lose frames (images) while running the Pylon Viewer (a pylon SDK sample or your own application) on a Linux PC, you have to consider the measures suggested in this FAQ.
If you run the PylonViewerApp (i.e. the Pylon Viewer) from a console you may get error messages while running a camera in continuous shot mode, like:
Failed to grab image: GX status 0xe1000014.
This error message means "The buffer was incompletely grabbed" and may have different origins.
You can also check if you were using frames in pylon viewer -> Stream Prameters -> Statistic -> Failed Buffer Count. If this parameter was different than "0", it means you are losing frames.
I. The first thing you have to check is, if your network adapter supports Jumbo Frames (IP packets bigger than 1500 Byte). If yes, Jumbo Frames should be enabled by setting the Maximum Transfer Unit (MTU) size to 8192.
You can check what is the currently used MTU value of all adapters by executing the following command in a console:
ifconfig
If the MTU was e.g. only 1500, you have to try to increase it (if the adapter supported bigger values though) by executing the following command, e.g. for an adapter called "eth0":
ifconfig eth0 mtu 8192
FYI: The recommended Gigabit Ethernet (GigE) network adapters for use with Basler GigE cameras are the adapters in the Intel PRO 1000 series. Although the pylon software will run with any GigE network adapter, we observed a significantly higher CPU load when grabbing image data with network adapters other than the recommended Intel PRO 1000 series.
Having set the MTU= 8192 you may set the camera's Packet Size= 8000, for example ( or to the maximum supported MTU, e.g. 3000, 6000).
If no Jumbo Frames were suppoted by your NIC though, you have to use Packet Size= 1500.
The Packet Size parameter can be found in the camera feature tree under "Transport Layer" in Pylon Viewer.
II. In addition to that, you also have to check and eventually increase the ReceiveThreadPriority of the pylon acquisition threads.
To check the ReceiveThreadPriority switch to User Level "Guru" in Pylon Viewer and go to the Stream Parameters.
If the ReceiveThreadPriority= 0 you have to necessarily increase it.
To do that you have to add the following line:
* - rtprio 99
to /etc/security/limits.conf
After changing the /etc/security/limits.conf file, logging off and on again is required.
Now the ReceiveThreadPriority in Pylon Viewer should be set to about 50, for instance.
III. In addition, you have to increase the SocketBufferSize in order to increase the buffer size for incoming images.
In order to retrieve the current value of SocketBufferSize in [Bytes], execute the following command in a console:
sysctl net.core.rmem_max
If the retrieved value was smaller than e.g. 4096000, i.e. 4 MByte, you have to increase it.
You can do that by executing the following command in a console (you need "root" rights):
sudo sysctl -w net.core.rmem_max= 4096000
IV. In order to "tune" the settings of a given network adapter and by that to improve the overall system performance (e.g. decrease the CPU load), you have to configure the Interrupt Moderation Rate accordingly.
To do so, first check if your given adapter supports "coalesce settings".
For an adapter called e.g. "eth0" execute the following command in a console:
ethtool -c eth0
If you did not get any error message but an output like that, e.g.:
Coalesce parameters for eth0:
Adaptive RX: off TX: off
stats-block-usecs: 0
sample-interval: 0
pkt-rate-low: 0
pkt-rate-high: 0
rx-usecs: 20
rx-frames: 5
rx-usecs-irq: 0
rx-frames-irq: 5
tx-usecs: 0
tx-frames: 0
tx-usecs-irq: 0
tx-frames-irq: 0
rx-usecs-low: 0
rx-frame-low: 0
tx-usecs-low: 0
tx-frame-low: 0
rx-usecs-high: 0
rx-frame-high: 0
tx-usecs-high: 0
tx-frame--high: 0
This means your adapter can be tuned (otherwise you cannot do the follwing).
In this case try setting the following parameters by the commands (you need "root" rights):
**sudo ethtool -C eth0 rx-usecs 1000
sudo ethtool -C eth0 rx-frames 4096**
The value 4096 for rx-frames represents the absolute maximum and may not be supported by most NICs.
Hence, if you failed while setting it, try to find out what the maximum supported value for your given NIC is by testing with values like e.g. 2048, 1024, 512, 256, 128 etc.
V. If none of these measures would resolve the problem, you could also try :
(1) increasing the Inter-Packet Delay (in the camera's "Transport Layer" node) to a value that starts decreasing the maximal resulting camera frame rate (in the node Acquisition Controls -> Resulting Frame Rate (Abs) [Hz]).
(2) look for a driver update for the given network card.
Just drop us an email to ... Show more