The lossless compression feature is available on the following FLIR machine vision Blackfly S GigE cameras:
Application note description
This application note describes the lossless compression feature available on select FLIR machine vision cameras.
Preparing for use
Before you use your camera, we recommend that you are aware of the following resources available from our website:
- Camera Reference for the camera—HTML document containing specifications, EMVA imaging, installation guide, and technical reference for the camera model. Replace <PART-NUMBER> with your model's part number:
- Getting Started Manual for the camera—provides information on installing components and software needed to run the camera.
- Technical Reference for the camera—provides information on the camera’s specifications, features and operations, as well as imaging and acquisition controls.
- Firmware updates—ensure you are using the most up-to-date firmware for the camera to take advantage of improvements and fixes.
- Tech Insights—Subscribe to our bi-monthly email updates containing information on new knowledge base articles, new firmware and software releases, and Product Change Notices (PCN).
What is lossless compression?
Lossless compression is a feature that uses a lossless compression algorithm to reduce the amount of data transmitted from the camera while maintaining the image quality. Compressed images can be streamed in a FLIR proprietary format with Spinnaker and then saved to disk. These saved images can later be loaded into Spinnaker for processing.
The benefits include:
- Increase in frame rate
- Decrease in data over the link to allow for more cameras
- Decrease in space required to store the images on disk
As an example, a configuration with the BFS-PGE-50S5 (Sony IMX264) without compression might look like the following:
Using lossless compression with a compression ratio of 1:1.8 and 8-bit pixel format, the configuration could be:
Lossless compression is supported in the Spinnaker SDK version 184.108.40.206 (or later). Spinnaker can be downloaded from: https://www.flir.com/products/spinnaker-sdk/
You may need to upgrade your firmware to include lossless compression. The feature is supported in the following firmware (or later):
(Link goes to Camera Reference)
(includes firmware file)
To determine the firmware version number of your camera:
- Query the GenICam Device Control feature DeviceFirmwareVersion.
Camera firmware can be upgraded using SpinView, part of the Spinnaker SDK.
To upgrade the firmware:
- Download the firmware from the Package Zip link above.
- With your camera connected, start the SpinView application.
- From the Device list, right click the camera and select Update Device Firmware.
- If you get a Device is Active warning, close the Display pane or click the Disconnect button and right click the camera again.
- Browse to select the firmware file and click Open.
- Click Yes to continue.
Do not disconnect the camera during the firmware update process.
Lossless compression is best used in situations where the scene is fixed. Dynamic scenes do not compress as much.
How to enable lossless compression feature
By default, lossless compression is turned off. All the compression nodes are available to access from the Compression tab in SpinView.
To use lossless compression:
- Select the Pixel Format to be either Mono8 or BayerRG8.
- Ensure ISP Enable is not selected (disabled).
- From the Image Compression Mode drop-down, select Lossless. If this node is locked, ensure that ISP has been disabled and that a supported pixel format (Mono8 or BayerRG8) is selected.
- Select the Adaptive Compression Enable checkbox to allow dynamic updates to compression tables to achieve a better compression ratio. If unchecked, a fixed encoding table is used. Fixed encoding is optimized for typical scenes and provides good performance for a wide variety of images.
- Set the Max Datarate Threshold to be the maximum desired datarate in B/s. The camera either reduces the frame rate to stay at (or below) the maximum datarate, or drops frames to maintain the frame rate and not exceed the datarate. The method used depends on whether AcquisitionFrameRate is enabled (Drop Frames) or disabled (Reduce Frame Rate).
- Set Acquisition Frame Rate to be enabled or disabled depending on the desired saturation priority. Enabled prioritizes maintaining the frame rate over dropping frames. Disabled adjusts the frame rate to remain at or below the maximum datarate.
There are a number of read-only nodes to provide the following information:
- Compression Ratio—The ratio between size of data to transmit and actual uncompressed image size.
- Compression Saturation Priority—Dependent on AcquisitionFrameRate. If frame rate is enabled, the priority is to maintain that frame rate and drop frames if the maximum datarate is reached. If frame rate is disabled, the priority is to reduce the frame rate to achieve the maximum datarate.
- Current Datarate—The compressed datarate of the camera in B/s.
- Compressed FrameDrop Count—The number of frames dropped to keep the datarate below the maximum.
Lossless compression also adds the following information in Chunk Data:
- Chunk Compression Mode—Specifies whether image data is compressed.
- Chunk Current Datarate—Current datarate as calculated by the bitrate control algorithm in B/s. This is only used if frame is compressed.
- Chunk Compression Ratio—Specifies compression ratio for the current frame. This is only used if frame is compressed.
Compression saturation priority
A challenge when compressing images is that they change in size when the scene changes. This change in size can cause the bitrate of the interface to exceed its maximum. There are two modes for handling this scenario:
- Drop frames
- Reduce frame rate
The modes are controlled by the Acquisition Frame Rate Enable node. The method in use is reported by the Compression Saturation Priority node.
Method 1—Drop Frames
The Drop Frame mode prioritizes keeping the frame rate constant over dropping frame. It is best for situations with a relatively constant compression ratio where a constant frame rate is required. Users must determine an appropriate frame rate to minimize the chance of dropping an image. Current and previous frames are averaged to determine if a frame should be dropped.
To use this mode, enable Acquisition Frame Rate.
Method 2—Reduce Frame Rate
The Reduce Frame Rate mode prioritizes keeping the datarate under the threshold over maintaining a constant frame rate. It is best for situations where a variable frame rate is acceptable and a variable compression ratio is expected. The camera determines an acceptable frame rate to prevent dropped frames.
Note that the frame rate may be slightly lower than can be achieved with Drop Frame method (if near the maximum threshold). The default target bitrate threshold is 6% lower than the maximum.
To use this mode, disable Acquisition Frame Rate.
Compression saturation priority example
In a configuration with the BFS-PGE-23S3 (Sony IMX392) with one camera per one GigE NIC, with lossless compression enabled and a compression ratio of 1:1.8 (8-bit pixel format), the camera can achieve 80 FPS using bandwidth of 102 MB/s.
In this example if the compression ratio were to lower to 1.2 for 5 frames, the bitrate would be exceeded. How the camera behaves is dependent on the Compression Saturation Priority.
If the Compression Saturation Priority is DropFrame then the Acquisition Frame Rate of 80 FPS is maintained and approximately 2 frames are dropped.
Note that the first frame is not dropped as the average has not yet exceeded the bitrate threshold.
If the Compression Saturation Priority is ReduceFrameRate then the frame rate is reduced to ~61 FPS while the compression ratio is 1.2. When the compression ratio returns to 1.8, the Acquisition Frame Rate increases back to 80 FPS.
Note that frame timing shifts right as the frame rate is reduced.
The following factors can affect the compression performance:
- Complexity of the scene—Compression performance is scene dependent. Plain, textureless, static scenes have the best compression ratio.
- Sensor characterization, including noise levels—Difference sensors have different characterization, including noise level. This could lead to different compression ratios with different sensors for the same scene.
- Adaptive algorithm—FLIR's lossless compression is adaptive and takes 1-3 frames to achieve an optimal compression ratio.
- Gain/Noise—Lower gain means lower noise level which leads to a better compression ratio.
- Sharpness—An unfocused image means blurred, low spatial frequency which leads to a worse compression ratio.
- Resolution/Region of Interest (ROI)—A smaller ROI leads to a slightly better compression ratio in most cases.
- Exposure—A higher exposure time (with the same gain) creates a larger variance in pixel intensity which leads to a worse compression ratio.
The Spinnaker SDK comes with a compression example located in:
Program Files-->FLIR Systems-->Spinnaker-->src-->Compression