ImFusion SDK 4.3
ImFusionImage Class Reference

#include <ImFusion/Base/ImFusionImage.h>

Loading and saving of the ImFusion image format. More...

+ Inheritance diagram for ImFusionImage:

Detailed Description

Loading and saving of the ImFusion image format.

Classes

class  ImFusionImageHeader
 For image types, the corresponding data block contains the following header. More...
 

Public Member Functions

 ImFusionImage ()
 Constructor with filename to load or save.
 
 ~ImFusionImage () override
 Deletes all auxiliary storage however not any loaded data.
 
void setCompressionOptions (int mode, int passes, int dx, int dy)
 Set options for image compression.
 
DataloadInstance (unsigned int type, unsigned int headerSize) override
 Create specialized instance for a given data type or return null if not supported.
 
unsigned int saveType (const Data *data) override
 Return type for saving a given data instance or null if not supported.
 
bool load (unsigned int type, Data *data, std::istream &file, Progress *p=0) override
 Load specified data type into given class instance from file, return true upon success.
 
bool save (Data *data, std::ostream &file, Progress *p=0) override
 Save a data instance to file, return true if successful.
 
bool startSaveAsync (SharedImageSet *is, std::ostream &file, Progress *p=0)
 Prepares the asynchronous saving of images.
 
bool addFrameAsync (TypedImage< unsigned char > *memImg, std::ostream &file)
 After calling startSaveAsync(), call this method to save an image. Blocking.
 
bool closeAsync (SharedImageSet *is, std::ostream &file, bool saveTimestamps=false)
 After calling startSaveAsync() and addFrameAsync() for each image, finalize the operation with this method.
 
bool loadFromAsyncFormat (SharedImageSet *is, std::istream &file, Progress *p=0)
 Reads a SharedImageSet that was saved with startSaveAsync/addFrameAsync/closeAsync.
 
void setCurrentFilePath (const std::string &path)
 Sets the path of the current IMF file being loaded/saved.
 
const std::stringcurrentFilePath () const
 Returns the path of the current IMF file being loaded/saved.
 
- Public Member Functions inherited from ImFusionFilePlugin
virtual ~ImFusionFilePlugin ()=default
 Destructor.
 
virtual std::unique_ptr< PropertiescustomPropertiesToSave (Data *)
 Lets plugin save custom properties as part of the global file metadata.
 
virtual bool loadCustomProperties (Data *, Properties *)
 Load custom properties as returned previously by customPropertiesToSave()
 
virtual void applyFlipToEnsureConsistency (Data *)
 Is called after the image content had to be flipped to ensure a consistent coordinate system.
 
virtual bool beginBlockRead (std::iostream &, unsigned long long)
 Initialize plugin with current file pointer.
 
virtual bool endBlockRead ()
 Indicate to plugin that it will lose read access to the file pointer after this call.
 
virtual void setBlockType (unsigned int type)
 Set the type of current data block which is being loaded/saved.
 

Static Public Member Functions

static unsigned int imageSaveType (const SharedImageSet *is)
 Return the first 9 bits of the save type of a given SharedImageSet.
 

Protected Member Functions

virtual bool loadHeader (std::istream &file)
 Load the file header, return true upon success.
 
virtual unsigned char saveHeader (std::ostream &file, SharedImageSet *is, ImageCompression *c, int nf)
 Save the file header, return the data format.
 
bool loadFrame (std::istream &file, const ImageDescriptor &d, const mat4 &m, const double t, unsigned int blockType, SharedImageSet *is)
 Loads an image data frame, returns true if successful.
 
ImageDescriptor loadDescriptor (std::istream &file)
 Load an image descriptor.
 
void saveDescriptor (std::ostream &file, const ImageDescriptor &d, int reverseScaling=1)
 Save an image descriptor.
 
mat4 loadMatrix (std::istream &file)
 Load a transformation matrix.
 
void saveMatrix (std::ostream &file, const mat4 &m)
 Save a matrix.
 
void saveImage (std::ostream &file, const MemImage *img, unsigned char format) const
 Save a single image given compression format.
 
template<typename T>
void loadImage (std::istream &file, TypedImage< T > *img) const
 Template method to load a compressed image.
 
