How do I calculate the packet delay for a GigE Vision camera to prevent dropped frames?

75 views (last 30 days)
I am using a GigE Vision compliant camera with the Image Acquisition Toolbox GigE Vision adaptor. However, after a number of frames are acquired the acquisition stops and the following error message is displayed:
ERROR: gige: Block/frame 23 is being dropped because a lost packet is unable to be resent.There are several possible causes for packets being lost. See the troubleshooting information in the "Configuring GigE Vision Devices" section of the Image Acquisition Toolbox documentation.
How can I calculate the recommended packet delay corresponding to my camera settings?

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 14 Oct 2021
Edited: MathWorks Support Team on 14 Oct 2021
Note: Before configuring the camera GigE streaming parameters in MATLAB, make sure the Gigabit Ethernet card/adapter configuration and network connection settings are according to the "GigE Vision Quick Start Configuration Guide" (attached at the end of this article as GigEVisionQuickStart.pdf).
The following documentation pages contain additional configuration and troubleshooting information:
The dropped frame error message can be caused by GigE packets being lost as a result of high CPU load.
To lower the CPU load when acquiring images with the GigE adaptor try the following:
1. Raise the value of the PacketSize source property while making sure it is not larger than the Ethernet card jumbo frame/packet size.
Note: With some hardware configurations the dropped frame error might be encountered when the PacketSize is equal to the Ethernet card jumbo frame size, so try using smaller PacketSize values (for example, if the Ethernet card Jumbo frame is 9000 bytes, try setting the PacketSize to 8000).
2. For optimum performance and to prevent dropped frames configure the camera to insert an appropriate delay between packets by setting the PacketDelay source property.
  • The PacketDelay property is available for Image Acquisition Toolbox 4.2 (R2011b) and above
  • Starting in MATLAB R2013a the toolbox does an automatic configuration of the PacketSize value. This should lead to increased performance and lower CPU load. Due to this optimization of PacketSize, you may need to adjust your PacketDelay accordingly.
The recommended PacketDelay value depends on the PacketSize, camera resolution (image height and width), pixel format (for example 'Mono8'), camera frame rate, and other camera specific settings.
The attached CalculatePacketDelay.m and CalculateFrameRate.m scripts can be used to calculate the recommended PacketDelay value.
The 'CalculatePacketDelay.m' script will calculate the recommended packet delay corresponding to the frame rate the camera is set to operate at and it takes as input arguments the video input object and the camera frame rate.
CalculatePacketDelay(vid, framesPerSecond)
Depending on the camera model, the camera frame rate may be obtained as a device specific property, but it can also be estimated (or verified) with the 'CalculateFrameRate.m' script, which acquires a specified number of frames to determine an effective frame rate.
CalculateFrameRate(vid, framesToAcquire)
>> vid = videoinput('gige', 1, 'Mono8');
>> src = getselectedsource(vid);
>> src.PacketSize = 9014;
>> framesToAcquire = 5;
>> framesPerSecond = CalculateFrameRate(vid, framesToAcquire)
ans =
>> delay = CalculatePacketDelay(vid, framesPerSecond)
Calculating Packet Delay for:
FrameRate = 10, PacketSize = 9014, FrameHeight = 656, FrameWidth = 490, VideoFormat = Mono8
Time stamp tick frequency (ticks/s): 31250000.0
Used gigabit bandwitdh: 2.6 %
Packet Delay: 72097.8 (ticks)
delay =
>> src.PacketDelay = delay;
Note: To prevent acquisition stopping due to a dropped frame error, use the PacketDelay value recommended for your camera configuration parameters. Using values arbitrarily larger or smaller is not likely to provide a correct configuration for the GigE streaming process.
  1 Comment
Julia Antoniou
Julia Antoniou on 5 Jul 2018
Hi David,
Apologies for the delayed reply. I would recommend contacting MathWorks Technical Support directly about this question. You can do so here:

Sign in to comment.

More Answers (1)

cr on 7 Dec 2015
Edited: cr on 8 Dec 2015
On my camera (Basler ACE2500 14gm), packetSize setting behaves in a manner opposite to what's been described here. The default packetSize is 2000 and when I increase it to 8192 (with Jumbosize set to 9014) the CPU usage still remains very high (over 90% for 8fps Mono8). Hence, increasing the PackDelay setting even to 10000 as next step doesn't help much (The vendor software does 8fps while not using CPU above 25%). However, if I reduce packetSize to 500 it helps the CPU usage magically. The packetDelay setting then kicks in to reduce CPU load even further. With packetSize of 300 and delay of 8000 I'm able to closely match vendor software performance. I don't know if these guidelines and settings work for anyone or the general recommendations here depend of camera/driver, etc but they certainly didn't work for me and, worse, are misguiding. The attached utility files often suggest packetDelay values that make camera return no images. E.g. With 10fps and the settings aforementioned, the packetDelay suggested was 250, an unusable value.




Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!