ImFusion SDK 4.3
ImageCompressionCodec Class Reference

#include <ImFusion/Base/ImageCompressionCodec.h>

Saving and loading of compressed image data through video codecs. More...

+ Inheritance diagram for ImageCompressionCodec:

Detailed Description

Saving and loading of compressed image data through video codecs.

This class supports asynchronous saving of images. You need to instantiate a new object of this class with an image container that already has at least one image inside.

Note
This class requires libavcodec to be linked, which we don't do directly. Instead, we use OpenCV with FFMPEG support on, which makes automatically takes care of the correct libraries to link. Make sure that you use an FFMPEG version of at least 3.0.

Public Types

enum  CompressionCodec { FFV1 , H264 }
 Enum of supported video codecs. More...
 

Public Member Functions

 ImageCompressionCodec (SharedImageSet *is, const ImageDescriptor &desc)
 Constructor for loading data with empty image set container.
 
 ImageCompressionCodec (SharedImageSet *is)
 Constructor with an allocated image set container to save.
 
virtual ~ImageCompressionCodec ()
 Destructor.
 
bool load (std::istream &file)
 Loads a compressed image set.
 
bool save (std::ostream &file)
 Saves a compressed image set in one go.
 
bool startSaveAsync (std::ostream &file)
 Prepares the asynchronous saving of images.
 
bool addFrameAsync (TypedImage< unsigned char > *memImg)
 After calling startSaveAsync(), call this method to encode an image. Blocking.
 
bool closeAsync ()
 After calling startSaveAsync() and addFrameAsync() for each image, finalize the operation with this method.
 
void setProgress (Progress *p)
 Set optional progress callback.
 
void setCodec (CompressionCodec c)
 Sets the compression codec.
 
CompressionCodec codec () const
 Returns the compression codec.
 

Static Public Member Functions

static void registerAllCodecs ()
 To be called from base factory.
 

Protected Member Functions

bool encodeFrameInBuffer ()
 

Member Enumeration Documentation

◆ CompressionCodec

Enum of supported video codecs.

Enumerator
FFV1 

FFV1, lossless.

H264 

H264, not lossless, achieves high compression rates.

Member Function Documentation

◆ save()

bool save ( std::ostream & file)

Saves a compressed image set in one go.

Internally calls startSaveAsync(), addFrameAsync() for each frame, and eventually closeAsync().

◆ startSaveAsync()

bool startSaveAsync ( std::ostream & file)

Prepares the asynchronous saving of images.

The SharedImageSet provided in the constructor must already at construction (!) be filled with at least one image to ensure correct encoder metadata. Does not save any images, call addFrameAsync() for each image.

◆ closeAsync()

bool closeAsync ( )

After calling startSaveAsync() and addFrameAsync() for each image, finalize the operation with this method.

Without it, the data will not be readable.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close