Fawkes API
Fawkes Development Version
|
#include <>>
Public Types | |
enum | JpegColorspace { JPEG_CS_RGB, JPEG_CS_YUV } |
JPEG color space. More... | |
enum | JpegCompressorImplementation { JPEG_CI_LIBJPEG, JPEG_CI_MMAL } |
JPEG color space. More... | |
![]() | |
enum | CompressionDestination { COMP_DEST_FILE, COMP_DEST_MEM } |
Where to put the compressed image. More... | |
Public Member Functions | |
JpegImageCompressor (unsigned int quality=80, JpegColorspace jcs=JPEG_CS_RGB) | |
Constructor. More... | |
JpegImageCompressor (JpegCompressorImplementation impl_type, unsigned int quality=80, JpegColorspace jcs=JPEG_CS_RGB) | |
Constructor. More... | |
virtual | ~JpegImageCompressor () |
Destructor. More... | |
virtual void | set_image_dimensions (unsigned int width, unsigned int height) |
virtual void | set_image_buffer (colorspace_t cspace, unsigned char *buffer) |
virtual void | set_destination_buffer (unsigned char *buf, unsigned int buf_size) |
virtual size_t | compressed_size () |
virtual void | set_filename (const char *filename) |
virtual void | set_compression_destination (ImageCompressor::CompressionDestination cd) |
virtual bool | supports_compression_destination (ImageCompressor::CompressionDestination cd) |
virtual void | compress () |
virtual size_t | recommended_compressed_buffer_size () |
virtual bool | supports_vflip () |
virtual void | set_vflip (bool enable) |
![]() | |
virtual | ~ImageCompressor () |
Virtual empty destructor. More... | |
Jpeg image compressor. The compressor can choose from several actual implementations. The default is to use the system's version of libjpeg. On the Raspberry Pi the MMAL implementation (which uses VideoCore) is preferred.
Definition at line 37 of file jpeg_compressor.h.
JPEG color space.
Enumerator | |
---|---|
JPEG_CS_RGB | RGB. |
JPEG_CS_YUV | YUV444 packed. |
Definition at line 47 of file jpeg_compressor.h.
JPEG color space.
Enumerator | |
---|---|
JPEG_CI_LIBJPEG | Force usage of libjpeg for compression. |
JPEG_CI_MMAL | Force usage of MMAL for compression. |
Definition at line 53 of file jpeg_compressor.h.
|
explicit |
Constructor.
quality | JPEG quality in percent |
jcs | Jpeg colorspace |
Definition at line 49 of file jpeg_compressor.cpp.
|
explicit |
Constructor.
impl_type | force usage of this implementation type |
quality | JPEG quality in percent |
jcs | Jpeg colorspace |
Definition at line 71 of file jpeg_compressor.cpp.
|
virtual |
Destructor.
Definition at line 97 of file jpeg_compressor.cpp.
|
inlinevirtual |
Compress image.
Implements firevision::ImageCompressor.
Definition at line 100 of file jpeg_compressor.h.
Referenced by fawkes::WebviewJpegStreamProducer::loop(), and firevision::FuseServerClientThread::process_getimage_message().
|
inlinevirtual |
Get compressed size.
Implements firevision::ImageCompressor.
Definition at line 80 of file jpeg_compressor.h.
Referenced by fawkes::WebviewJpegStreamProducer::loop(), and firevision::FuseServerClientThread::process_getimage_message().
|
inlinevirtual |
Get the recommended size for the compressed buffer. It is not guaranteed that this size is really enough for compression but in most cases this should be suitable.
Implements firevision::ImageCompressor.
Definition at line 105 of file jpeg_compressor.h.
Referenced by fawkes::WebviewJpegStreamProducer::loop(), and firevision::FuseServerClientThread::process_getimage_message().
|
inlinevirtual |
Set compression destination.
cd | compression destination |
Implements firevision::ImageCompressor.
Definition at line 90 of file jpeg_compressor.h.
Referenced by fawkes::WebviewJpegStreamProducer::init(), and firevision::FuseServerClientThread::process_getimage_message().
|
inlinevirtual |
Set destination buffer (if compressing to memory).
buf | buffer |
buf_size | buffer size |
Implements firevision::ImageCompressor.
Definition at line 75 of file jpeg_compressor.h.
Referenced by fawkes::WebviewJpegStreamProducer::loop(), and firevision::FuseServerClientThread::process_getimage_message().
|
inlinevirtual |
Set file name.
filename | file name (if compressing to file) |
Implements firevision::ImageCompressor.
Definition at line 85 of file jpeg_compressor.h.
|
inlinevirtual |
Set image buffer to compress
cspace | colorspace of image |
buffer | buffer that contains the image |
Implements firevision::ImageCompressor.
Definition at line 70 of file jpeg_compressor.h.
Referenced by fawkes::WebviewJpegStreamProducer::init(), and firevision::FuseServerClientThread::process_getimage_message().
|
inlinevirtual |
Set dimensions of image to compress.
width | width of image in pixels |
height | height of image in pixels |
Implements firevision::ImageCompressor.
Definition at line 65 of file jpeg_compressor.h.
Referenced by fawkes::WebviewJpegStreamProducer::init(), and firevision::FuseServerClientThread::process_getimage_message().
|
inlinevirtual |
Enable or disable vflipping. This shall throw an exception if vflipping is not supported.
enable | true to enable vflipping, false to disable |
Exception | thrown if vflipping is not supported. |
Implements firevision::ImageCompressor.
Definition at line 115 of file jpeg_compressor.h.
Referenced by fawkes::WebviewJpegStreamProducer::init().
|
inlinevirtual |
Check if compressor supports desired compression destination.
cd | compression destination |
Implements firevision::ImageCompressor.
Definition at line 95 of file jpeg_compressor.h.
|
inlinevirtual |
Check if image compressor can do vflip during compress.
Vertical flipping (having the image upside down) is an operation necessary for example for cameras hanging upside down. During compression when the buffer is typically copied or converted line-wise anyway, this is a particularly cheap operation. Therfore we provide an API to implement this.
Implements firevision::ImageCompressor.
Definition at line 110 of file jpeg_compressor.h.
Referenced by fawkes::WebviewJpegStreamProducer::init().