Technical Application Note (TAN2010003): Image Tearing Causes and Solutions
This application note explains image tearing, how to detect it, its causes, and recommended solutions.
Image tearing refers to the display of images that appear broken or misaligned. Image tearing has been seen on both laptop and desktop systems, and across a variety of hardware platforms and operating systems. It is not specific to any particular system configuration, and has been known to occur with FireWire and USB 2.0 devices.
There is a difference between horizontal image tearing where the image appears torn due to a problem with the video display, and the broken or torn images resulting from corrupt data. The following sections explain some common causes of image tearing and suggest solutions.
The following images show examples of image tearing.
With FlyCapture SDK version 18.104.22.168 and newer, you can detect when the camera transmits a torn image. To use this feature, the following additional components are required:
To get the necessary software and firmware updates, visit the downloads page.
Image tearing can happen on both FireWire and USB 2.0 cameras, but has different causes.
FireWire transfers a complete image to the PC at one time. Image data feeds into the FIFO buffer on the host adapter, where it is picked up. If the PC cannot keep up with grabbing the data from the controller’s FIFO, the FIFO overflows and data is dropped.
USB 2.0 transfers data differently. Data is stored in a FIFO on the USB 2.0 camera, and polled by the PC directly. The data is sent in 512-byte packets. The PC polls the device every time it wants to receive the next packet. If the PC does not grab the data from the camera’s FIFO quickly enough, the FIFO overflows and data is dropped.
The main limitation of USB 2.0, and the reason it may tear more often than FireWire, is the limited amount of resources on the camera, which keeps the FIFO buffer relatively small. USB 2.0 cameras depend on the PC to ask for data, so if the PC is too busy, the camera’s FIFO can overflow quickly. FireWire cameras do not depend on the PC to ask for data; it is sent to the host adapter at the proper rate, and the camera’s FIFO does not overflow. Since there are more resources on the host adapter, FIFO buffers are larger, reducing the chance for overflow.
The FIFO buffers on FLIR machine vision USB 2.0 cameras are the same size. However, different cameras may fill their FIFOs at different data rates, so one camera may fill up quicker than another. Any property that affects the data rate can contribute to overflowing, such as pixel clock, frame rate, line rate, and valid pixels in a line. In general, the slower the data rate, the less likelihood of a FIFO overflow, even if the PC does not poll as quickly as it should. For example, a Firefly MV-03MT may have fewer torn images than a Chameleon because it runs at a slower pixel clock and lower resolution (assuming the Chameleon is running at full resolution). However, a Firefly MV 13S2 may have more torn images than a Chameleon, since it runs at a higher pixel clock, assuming the same resolution.
Horizontal tearing, such as the example shown in Figure 1, is often a video display issue, rather than a problem with the actual image data. To verify that the image data is not corrupted, run the SaveToAVI example available with the FlyCapture SDK, and analyze each frame of the AVI.
If the image data is not corrupt, the most likely reason for image tearing is that the frame rate of the image display is not synchronized with the refresh rate of the monitor. The monitor video display buffer fills with data, which is then displayed. Sometimes the display buffer only partially fills before the monitor grabs it and displays it to the screen. This causes the tearing effect and is more noticeable if the camera is being panned and there is a significant difference in image content between frames. For recommendations on how to reduce this type of image tearing, contact our Technical Support team.
If the image data is corrupt, review the following sections to find the likely causes and solutions.
Hardware issues may contribute to torn images on both FireWire and USB. 2.0 cameras. Some problems are specific to the interface, while others are more general.
Here are some common hardware issues that may contribute to torn images with both FireWire and USB 2.0 cameras:
Note: Disabling onboard devices may reduce image tearing.
PCMCIA 1394 or CardBus controllers on laptop systems often have difficulty keeping up with required data transfer rates. Here are some possible solutions:
Power-saving features added to the chipsets of more recent CPUs can interfere with data transmission. Adjusting the settings of some of these features may address image tearing when running cameras at higher data rates.
Torn images may result from the CPU entering a sleep state. The FlyCapture SDK provides a command prompt utility to disable CPU sleep states. Run the RegistryControlUtility (C:\Program Files\Point Grey Research\FlyCapture2\bin64\RegistryControlUtility.exe) which can control the sleep state state of the system.
For information about usage and parameters, run from the command prompt. The parameters are:
Disable— disables all processor sleep states
enable— enables processor sleep states
Follow these steps to turn off the power-saving features of USB root hubs on your system:
Use of the C1E Enhanced Halt State can cause image tearing. This is primarily due to C1E slowing the transfer of image data off the FireWire host adapter card, which results in FIFO overflows. In some cases, it is possible to disable this feature in the host system's BIOS. If this is not possible, use the RegistryControlUtility (C:\Program Files\Point Grey Research\FlyCapture2\bin64\RegistryControlUtility.exe) to adjust the CPU settings to turn off the C1E state.
With FireWire cameras, certain bandwidth issues may contribute to image tearing. For example, if the host system or PC cannot keep up with data rates across the 1394 PCI or laptop PCMCIA bus, corrupt images may occur. Reasons for these types of situations include:
PCI bus saturation is a common situation and can happen for a number of reasons, including:
When the PCI bus is saturated, the system cannot keep up with the data rates going across it. As a result, images cannot be pulled off the 1394 PCI card fast enough. The isochronous FIFO buffers on-board the card gradually fill with image data from the camera, and eventually a general FIFO overflow occurs. These overflows can result in:
Typically, synchronization packets prevent repeated image tearing. When data is dropped, the current image is torn, but the image corrects itself for the next frame, unless data is dropped from that image as well. Note that general FIFO overflows occur at the lowest level of the Windows IEEE 1394 substructure, making them beyond the control of FLIR drivers and software.
Corrupted data when using the IEEE 1394 port on a laptop computer can be caused by too much latency in the C3 power state transition, which causes buffer overruns on the host adapter. The interrupts associated with the processor's ability to dynamically change speeds conflict with the high demand on the processor that is needed when streaming video or data across the IEEE 1394 port. This is seen on laptops from various manufacturers.
The following suggestions may help to avoid torn images, depending on system components and configuration, speed and/or hardware:
A combination of solutions may be required to minimize occurrence of torn images.