template<typename T>
void saveImage (std::ostream &file, const TypedImage< T > *img, unsigned char format) const
 Template method to actually save an image with compression.
 
Data::Modality computeModality (unsigned int blockType) const
 Assemble image modality from block type and data format.
 
std::string currentFileDirectory () const
 Returns the directory of the ImFusion file currently being loaded/saved.
 

Protected Attributes

Progressm_progress
 Optional progress callback interface.
 
std::vector< ImageDescriptorm_desc
 Image descriptors for per frame data.
 
std::vector< mat4 > m_matrices
 Matrix transformation for per frame data.
 
std::vector< double > m_timestamps
 Timestamp for per frame data.
 
ImFusionImageHeaderm_header
 The image format header.
 
DataList m_data
 List of all loaded image data.
 
- Protected Attributes inherited from ImFusionFilePlugin
unsigned int m_blockType = 0
 Keeps the type of currently saving/loading data block.
 

Options which are handed through to the ImageCompression class

int m_cMode
 Main compression mode.
 
int m_cPasses
 Number of passes for image compression.
 
int m_cDiffX
 X range for difference compression.
 
int m_cDiffY
 X range for difference compression.
 

Members for streaming

std::iostreamm_stream
 file stream
 
unsigned long long m_streamWritten
 number of bytes written
 
unsigned long long m_streamStartPos
 start offset
 

Members of async. saving

std::streampos m_asyncPosHeader
 Header position in current stream.
 
int m_asyncFrameCounter
 Frame counter (to fix header afterwards)
 
std::unique_ptr< ImageCompressionCodecm_asyncCompressor
 FFMPEP image compression engine.
 
std::string m_currentFilePath
 Path of the current IMF file being loaded/saved.
 
std::string m_asyncFilePath
 Path to the binary file with the actual images.
 

Methods for streaming images into file

bool beginBlockWrite (std::iostream &io) override
 Begin block to be written into file. Returns true if successful, false otherwise.
 
bool blockWriteImage (SharedImageSet *is)
 Stream image with header into block. Returns true if successful, false otherwise.
 
unsigned long long endBlockWrite () override
 Finish block written into file. Returns number of bytes written to the block.
 

Member Function Documentation

◆ loadInstance()

Data * loadInstance ( unsigned int type,
unsigned int headerSize )
overridevirtual

Create specialized instance for a given data type or return null if not supported.

Implements ImFusionFilePlugin.

◆ saveType()

unsigned int saveType ( const Data * data)
overridevirtual

Return type for saving a given data instance or null if not supported.

Implements ImFusionFilePlugin.

◆ load()

bool load ( unsigned int type,
Data * data,
std::istream & file,
Progress * p = 0 )
overridevirtual

Load specified data type into given class instance from file, return true upon success.

Reimplemented from ImFusionFilePlugin.

◆ save()

bool save ( Data * data,
std::ostream & file,
Progress * p = 0 )
overridevirtual

Save a data instance to file, return true if successful.

Reimplemented from ImFusionFilePlugin.

◆ startSaveAsync()

bool startSaveAsync ( SharedImageSet * is,
std::ostream & file,
Progress * p = 0 )

Prepares the asynchronous saving of images.

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

◆ closeAsync()

bool closeAsync ( SharedImageSet * is,
std::ostream & file,
bool saveTimestamps = false )

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

Without it, the data will not be readable. If desired, appends the images' timestamps at the end. If saveTimestamps is false, is can be nullptr.

◆ loadFromAsyncFormat()

bool loadFromAsyncFormat ( SharedImageSet * is,
std::istream & file,
Progress * p = 0 )

Reads a SharedImageSet that was saved with startSaveAsync/addFrameAsync/closeAsync.

Internally calls load(), and then reads any potential timestamps from the end.

◆ beginBlockWrite()

bool beginBlockWrite ( std::iostream & io)
overridevirtual

Begin block to be written into file. Returns true if successful, false otherwise.

Reimplemented from ImFusionFilePlugin.

◆ endBlockWrite()

unsigned long long endBlockWrite ( )
overridevirtual

Finish block written into file. Returns number of bytes written to the block.

Reimplemented from ImFusionFilePlugin.


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