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.
(This node configures whether the acquisition frame rate is constrained to prevent the device bandwidth from being exceeded.
This node must be set to False so to enable the frame rate to to be increased past this constraint.) - 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