Browse KB Articles
Saving Images at High Bandwidth
KB Number: 10827
Technical Application Note (TAN2015001): Saving Images at High Bandwidth
Application Note Description
This Technical Application Note provides an analysis of the challenge of saving images at high bandwidth and offers methods to solve the issues.
The FlyCapture2 SDK includes a GUI application (FlyCap2) for capturing and saving images as well as an API for writing applications.
Using one of FLIR’s fastest Grasshopper3 USB 3.1 cameras, we demonstrate how to stream and save images to disk at a speed of 373 MB/s.
High Performance Recording
Many cameras are being used in very high bandwidth applications. There are many systems quite capable of displaying images under high bandwidth conditions. However, only a few systems manage to save images at high bandwidth.
Saving images to disk depends on multiple factors including:
In order to save images to disk, the following steps are typically required:
To achieve maximum image saving performance, we recommend:
There are two recording modes: Streaming and Buffered.
In Streaming mode, frames are written directly to disk and not buffered in system memory while recording. This recording mode is only recommended for users with a fast hard drive, as slower hard drives may result in dropped frames. The hard drive’s write speed should exceed the desired camera bandwidth for optimum results.
Image Acquisition in Streaming Mode
In Buffered mode, frames are being buffered into system memory while recording. This is recommended for users with slower hard drives. In this mode, FlyCapture continuously buffers images in physical memory until the memory usage reaches 95%. If the memory usage exceeds 95% recording stops.
Buffered mode introduces a small delay for memory allocation as FlyCapture must dynamically adjust system memory during runtime. The memory allocation delay is introduced when the current image memory is full.
Image Acquisition in Buffered Mode
Using FlyCapture2 to Record Images
Using the FlyCap2 GUI
To set the recording mode using the FlyCap2 GUI:
Using the FlyCapture2 API
By default, streaming mode is enabled. HighPerformanceRetrieveBuffer is a special acquisition call included in the FlyCapture2 API to enable buffered mode.
In the default mode, Retrieve buffer reads registers on the camera to determine which embedded image information settings are enabled, the current Bayer Tile settings. When High Performance mode is on, these reads are disabled. This means that any changes to the Bayer Tile or to the embedded image information after StartCapture() are not tracked when made using direct register writes. If the corresponding SetEmbeddedImageInfo() and GetEmbeddedImageInfo() calls are used then the changes are appropriately reflected. This also means that changes to embedded image info from other processes are not updated either.
Enable BUFFER_FRAMES and allocate a large number of buffers. (The default is 10 buffers allocated.) As an example, 100 buffers on a 2.3 MP camera would consume 100 x 2.3 MB = 230 MB RAM.
The following code snippet enables buffered mode and allocates 300 buffers:
We tested two high bandwidth cameras: FL3-U3-13Y3M and GS3-U3-23S6M using a console test application. The console test application uses FlyCapture2 API with HighPerformanceRetrieveBuffer mode enabled. For information on why this mode is not enabled by default, please see Frequently Asked Questions Q3.
Flea3—FL3-U3-13Y3M System Benchmark
Both systems we tested, the Dell T1600 and the standard configuration, allowed the FL3-U3-13Y3M camera to reliably stream and save at its maximum data rate of 188 MB/s via FlyCapture2 API.
The test below ran for 30 seconds.
Grasshopper3—GS3-U3-23S6M System Benchmark
Of the two systems tested, the Dell T1600 allowed the Grasshopper3 to stream and save at its maximum data rate of 373 MB/s. The standard PC was able to stream and save at a maximum rate of 202 MB/s.
The key difference between the two systems is that the Dell T1600 has a raid 0 configuration.
The test below ran for 30 seconds.
Frequently Asked Questions
Q1: How do I identify the hard drive disk write speed before I buy it?
You can get an idea of the hard drive write speed by reading the hard drive specification. The hard drive write speed advertised by modern hard drives or solid state drives does not apply to certain applications. This is because the hard drive write speed is benchmarked by writing sequentially to the hard drive. Typically, a large file size of 1 GB is used to benchmark the hard drive’s sequential write speed.
Q2: How do I evaluate my hard drive’s write speed?
Machine vision applications typically write images with a size of 1 to 10 MB. In order to find a hard drive that can handle saving images at the required speed, we should benchmark the hard drive with the actual image size produced by the camera.
We developed a utility, PointGreyHDDBenchmark, that can identify the maximum data write speed for your hard drive.
HighPerformanceRetrieveBuffer is disabled by default to provide customers the highest amount of flexibility. In general, Point Grey recommends enabling HighPerformanceRetrieveBuffer mode if you do not plan on dynamically changing embedded image information.