Quite OK Image Format (QOI) is a lossless image compression method that balances compression ratio and throughput. This article explains how to obtain a compressed image from a camera and how to decompress the image.
Prerequisites
- Phoenix camera with firmware v1.78 and higher
- Triton camera with firmware v1.127 and higher
- Arena SDK v1.0.49.3 and higher
How to enable QOI compression on your camera
- Stop streaming if the camera is streaming images
- Set Pixel Format to a QOI pixel format
- Mono cameras: QOI_Mono
- Color cameras: QOI_BayerRG8, QOI_Mono8, QOI_RGB8, QOI_BGR8, QOI_YCbCr8
- Mono cameras: QOI_Mono
- Set Acquisition Frame Rate Link Limit Enable = False.
- Set ISP Clock Speed = Fast.
Comparison
Example settings with a TRI032S-M and resulting change in frame rate are shown below.
Using Arena SDK to grab a QOI-compressed image
C++
Arena::SetNodeValue<<bool>(pDevice->GetNodeMap(), "AcquisitionFrameRateLinkLimitEnable", false);
Arena::SetNodeValue<GenICam::gcstring>(pDevice->GetNodeMap(), "ISPClockSpeed", "Fast");
Arena::SetNodeValue<GenICam::gcstring>(pDevice->GetNodeMap(), "PixelFormat", "QOI_Mono8");
pDevice->StartStream();
Arena::ICompressedImage* pCompressedImage = pDevice->GetCompressedImage(2000);
// use compressed image
pDevice->RequeueBuffer(pCompressedImage);
pDevice->StopStream();
See the following code samples, which are available with the Arena SDK or the Arena Python Package:
- Cpp_Acquisition_CompressedImageHandling
- Cs_Acquisition_CompressedImageHandling
- C_Acquisition_CompressedImageHandling
- py_acquisition_compressed_image_handling.py and py_acquisition_compressed_image_handling.ipynb
Using Arena SDK to decompress a QOI-compressed image:
C++
IImage* pDecompressedImage = Arena::ImageFactory::DecompressImage(pCompressedImage);
Arena::ImageFactory::Destroy(pDecompressedImage);
See the following code samples, which are available with the Arena SDK or the Arena Python Package:
- Cpp_Acquisition_CompressedImageLoading
- Cs_Acquisition_CompressedImageLoading
- C_Acquisition_CompressedImageLoading
- py_acquisition_compressed_image_handling.py and py_acquisition_compressed_image_handling.ipynb
Decompressing a QOI-compressed image
C++
#define QOI_IMPLEMENTATION
#include "qoi.h"
[...]
Arena::SetNodeValue<<bool>(pDevice->GetNodeMap(), "AcquisitionFrameRateLinkLimitEnable", false);
Arena::SetNodeValue<GenICam::gcstring>(pDevice->GetNodeMap(), "ISPClockSpeed", "Fast");
Arena::SetNodeValue<GenICam::gcstring>(pDevice->GetNodeMap(), "PixelFormat", "QOI_Mono8");
pDevice->StartStream();
Arena::ICompressedImage* pCompressedImage = pDevice->GetCompressedImage(2000);
qoi_desc desc = { 0 };
void* decompressed_image = qoi_decode(pCompressedImage->GetData(), (int)pCompressedImage->GetSizeFilled(), &desc, 1);
QOI_FREE(decompressed_image)
pDevice->RequeueBuffer(pCompressedImage);
The following decompression algorithms are used:
- Color images: https://github.com/phoboslab/qoi
- Mono images: https://github.com/jstavats/qoi
Using a non-QOI pixel format with a QOI configuration
If you use a non-QOI pixel format with the QOI configuration described above, you could encounter dropped frames.
Example:
- Pixel Format = Non-QOI pixel format
- Acquisition Frame Rate Link Limit Enable = False
- ISP Clock Speed = Fast
If the resulting bandwidth is beyond 1Gbps, you will encounter dropped frames on the host. The host is notified of these dropped frames with a “Frame Dropped” event.